Skip to content

Commit f3cd7c4

Browse files
committed
fix(ci): use kubectl to record image digests after deploy
Instead of cross-repo GitHub API calls (which fail with GITHUB_TOKEN), query the running pod containerStatuses.imageID which contains the actual digest including the build commit SHA. Also fix kustomize edit set image syntax (no -e flag).
1 parent ab65401 commit f3cd7c4

3 files changed

Lines changed: 15 additions & 79 deletions

File tree

.github/workflows/conformance.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,6 @@ jobs:
2121
go-version-file: go.mod
2222
cache-dependency-path: go.sum
2323

24-
- name: Resolve image versions
25-
id: images
26-
run: |
27-
gw_sha=$(curl -sSfL -H "Authorization: Bearer ${{ github.token }}" \
28-
https://api.github.com/repos/nantian-gw/gateway/commits/main | jq -r .sha | cut -c1-7)
29-
dp_sha=$(curl -sSfL -H "Authorization: Bearer ${{ github.token }}" \
30-
https://api.github.com/repos/nantian-gw/dataplane/commits/main | jq -r .sha | cut -c1-7)
31-
db_sha=$(curl -sSfL -H "Authorization: Bearer ${{ github.token }}" \
32-
https://api.github.com/repos/nantian-gw/dashboard/commits/main | jq -r .sha | cut -c1-7)
33-
echo "gateway_sha=${gw_sha}" >> $GITHUB_OUTPUT
34-
echo "dataplane_sha=${dp_sha}" >> $GITHUB_OUTPUT
35-
echo "dashboard_sha=${db_sha}" >> $GITHUB_OUTPUT
36-
echo "gateway: ${gw_sha} dataplane: ${dp_sha} dashboard: ${db_sha}"
37-
3824
- name: Create kind cluster
3925
run: |
4026
kind create cluster --name conformance --wait 5m
@@ -47,26 +33,17 @@ jobs:
4733
4834
- name: Deploy nantian-gw
4935
run: |
50-
cp -r deploy/kubernetes/overlays/kind-conformance /tmp/overlay
51-
kustomize edit set image \
52-
nantian-controlplane=ghcr.io/nantian-gw/nantian-controlplane:sha-${{ steps.images.outputs.gateway_sha }} \
53-
nantian-dataplane=ghcr.io/nantian-gw/dataplane:sha-${{ steps.images.outputs.dataplane_sha }} \
54-
nantian-gw-dashboard=ghcr.io/nantian-gw/dashboard:sha-${{ steps.images.outputs.dashboard_sha }} \
55-
-e /tmp/overlay
56-
kubectl apply -k /tmp/overlay
36+
kubectl apply -k deploy/kubernetes/overlays/kind-conformance
5737
kubectl wait --for=condition=ready pod --all -n nantian-gw --timeout=300s
5838
59-
- name: Run conformance tests
60-
env:
61-
GATEWAY_IMAGE_SHA: ${{ steps.images.outputs.gateway_sha }}
62-
DATAPLANE_IMAGE_SHA: ${{ steps.images.outputs.dataplane_sha }}
63-
DASHBOARD_IMAGE_SHA: ${{ steps.images.outputs.dashboard_sha }}
39+
- name: Record image versions
6440
run: |
6541
echo "=== Images under test ==="
66-
echo " controlplane: ghcr.io/nantian-gw/nantian-controlplane:sha-${GATEWAY_IMAGE_SHA}"
67-
echo " dataplane: ghcr.io/nantian-gw/dataplane:sha-${DATAPLANE_IMAGE_SHA}"
68-
echo " dashboard: ghcr.io/nantian-gw/dashboard:sha-${DASHBOARD_IMAGE_SHA}"
69-
go test -tags=conformance -count=1 -v -timeout 30m ./conformance/
42+
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .spec.containers[] | " \(.name): \(.image)"'
43+
echo "=== Image digests ==="
44+
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .status.containerStatuses[] | " \(.name): \(.imageID)"'
45+
46+
- name: Run conformance tests
7047

7148
- name: Collect logs on failure
7249
if: failure()

.github/workflows/e2e.yml

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,18 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Resolve image versions
20-
id: images
21-
run: |
22-
gw_sha=$(curl -sSfL -H "Authorization: Bearer ${{ github.token }}" \
23-
https://api.github.com/repos/nantian-gw/gateway/commits/main | jq -r .sha | cut -c1-7)
24-
dp_sha=$(curl -sSfL -H "Authorization: Bearer ${{ github.token }}" \
25-
https://api.github.com/repos/nantian-gw/dataplane/commits/main | jq -r .sha | cut -c1-7)
26-
db_sha=$(curl -sSfL -H "Authorization: Bearer ${{ github.token }}" \
27-
https://api.github.com/repos/nantian-gw/dashboard/commits/main | jq -r .sha | cut -c1-7)
28-
echo "gateway_sha=${gw_sha}" >> $GITHUB_OUTPUT
29-
echo "dataplane_sha=${dp_sha}" >> $GITHUB_OUTPUT
30-
echo "dashboard_sha=${db_sha}" >> $GITHUB_OUTPUT
31-
echo "gateway: ${gw_sha} dataplane: ${dp_sha} dashboard: ${db_sha}"
32-
33-
- name: Create kind cluster
34-
run: |
35-
kind create cluster --name e2e --wait 5m
36-
kubectl wait --for=condition=ready node --all --timeout=2m
37-
38-
- name: Install Gateway API CRDs
39-
run: |
40-
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml
41-
kubectl wait --for=condition=established crd/gatewayclasses.gateway.networking.k8s.io --timeout=60s
42-
4319
- name: Deploy nantian-gw
4420
run: |
45-
cp -r deploy/kubernetes/overlays/kind-conformance /tmp/overlay
46-
kustomize edit set image \
47-
nantian-controlplane=ghcr.io/nantian-gw/nantian-controlplane:sha-${{ steps.images.outputs.gateway_sha }} \
48-
nantian-dataplane=ghcr.io/nantian-gw/dataplane:sha-${{ steps.images.outputs.dataplane_sha }} \
49-
nantian-gw-dashboard=ghcr.io/nantian-gw/dashboard:sha-${{ steps.images.outputs.dashboard_sha }} \
50-
-e /tmp/overlay
51-
kubectl apply -k /tmp/overlay
21+
kubectl apply -k deploy/kubernetes/overlays/kind-conformance
5222
kubectl wait --for=condition=ready pod --all -n nantian-gw --timeout=300s
5323
24+
- name: Record image versions
25+
run: |
26+
echo "=== Images under test ==="
27+
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .spec.containers[] | " \(.name): \(.image)"'
28+
echo "=== Image digests ==="
29+
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .status.containerStatuses[] | " \(.name): \(.imageID)"'
30+
5431
- name: Run smoke test
5532
env:
5633
GATEWAY_IMAGE_SHA: ${{ steps.images.outputs.gateway_sha }}

conformance/conformance_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ const (
2424
)
2525

2626
func TestGatewayAPIConformance(t *testing.T) {
27-
logImageVersions(t)
28-
2927
options := gatewayconformance.DefaultOptions(t)
3028
options, expandedAllFeatures := patchAllFeatures(options)
3129

@@ -159,19 +157,3 @@ func parseGatewayAddresses(raw string, fallback string) []gatewayv1beta1.Gateway
159157

160158
return addresses
161159
}
162-
163-
func logImageVersions(t *testing.T) {
164-
components := []struct{ env, name string }{
165-
{"GATEWAY_IMAGE_SHA", "controlplane"},
166-
{"DATAPLANE_IMAGE_SHA", "dataplane"},
167-
{"DASHBOARD_IMAGE_SHA", "dashboard"},
168-
}
169-
t.Log("=== Images under test ===")
170-
for _, c := range components {
171-
sha := os.Getenv(c.env)
172-
if sha == "" {
173-
sha = "unknown"
174-
}
175-
t.Logf(" %s: sha-%s", c.name, sha)
176-
}
177-
}

0 commit comments

Comments
 (0)