|
| 1 | +name: CI Provisioning E2E (Knative) |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + - release/* |
| 9 | + paths: |
| 10 | + - "packages/provisioning-handlers/**" |
| 11 | + - "tests/e2e/__tests__/provisioning-knative*" |
| 12 | + - "tests/e2e/fixtures/provisioning-knative*" |
| 13 | + - ".github/workflows/test-provisioning-e2e.yaml" |
| 14 | + push: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + - develop |
| 18 | + - release/* |
| 19 | + - feat/provisioning-handlers |
| 20 | + paths: |
| 21 | + - "packages/provisioning-handlers/**" |
| 22 | + - "tests/e2e/__tests__/provisioning-knative*" |
| 23 | + - "tests/e2e/fixtures/provisioning-knative*" |
| 24 | + - ".github/workflows/test-provisioning-e2e.yaml" |
| 25 | + workflow_dispatch: {} |
| 26 | + |
| 27 | +concurrency: |
| 28 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 29 | + cancel-in-progress: true |
| 30 | + |
| 31 | +jobs: |
| 32 | + e2e-knative: |
| 33 | + name: Provisioning E2E (Knative + kind) |
| 34 | + runs-on: ubuntu-latest |
| 35 | + timeout-minutes: 25 |
| 36 | + |
| 37 | + # ── PostgreSQL service container ────────────────────────────────────── |
| 38 | + services: |
| 39 | + postgres: |
| 40 | + image: postgres:16 |
| 41 | + env: |
| 42 | + POSTGRES_USER: postgres |
| 43 | + POSTGRES_PASSWORD: postgres |
| 44 | + POSTGRES_DB: provisioning_e2e |
| 45 | + ports: |
| 46 | + - 5432:5432 |
| 47 | + options: >- |
| 48 | + --health-cmd="pg_isready -U postgres" |
| 49 | + --health-interval=5s |
| 50 | + --health-timeout=5s |
| 51 | + --health-retries=10 |
| 52 | +
|
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v5 |
| 56 | + |
| 57 | + # ── Node / pnpm ──────────────────────────────────────────────────── |
| 58 | + - name: Setup pnpm |
| 59 | + uses: pnpm/action-setup@v6 |
| 60 | + |
| 61 | + - name: Setup Node.js |
| 62 | + uses: actions/setup-node@v5 |
| 63 | + with: |
| 64 | + node-version: "22" |
| 65 | + cache: "pnpm" |
| 66 | + |
| 67 | + - name: Generate function packages |
| 68 | + run: node --experimental-strip-types scripts/generate.ts |
| 69 | + |
| 70 | + - name: Install dependencies |
| 71 | + run: pnpm install |
| 72 | + |
| 73 | + - name: Build workspace |
| 74 | + run: pnpm build |
| 75 | + |
| 76 | + # ── kind cluster ─────────────────────────────────────────────────── |
| 77 | + - name: Setup kind cluster |
| 78 | + uses: helm/kind-action@v1 |
| 79 | + with: |
| 80 | + cluster_name: provisioning-e2e |
| 81 | + wait: 120s |
| 82 | + |
| 83 | + - name: Verify cluster |
| 84 | + run: | |
| 85 | + kubectl version |
| 86 | + kubectl get nodes -o wide |
| 87 | +
|
| 88 | + # ── Knative Serving ──────────────────────────────────────────────── |
| 89 | + - name: Install Knative Serving CRDs |
| 90 | + run: | |
| 91 | + KNATIVE_VERSION=v1.17.0 |
| 92 | + echo "Installing Knative Serving ${KNATIVE_VERSION} CRDs..." |
| 93 | + kubectl apply -f "https://github.com/knative/serving/releases/download/knative-${KNATIVE_VERSION}/serving-crds.yaml" |
| 94 | +
|
| 95 | + - name: Install Knative Serving core |
| 96 | + run: | |
| 97 | + KNATIVE_VERSION=v1.17.0 |
| 98 | + echo "Installing Knative Serving ${KNATIVE_VERSION} core..." |
| 99 | + kubectl apply -f "https://github.com/knative/serving/releases/download/knative-${KNATIVE_VERSION}/serving-core.yaml" |
| 100 | +
|
| 101 | + - name: Install Kourier networking |
| 102 | + run: | |
| 103 | + KNATIVE_VERSION=v1.17.0 |
| 104 | + echo "Installing Kourier networking layer..." |
| 105 | + kubectl apply -f "https://github.com/knative/net-kourier/releases/download/knative-${KNATIVE_VERSION}/kourier.yaml" |
| 106 | +
|
| 107 | + kubectl patch configmap/config-network \ |
| 108 | + --namespace knative-serving \ |
| 109 | + --type merge \ |
| 110 | + --patch '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}' |
| 111 | +
|
| 112 | + - name: Wait for Knative Serving pods |
| 113 | + run: | |
| 114 | + echo "Waiting for Knative Serving pods..." |
| 115 | + kubectl wait --for=condition=Available deployment --all \ |
| 116 | + -n knative-serving --timeout=180s || true |
| 117 | +
|
| 118 | + echo "=== Knative Serving pods ===" |
| 119 | + kubectl get pods -n knative-serving |
| 120 | + echo "=== Kourier pods ===" |
| 121 | + kubectl get pods -n kourier-system || true |
| 122 | +
|
| 123 | + - name: Verify Knative CRDs |
| 124 | + run: | |
| 125 | + echo "Checking for serving.knative.dev CRDs..." |
| 126 | + kubectl get crd | grep knative || { echo "No Knative CRDs!"; exit 1; } |
| 127 | +
|
| 128 | + # ── Bootstrap DB ─────────────────────────────────────────────────── |
| 129 | + - name: Bootstrap minimal DB for provisioning |
| 130 | + env: |
| 131 | + PGHOST: localhost |
| 132 | + PGPORT: "5432" |
| 133 | + PGUSER: postgres |
| 134 | + PGPASSWORD: postgres |
| 135 | + PGDATABASE: provisioning_e2e |
| 136 | + run: | |
| 137 | + psql -f tests/e2e/fixtures/provisioning-knative-bootstrap.sql |
| 138 | + echo "DB bootstrap complete." |
| 139 | +
|
| 140 | + echo "=== Verify seed data ===" |
| 141 | + psql -c "SELECT name FROM metaschema_public.namespace;" |
| 142 | + psql -c "SELECT name, image FROM constructive_compute_public.platform_function_definitions;" |
| 143 | +
|
| 144 | + # ── Start proxies ────────────────────────────────────────────────── |
| 145 | + - name: Start kubectl proxy and Kourier port-forward |
| 146 | + run: | |
| 147 | + # K8s API proxy for @kubernetesjs/ops |
| 148 | + kubectl proxy --port=8001 & |
| 149 | + echo "kubectl proxy started on :8001" |
| 150 | +
|
| 151 | + # Wait for Kourier service to exist |
| 152 | + echo "Waiting for Kourier service..." |
| 153 | + for i in $(seq 1 30); do |
| 154 | + if kubectl get svc kourier -n kourier-system &>/dev/null; then |
| 155 | + echo " Kourier service found" |
| 156 | + break |
| 157 | + fi |
| 158 | + echo " attempt $i: waiting..." |
| 159 | + sleep 5 |
| 160 | + done |
| 161 | +
|
| 162 | + # Port-forward Kourier for function invocation |
| 163 | + kubectl port-forward -n kourier-system svc/kourier 8090:80 & |
| 164 | + echo "Kourier port-forward started on :8090" |
| 165 | +
|
| 166 | + sleep 3 |
| 167 | +
|
| 168 | + # ── Run E2E tests ────────────────────────────────────────────────── |
| 169 | + - name: Run provisioning Knative E2E tests |
| 170 | + env: |
| 171 | + K8S_API_URL: http://localhost:8001 |
| 172 | + KOURIER_URL: http://localhost:8090 |
| 173 | + PGHOST: localhost |
| 174 | + PGPORT: "5432" |
| 175 | + PGUSER: postgres |
| 176 | + PGPASSWORD: postgres |
| 177 | + PGDATABASE: provisioning_e2e |
| 178 | + run: | |
| 179 | + pnpm jest \ |
| 180 | + tests/e2e/__tests__/provisioning-knative-e2e.test.ts \ |
| 181 | + --no-coverage \ |
| 182 | + --testTimeout=360000 |
| 183 | +
|
| 184 | + # ── Diagnostics on failure ───────────────────────────────────────── |
| 185 | + - name: Dump diagnostics on failure |
| 186 | + if: failure() |
| 187 | + run: | |
| 188 | + echo "=== Namespaces ===" |
| 189 | + kubectl get ns || true |
| 190 | +
|
| 191 | + echo "" |
| 192 | + echo "=== Knative Services (all namespaces) ===" |
| 193 | + kubectl get ksvc -A || true |
| 194 | +
|
| 195 | + echo "" |
| 196 | + echo "=== Pods in test-ns ===" |
| 197 | + kubectl get pods -n test-ns -o wide || true |
| 198 | +
|
| 199 | + echo "" |
| 200 | + echo "=== Describe ksvc in test-ns ===" |
| 201 | + kubectl describe ksvc -n test-ns || true |
| 202 | +
|
| 203 | + echo "" |
| 204 | + echo "=== Events in test-ns ===" |
| 205 | + kubectl get events -n test-ns --sort-by='.lastTimestamp' || true |
| 206 | +
|
| 207 | + echo "" |
| 208 | + echo "=== Knative Serving pods ===" |
| 209 | + kubectl get pods -n knative-serving -o wide || true |
| 210 | +
|
| 211 | + echo "" |
| 212 | + echo "=== Kourier pods ===" |
| 213 | + kubectl get pods -n kourier-system -o wide || true |
| 214 | +
|
| 215 | + echo "" |
| 216 | + echo "=== Pod logs in test-ns ===" |
| 217 | + for pod in $(kubectl get pods -n test-ns -o jsonpath='{.items[*].metadata.name}' 2>/dev/null); do |
| 218 | + echo "--- $pod ---" |
| 219 | + kubectl logs -n test-ns "$pod" --all-containers --tail=100 || true |
| 220 | + done |
| 221 | +
|
| 222 | + echo "" |
| 223 | + echo "=== Secrets in test-ns ===" |
| 224 | + kubectl get secrets -n test-ns || true |
| 225 | +
|
| 226 | + echo "" |
| 227 | + echo "=== DB function definitions ===" |
| 228 | + PGHOST=localhost PGPORT=5432 PGUSER=postgres PGPASSWORD=postgres PGDATABASE=provisioning_e2e \ |
| 229 | + psql -c "SELECT id, name, service_url, image FROM constructive_compute_public.platform_function_definitions;" || true |
0 commit comments