-
Notifications
You must be signed in to change notification settings - Fork 1
260 lines (223 loc) · 7.79 KB
/
Copy pathrelease.yml
File metadata and controls
260 lines (223 loc) · 7.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Release
"on":
push:
tags:
- "v*"
workflow_dispatch:
inputs:
release_tag:
description: "Release tag to publish, for example v0.1.0"
required: true
type: string
permissions:
contents: write
packages: write
attestations: write
artifact-metadata: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.release_tag || github.ref_name || github.run_id }}
cancel-in-progress: false
jobs:
metadata:
name: Metadata
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.vars.outputs.release_tag }}
checkout_ref: ${{ steps.vars.outputs.checkout_ref }}
control_image: ${{ steps.vars.outputs.control_image }}
control_image_name: ${{ steps.vars.outputs.control_image_name }}
steps:
- name: Compute release metadata
id: vars
run: |
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
release_tag="${{ github.event.inputs.release_tag }}"
else
release_tag="${GITHUB_REF_NAME}"
fi
if [[ -z "${release_tag}" ]]; then
echo "release tag is required" >&2
exit 1
fi
owner_lc="${GITHUB_REPOSITORY_OWNER,,}"
checkout_ref="refs/tags/${release_tag}"
control_image_name="ghcr.io/${owner_lc}/nantian-controlplane"
control_image="${control_image_name}:${release_tag}"
{
echo "release_tag=${release_tag}"
echo "checkout_ref=${checkout_ref}"
echo "control_image=${control_image}"
echo "control_image_name=${control_image_name}"
} >>"${GITHUB_OUTPUT}"
security-scans:
name: Security Scans
needs: metadata
permissions:
contents: read
security-events: read
uses: ./.github/workflows/security-scans.yml
with:
checkout_ref: ${{ needs.metadata.outputs.checkout_ref }}
controlplane:
name: Controlplane Tests
runs-on: ubuntu-latest
needs: metadata
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.metadata.outputs.checkout_ref }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Run Go unit tests
run: go test -count=1 -timeout 5m ./...
kind-smoke:
name: Kind Validation
runs-on: ubuntu-latest
needs:
- metadata
- controlplane
timeout-minutes: 90
env:
CLUSTER_NAME: release-validation
GATEWAY_API_VERSION: v1.5.1
CONTROLPLANE_IMAGE: ${{ needs.metadata.outputs.control_image }}
DATAPLANE_IMAGE: ghcr.io/nantian-gw/dataplane:latest
DASHBOARD_IMAGE: ghcr.io/nantian-gw/dashboard:latest
CONFORMANCE_EXPERIMENTAL: "true"
ALL_FEATURES: "true"
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.metadata.outputs.checkout_ref }}
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Install Kind tooling
run: scripts/ci/install-kind-tools.sh
- name: Create kind cluster
run: scripts/ci/create-kind-cluster.sh
- name: Install Gateway API CRDs
run: scripts/ci/install-gateway-api-crds.sh
- name: Build current control-plane image
run: scripts/ci/build-controlplane-image.sh
- name: Load images into kind
run: scripts/ci/load-kind-images.sh
- name: Deploy Nantian Gateway
run: scripts/ci/deploy-kind-conformance.sh
- name: Record image versions
run: |
echo "=== Images under test ==="
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .spec.containers[] | " \(.name): \(.image)"'
echo "=== Image digests ==="
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .status.containerStatuses[] | " \(.name): \(.imageID)"'
- name: Run smoke test
run: CLUSTER_NAME="$CLUSTER_NAME" ./test/e2e/smoke/run.sh --no-cleanup
- name: Run full Gateway API conformance
id: conformance
env:
RELEASE_TAG: ${{ needs.metadata.outputs.release_tag }}
run: |
mkdir -p dist/conformance
report_path="${GITHUB_WORKSPACE}/dist/conformance/report.yaml"
set +e
go test -tags=conformance -count=1 -v -timeout 30m ./conformance/ \
-args \
-gateway-class nantian-gw \
-report-output "$report_path" \
-organization "Nantian Gateway" \
-project "Nantian Gateway" \
-url "https://github.com/nantian-gw/gateway" \
-version "${RELEASE_TAG}" \
-contact "https://github.com/nantian-gw/gateway/issues" 2>&1 \
| tee dist/conformance/run.log
status=${PIPESTATUS[0]}
echo "exit_code=${status}" >>"${GITHUB_OUTPUT}"
exit "${status}"
- name: Collect diagnostics on failure
if: failure()
run: ARTIFACT_DIR=tmp/conformance-diagnostics scripts/ci/collect-kind-diagnostics.sh
- name: Upload conformance artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: conformance-${{ needs.metadata.outputs.release_tag }}
path: |
dist/conformance/
tmp/conformance-diagnostics/
if-no-files-found: warn
- name: Cleanup
if: always()
run: command -v kind >/dev/null 2>&1 && kind delete cluster --name "$CLUSTER_NAME" || true
publish:
name: Publish Release Images
runs-on: ubuntu-latest
needs:
- metadata
- controlplane
- kind-smoke
timeout-minutes: 45
outputs:
control_digest: ${{ steps.build-controlplane.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.metadata.outputs.checkout_ref }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push controlplane image
id: build-controlplane
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile
push: true
tags: ${{ needs.metadata.outputs.control_image }}
- name: Prepare image metadata directory
run: mkdir -p dist/image-metadata
- name: Generate image provenance
env:
RELEASE_TAG: ${{ needs.metadata.outputs.release_tag }}
CONTROL_DIGEST: ${{ steps.build-controlplane.outputs.digest }}
CONTROL_IMAGE: ${{ needs.metadata.outputs.control_image }}
TIMESTAMP: ${{ github.event.repository.updated_at }}
run: |
cat > dist/image-metadata/provenance.json <<HEREDOC
{
"release": "${RELEASE_TAG}",
"ci_run": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"controlplane": {
"image": "${CONTROL_IMAGE}",
"digest": "${CONTROL_DIGEST}"
},
"timestamp": "${TIMESTAMP}"
}
HEREDOC
- name: Upload image metadata artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: image-metadata-${{ needs.metadata.outputs.release_tag }}
path: dist/image-metadata/
if-no-files-found: warn