Skip to content

Commit 0e5ef20

Browse files
authored
Fix integration and docs-preview-cleanup CI (#52)
* ci: reach gateway via port-forward, fix kind cleanup and preview-deletion listing * ci: wait for the nebi deployment to exist before asserting on it --------- Co-authored-by: Amit Kumar <aktech@users.noreply.github.com>
1 parent fe81e52 commit 0e5ef20

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

.github/workflows/docs-preview-cleanup.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ jobs:
2222
run: |
2323
set -euo pipefail
2424
base="https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/pages/projects/${CF_PROJECT}/deployments"
25-
ids=$(curl -fsS -H "Authorization: Bearer ${CF_API_TOKEN}" "${base}?env=preview&per_page=100" \
26-
| jq -r --arg b "$BRANCH" '.result[] | select(.deployment_trigger.metadata.branch == $b) | .id')
25+
# No ?env=preview filter — the deployments list endpoint rejects it
26+
# with HTTP 400; the branch filter below already excludes production
27+
# deployments (those trigger from main).
28+
ids=$(curl -fsS -H "Authorization: Bearer ${CF_API_TOKEN}" "${base}?per_page=100" \
29+
| jq -r --arg b "$BRANCH" '.result[] | select(.deployment_trigger.metadata.branch == $b) | .id') \
30+
|| { echo "::warning::Could not list preview deployments; skipping cleanup."; exit 0; }
2731
if [ -z "$ids" ]; then
2832
echo "No preview deployments found for branch '$BRANCH'."
2933
exit 0

.github/workflows/test.yaml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ jobs:
6060

6161
- name: Verify deployment and operator-wired OIDC
6262
run: |
63+
# add-software-pack returns as soon as the Application reports
64+
# Healthy, which a freshly created app does vacuously before its
65+
# first sync creates any resources. Wait for the Deployment to
66+
# exist before asserting anything about it (rollout status with a
67+
# selector exits 0 on zero matches, so it is not a wait).
68+
for i in $(seq 1 60); do
69+
kubectl get deploy -n nebi -l app.kubernetes.io/name=nebari-nebi-pack \
70+
-o name 2>/dev/null | grep -q . && break
71+
echo "Waiting for nebi deployment to be created... (${i}/60)"
72+
sleep 5
73+
done
6374
kubectl rollout status deployment -n nebi \
6475
-l app.kubernetes.io/name=nebari-nebi-pack --timeout=180s
6576
@@ -71,18 +82,26 @@ jobs:
7182
|| { echo "OIDC env not wired"; exit 1; }
7283
7384
- name: Verify the gateway redirects nebi to Keycloak
74-
env:
75-
GATEWAY_IP: ${{ steps.sandbox.outputs.gateway-ip }}
85+
# Reach the gateway through a port-forward to Envoy's LoadBalancer
86+
# Service rather than the LB IP, which is not routable from the
87+
# runner's network namespace.
7688
run: |
89+
svc=$(kubectl get svc -n envoy-gateway-system \
90+
-o jsonpath='{.items[?(@.spec.type=="LoadBalancer")].metadata.name}')
91+
kubectl port-forward -n envoy-gateway-system "svc/${svc}" 8443:443 &
92+
pf=$!
93+
trap 'kill $pf' EXIT
94+
for i in $(seq 1 30); do
95+
curl -sk -o /dev/null --connect-timeout 2 https://127.0.0.1:8443/ && break
96+
sleep 1
97+
done
7798
loc=$(curl -sk -o /dev/null -w '%{redirect_url}' \
78-
--resolve "nebi.nebari.local:443:${GATEWAY_IP}" \
79-
https://nebi.nebari.local/)
99+
--resolve "nebi.nebari.local:8443:127.0.0.1" \
100+
https://nebi.nebari.local:8443/)
80101
echo "redirect: $loc"
81102
echo "$loc" | grep -q 'keycloak.nebari.local/realms/nebari/protocol/openid-connect/auth' \
82103
|| { echo "nebi did not redirect to Keycloak"; exit 1; }
83104
84105
- name: Cleanup
85106
if: always()
86-
run: |
87-
k3d cluster delete ${{ steps.sandbox.outputs.cluster-name }} || true
88-
docker network rm ${{ steps.sandbox.outputs.network-name }} 2>/dev/null || true
107+
run: kind delete cluster --name ${{ steps.sandbox.outputs.cluster-name }} || true

0 commit comments

Comments
 (0)