|
1 | | -name: E2E Tests |
| 1 | +name: End-to-End Tests |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: {} |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + test_suite: |
| 11 | + description: 'Test suite to run (e.g., machineaccount, userdeactivation or empty for all)' |
| 12 | + required: false |
| 13 | + default: '' |
| 14 | + type: string |
| 15 | + |
| 16 | +env: |
| 17 | + # Enable experimental remote taskfiles feature |
| 18 | + TASK_X_REMOTE_TASKFILES: 1 |
| 19 | + # Test infrastructure configuration |
| 20 | + TEST_INFRA_CLUSTER_NAME: test-infra |
| 21 | + IMAGE_NAME: ghcr.io/datum-cloud/auth-provider-zitadel |
| 22 | + IMAGE_TAG: dev |
6 | 23 |
|
7 | 24 | jobs: |
8 | 25 | test-e2e: |
9 | | - name: Run on Ubuntu |
10 | 26 | runs-on: ubuntu-latest |
| 27 | + timeout-minutes: 60 |
| 28 | + |
11 | 29 | steps: |
12 | | - - name: Clone the code |
13 | | - uses: actions/checkout@v4 |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v6 |
14 | 32 |
|
15 | | - - name: Setup Go |
16 | | - uses: actions/setup-go@v5 |
| 33 | + - name: Set up Go |
| 34 | + uses: actions/setup-go@v6 |
17 | 35 | with: |
18 | | - go-version-file: go.mod |
| 36 | + go-version-file: 'go.mod' |
| 37 | + cache: true |
19 | 38 |
|
20 | | - - name: Install docker-compose |
| 39 | + - name: Install Task CLI |
21 | 40 | run: | |
22 | | - sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose |
23 | | - sudo chmod +x /usr/local/bin/docker-compose |
24 | | - docker-compose --version |
| 41 | + sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin |
25 | 42 |
|
26 | | - - name: Install the latest version of kind |
| 43 | + - name: Verify Task installation |
27 | 44 | run: | |
28 | | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 |
29 | | - chmod +x ./kind |
30 | | - sudo mv ./kind /usr/local/bin/kind |
| 45 | + task --version |
| 46 | + echo "Available tasks:" |
| 47 | + task --list |
31 | 48 |
|
32 | | - - name: Verify kind installation |
33 | | - run: kind version |
| 49 | + - name: Set up Docker Buildx |
| 50 | + uses: docker/setup-buildx-action@v4 |
| 51 | + with: |
| 52 | + buildkitd-config-inline: | |
| 53 | + [worker.oci] |
| 54 | + max-parallelism = 4 |
34 | 55 |
|
35 | | - - name: Create kind cluster |
36 | | - run: make kind-create |
| 56 | + - name: Install kubectl |
| 57 | + uses: azure/setup-kubectl@v4 |
| 58 | + with: |
| 59 | + version: 'v1.30.0' |
37 | 60 |
|
38 | | - - name: Running Test e2e |
| 61 | + - name: Install KinD |
| 62 | + uses: helm/kind-action@v1 |
| 63 | + with: |
| 64 | + install_only: true |
| 65 | + version: v0.24.0 |
| 66 | + |
| 67 | + - name: Verify prerequisites |
| 68 | + run: | |
| 69 | + echo "=== Checking prerequisites ===" |
| 70 | + docker version |
| 71 | + kubectl version --client |
| 72 | + kind version |
| 73 | + echo "Go version: $(go version)" |
| 74 | +
|
| 75 | + - name: Set up test environment |
39 | 76 | run: | |
40 | | - go mod tidy |
41 | | - make test-e2e |
| 77 | + echo "=== Setting up test environment ===" |
| 78 | + # This task handles cluster creation, image build/load, and deployment |
| 79 | + task ci:setup |
42 | 80 |
|
43 | | - - name: Cleanup kind cluster |
| 81 | + - name: Verify components |
| 82 | + run: | |
| 83 | + echo "=== Verifying Auth Provider Zitadel components ===" |
| 84 | + |
| 85 | + APP_NAMESPACE="auth-provider-zitadel-system" |
| 86 | + ZITADEL_NAMESPACE="zitadel-system" |
| 87 | +
|
| 88 | + # Verify components are running |
| 89 | + echo "Checking Auth Provider Zitadel components:" |
| 90 | + task test-infra:kubectl -- get pods -n $APP_NAMESPACE |
| 91 | +
|
| 92 | + # Wait for components to be ready |
| 93 | + echo "⏳ Waiting for controller manager to be ready..." |
| 94 | + task test-infra:kubectl -- wait --for=condition=Available deployment/controller-manager -n $APP_NAMESPACE --timeout=1000s |
| 95 | +
|
| 96 | + echo "⏳ Waiting for API server to be ready..." |
| 97 | + task test-infra:kubectl -- wait --for=condition=Available deployment/apiserver -n $APP_NAMESPACE --timeout=1000s |
| 98 | +
|
| 99 | + echo "⏳ Waiting for AuthN webhook to be ready..." |
| 100 | + task test-infra:kubectl -- wait --for=condition=Available deployment/authn-webhook -n $APP_NAMESPACE --timeout=1000s |
| 101 | +
|
| 102 | + echo "⏳ Checking Zitadel status..." |
| 103 | + task test-infra:kubectl -- wait --for=condition=Available deployment/zitadel -n $ZITADEL_NAMESPACE --timeout=1000s |
| 104 | +
|
| 105 | + # Verify Aggregated API Availability (CA Injection) |
| 106 | + echo "⏳ Verifying Aggregated API Availability..." |
| 107 | + for i in {1..30}; do |
| 108 | + CA_LEN=$(task test-infra:kubectl -- get apiservice v1alpha1.identity.miloapis.com -o jsonpath='{len(.spec.caBundle)}' 2>/dev/null || echo "0") |
| 109 | + if [ "$CA_LEN" -gt "0" ]; then |
| 110 | + echo "✅ CA Bundle injected into APIService." |
| 111 | + break |
| 112 | + fi |
| 113 | + echo "⏳ Waiting for CA injection into identity APIService (attempt $i/30)..." |
| 114 | + sleep 2 |
| 115 | + done |
| 116 | + |
| 117 | + # Verify Discovery works |
| 118 | + echo "Verifying API Discovery..." |
| 119 | + task test-infra:kubectl -- get apiservice v1alpha1.identity.miloapis.com |
| 120 | + |
| 121 | + echo "✓ Components verification complete" |
| 122 | +
|
| 123 | + - name: Run end-to-end tests |
| 124 | + run: | |
| 125 | + echo "=== Running end-to-end tests ===" |
| 126 | +
|
| 127 | + # Determine which tests to run based on input |
| 128 | + if [ -n "${{ github.event.inputs.test_suite }}" ]; then |
| 129 | + echo "Running specified test suite: ${{ github.event.inputs.test_suite }}" |
| 130 | + task test:end-to-end -- ${{ github.event.inputs.test_suite }} |
| 131 | + else |
| 132 | + echo "Running all end-to-end tests..." |
| 133 | + task test:end-to-end |
| 134 | + fi |
| 135 | +
|
| 136 | + - name: Collect debug information on failure |
| 137 | + if: failure() |
| 138 | + run: | |
| 139 | + echo "=== Collecting debug information ===" |
| 140 | + APP_NAMESPACE="auth-provider-zitadel-system" |
| 141 | + ZITADEL_NAMESPACE="zitadel-system" |
| 142 | +
|
| 143 | + # Cluster status |
| 144 | + echo "=== Infrastructure Cluster Status ===" |
| 145 | + task test-infra:kubectl -- get pods -A || true |
| 146 | + task test-infra:kubectl -- get nodes -o wide || true |
| 147 | +
|
| 148 | + # App status and logs |
| 149 | + echo "=== Auth Provider Zitadel Status ===" |
| 150 | + task test-infra:kubectl -- describe pods -n $APP_NAMESPACE || true |
| 151 | + |
| 152 | + echo "--- Controller Manager Logs ---" |
| 153 | + task test-infra:kubectl -- logs -n $APP_NAMESPACE -l app.kubernetes.io/component=controller-manager --tail=500 || true |
| 154 | + |
| 155 | + echo "--- API Server Logs ---" |
| 156 | + task test-infra:kubectl -- logs -n $APP_NAMESPACE -l app.kubernetes.io/component=apiserver --tail=500 || true |
| 157 | + |
| 158 | + echo "--- AuthN Webhook Logs ---" |
| 159 | + task test-infra:kubectl -- logs -n $APP_NAMESPACE -l app.kubernetes.io/component=authn-webhook --tail=500 || true |
| 160 | +
|
| 161 | + # Zitadel status and logs |
| 162 | + echo "=== Zitadel Status ===" |
| 163 | + task test-infra:kubectl -- describe pods -n $ZITADEL_NAMESPACE || true |
| 164 | + |
| 165 | + echo "--- Zitadel Logs ---" |
| 166 | + task test-infra:kubectl -- logs -n $ZITADEL_NAMESPACE -l app.kubernetes.io/name=zitadel --tail=500 || true |
| 167 | +
|
| 168 | + # PostgreSQL status |
| 169 | + echo "--- PostgreSQL Logs ---" |
| 170 | + task test-infra:kubectl -- logs -n $ZITADEL_NAMESPACE -l app=zitadel-postgresql --tail=100 || true |
| 171 | +
|
| 172 | + # Docker container status |
| 173 | + echo "=== Docker Containers ===" |
| 174 | + docker ps -a || true |
| 175 | +
|
| 176 | + # KinD cluster info |
| 177 | + echo "=== KinD cluster info ===" |
| 178 | + kind get clusters || true |
| 179 | + kind export logs /tmp/kind-logs --name $TEST_INFRA_CLUSTER_NAME || true |
| 180 | +
|
| 181 | + - name: Upload debug artifacts |
| 182 | + if: failure() |
| 183 | + uses: actions/upload-artifact@v7 |
| 184 | + with: |
| 185 | + name: debug-logs |
| 186 | + path: | |
| 187 | + /tmp/kind-logs/ |
| 188 | + if-no-files-found: ignore |
| 189 | + |
| 190 | + - name: Cleanup test infrastructure |
44 | 191 | if: always() |
45 | | - run: make kind-delete |
| 192 | + run: | |
| 193 | + echo "=== Cleaning up test infrastructure ===" |
| 194 | +
|
| 195 | + # Clean up test infrastructure cluster |
| 196 | + task test-infra:cluster-down || true |
| 197 | +
|
| 198 | + # Verify cleanup |
| 199 | + echo "Remaining KinD clusters:" |
| 200 | + kind get clusters || true |
| 201 | +
|
| 202 | + echo "Remaining Docker containers:" |
| 203 | + docker ps -a --filter "name=$TEST_INFRA_CLUSTER_NAME" || true |
0 commit comments