|
| 1 | +name: E2E |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + kind-e2e: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + env: |
| 16 | + CLUSTER_NAME: backstage-e2e |
| 17 | + IMAGE: backstage:e2e |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 21 | + |
| 22 | + - name: Set up Docker Buildx |
| 23 | + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 |
| 24 | + |
| 25 | + - name: Build backend image |
| 26 | + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 |
| 27 | + with: |
| 28 | + context: . |
| 29 | + file: packages/backend/Dockerfile |
| 30 | + load: true |
| 31 | + tags: ${{ env.IMAGE }} |
| 32 | + cache-from: type=gha,scope=backstage-e2e |
| 33 | + cache-to: type=gha,mode=max,scope=backstage-e2e |
| 34 | + |
| 35 | + - name: Create kind cluster |
| 36 | + uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1 |
| 37 | + with: |
| 38 | + cluster_name: ${{ env.CLUSTER_NAME }} |
| 39 | + |
| 40 | + - name: Load image into kind |
| 41 | + run: kind load docker-image "${IMAGE}" --name "${CLUSTER_NAME}" |
| 42 | + |
| 43 | + - name: Install CloudNativePG operator |
| 44 | + run: | |
| 45 | + helm repo add cnpg https://cloudnative-pg.github.io/charts |
| 46 | + helm upgrade --install cnpg cnpg/cloudnative-pg \ |
| 47 | + --namespace cnpg-system --create-namespace \ |
| 48 | + --version '0.28.x' --wait --timeout 5m |
| 49 | +
|
| 50 | + - name: Deploy e2e overlay |
| 51 | + run: kubectl kustomize config/overlays/e2e | kubectl apply --server-side -f - |
| 52 | + |
| 53 | + - name: Wait for PostgreSQL |
| 54 | + run: kubectl -n backstage wait --for=condition=Ready cluster/backstage-postgres --timeout=5m |
| 55 | + |
| 56 | + - name: Wait for Backstage |
| 57 | + run: kubectl -n backstage rollout status deploy/backstage --timeout=10m |
| 58 | + |
| 59 | + - name: Smoke test backend |
| 60 | + run: | |
| 61 | + kubectl -n backstage run curl-smoke \ |
| 62 | + --image=curlimages/curl:8.10.1 \ |
| 63 | + --restart=Never --rm -i --quiet -- \ |
| 64 | + sh -ceu ' |
| 65 | + echo "readiness:" |
| 66 | + code=$(curl -sS -o /dev/null -w "%{http_code}" http://backstage:7007/.backstage/health/v1/readiness) |
| 67 | + echo "$code" |
| 68 | + [ "$code" = "200" ] |
| 69 | +
|
| 70 | + echo "liveness:" |
| 71 | + code=$(curl -sS -o /dev/null -w "%{http_code}" http://backstage:7007/.backstage/health/v1/liveness) |
| 72 | + echo "$code" |
| 73 | + [ "$code" = "200" ] |
| 74 | +
|
| 75 | + echo "catalog entities:" |
| 76 | + code=$(curl -sS -o /dev/null -w "%{http_code}" http://backstage:7007/api/catalog/entities) |
| 77 | + echo "$code" |
| 78 | + [ "$code" = "200" ] |
| 79 | + ' |
| 80 | +
|
| 81 | + - name: Dump diagnostics |
| 82 | + if: failure() |
| 83 | + run: | |
| 84 | + kubectl -n backstage get pods,svc,cluster |
| 85 | + kubectl -n backstage describe cluster/backstage-postgres || true |
| 86 | + kubectl -n backstage describe deploy/backstage |
| 87 | + kubectl -n backstage logs deploy/backstage --all-containers --tail=200 || true |
0 commit comments