Repository navigation
344 lines (326 loc) · 15.4 KB
/
Copy pathgo-cli.yml
File metadata and controls
344 lines (326 loc) · 15.4 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
name: Go CLI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch: {}
schedule:
# Daily 06:00 UTC: the full runtime parity matrix + publish parity. On
# push/PR only the cases affected by the change run (see parity-runtime).
- cron: "0 6 * * *"
# Least privilege for every job in this workflow: the jobs only check out the repo.
# A job that needs more must widen it
# for itself. Without this default, GITHUB_TOKEN falls back to the repository's
# (possibly write) default — see the CodeQL "workflow does not contain permissions"
# rule, which TestWorkflowsDeclarePermissions pins.
permissions:
contents: read
# A newer push to a branch makes the run before it moot, so that run is cancelled; never on main,
# whose every commit needs its answer. 3 of 11 push runs (2026-10-23..25) ran for a commit a newer
# push had replaced.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' }}
# The jobs that build and run containers land on spin-stack's docker8 fleet (spin-stack/ci: an
# ephemeral 8-vCPU EC2 instance per job, no nested virtualization). On GitHub's 4-vCPU runners a
# runtime parity shard took 10.7 min at p50 and 14.4 at p90, against 5.0 on Blacksmith's. A pull
# request from a fork runs on GitHub's runners instead: its code never reaches spin-stack's AWS
# account. Only a branch of this repository, which takes write access to push, runs on the fleet.
jobs:
# What a pull request changed, broken one small edit at a time (go-tools mutate): an
# edit no test refuses fails, so new code arrives with tests that hold it.
mutate:
if: github.event_name == 'pull_request'
runs-on: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'runs-on/fleet=docker8/env=production' || 'ubuntu-latest' }}
# 4 min on GitHub's runners for a diff's 200 mutations; a large diff's builds are many.
timeout-minutes: 30
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
- name: What this change broke, and whether a test noticed
env:
BASE: origin/${{ github.base_ref }}
run: go tool task mutate
lint-and-test:
runs-on: ubuntu-latest
# p90 3.2 min on GitHub's runners.
timeout-minutes: 15
permissions:
contents: read
outputs:
# Where the jobs that build and run containers land (see the top of this file).
fleet: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'runs-on/fleet=docker8/env=production' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
- run: go tool task lint
- run: go tool task spec:compliance
- run: go tool task vuln
- run: go tool task test:race
- run: go tool task coverage
- name: Coverage summary
if: always()
run: go tool task coverage:summary SRC=coverage.out TITLE="unit (hermetic)"
- run: go tool task test:integration
- run: go tool task build
- run: go tool task build:smoke
# Binary covdata for the cross-lane merge (coverage-report job).
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: always()
with:
name: covdata-unit
path: artifacts/coverage/data/unit
if-no-files-found: error
e2e:
runs-on: ${{ needs.lint-and-test.outputs.fleet }}
# p90 1.6 min on GitHub's runners.
timeout-minutes: 15
needs: lint-and-test
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
- run: go tool task coverage:e2e
- name: Coverage summary
if: always()
run: go tool task coverage:summary SRC=artifacts/coverage/data/e2e TITLE=e2e
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: always()
with:
name: covdata-e2e
path: artifacts/coverage/data/e2e
if-no-files-found: error
- if: always()
run: go tool task clean
# Hermetic parity gate: read-configuration golden comparison + the contract
# lane of the parity matrix (flag validation / output contract, no Docker).
parity:
# The contract and network lanes start no container: GitHub's runner is enough.
runs-on: ubuntu-latest
# p90 2.0 min on GitHub's runners.
timeout-minutes: 10
needs: lint-and-test
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: recursive
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
# pnpm installs the reference, through the firewall (task reference); pnpm 11 needs Node 22.13+.
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
with:
version: 11.27.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: "24"
- run: go tool task reference
- run: go tool task parity:contract
- run: go tool task parity:network
# Coverage is measured separately with an instrumented Go binary. Keep the
# functional parity run above release-like, and avoid conflating subprocess
# coverage with the hermetic unit profile.
- run: go tool task coverage:parity-contract
- name: Coverage summary
if: always()
run: go tool task coverage:summary SRC=artifacts/coverage/data/contract TITLE=parity:contract
- if: always()
run: go tool task reference:commit
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: always()
with:
name: parity-contract-network-v0.89.0
path: artifacts/
if-no-files-found: error
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: always()
with:
name: covdata-contract
path: artifacts/coverage/data/contract
if-no-files-found: error
# "Did the repo change today?" gate for the expensive daily lanes. Manual dispatch
# always runs; a scheduled run only proceeds when HEAD has a commit within the last
# day (devtool daily-changed) — on a private/billed repo this skips the daily matrix
# on quiet days. Runs on schedule/dispatch so the daily lanes' `needs:` is satisfied.
daily-changes:
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
- id: check
run: go tool task ci:daily-changes
# Single sharded runtime parity matrix, parameterized by event:
# push/PR — SCOPED to the commands the diff can affect (devtool parity-affected),
# run with the plain binary: a fast gate (the full matrix is ~45 min).
# daily — the FULL matrix with the instrumented binary, so one run gates parity
# AND measures coverage; daily-changes keeps it off on quiet days.
# 2 shards across independent runners (each its own docker daemon) so the matrix
# never contends for one runner's CPU/disk/daemon. PARITY_SHARD_TOTAL MUST equal the
# length of matrix.shard — parity_sharding_workflow_test.go enforces it so a mismatch
# can't silently drop cases.
parity-runtime:
needs: [lint-and-test, daily-changes]
# Every push/PR, and on schedule/dispatch only when the repo changed. always() so a
# skipped daily-changes (push/PR) doesn't skip this job; the explicit lint-and-test
# check restores the normal "needs succeeded" gate.
if: >-
always()
&& needs.lint-and-test.result == 'success'
&& (github.event_name == 'push' || github.event_name == 'pull_request'
|| needs.daily-changes.outputs.run == 'true')
runs-on: ${{ needs.lint-and-test.outputs.fleet }}
# A shard took 14.4 min at p90 as one of four on GitHub's runners; one of two on them (a
# fork's pull request) takes about twice that.
timeout-minutes: 45
strategy:
# On a push or a pull request the first failing shard stops the other: what it would have
# found is in the next push's run. The daily run keeps going, since it also measures
# coverage.
fail-fast: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
matrix:
shard: [0, 1]
env:
PARITY_RUNTIME_TIMEOUT: "10m"
# Each shard owns half of the selected cases. -parallel 2 was the proven load on a
# 4-vCPU runner (per-case id-label / COMPOSE_PROJECT_NAME isolation); docker8's 8 vCPU
# hold twice that.
PARITY_PARALLEL: ${{ needs.lint-and-test.outputs.fleet == 'ubuntu-latest' && '2' || '4' }}
PARITY_SHARD_INDEX: ${{ matrix.shard }}
PARITY_SHARD_TOTAL: "2"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: recursive
# Full history so the push/PR diff base is present for the affected mapping.
fetch-depth: 0
# devtool (the affected mapping) runs before the composite setup, so Go here.
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
- name: Plan this run
id: plan
# A pull request's diff is its base..head; a push's, what it moved the branch from..to.
env:
DIFF_BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
DIFF_HEAD: ${{ github.event.pull_request.head.sha || github.sha }}
run: go tool task parity:plan
- if: steps.plan.outputs.run == 'true'
uses: ./.github/actions/setup-parity-runtime
# push/PR: scoped, plain binary — a fast gate.
- name: Run parity (scoped, plain)
if: steps.plan.outputs.run == 'true' && (github.event_name == 'push' || github.event_name == 'pull_request')
env:
PARITY_COMMAND: ${{ steps.plan.outputs.commands }}
run: go tool task parity:runtime
# daily: full matrix, instrumented binary — gates parity AND measures coverage.
- name: Run parity (full, instrumented)
if: steps.plan.outputs.run == 'true' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
run: go tool task coverage:parity-runtime
- name: Coverage summary
if: always() && steps.plan.outputs.run == 'true' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
run: go tool task coverage:summary SRC=artifacts/coverage/data/runtime TITLE="parity:runtime shard $PARITY_SHARD_INDEX"
- if: always() && steps.plan.outputs.run == 'true'
run: go tool task reference:commit
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: always() && steps.plan.outputs.run == 'true'
with:
name: parity-runtime-v0.89.0-shard-${{ matrix.shard }}
path: artifacts/
if-no-files-found: error
# daily only: covdata slice for the cross-lane merge (distinct name per shard).
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: always() && steps.plan.outputs.run == 'true' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
with:
name: covdata-runtime-shard-${{ matrix.shard }}
path: artifacts/coverage/data/runtime
if-no-files-found: error
- if: always() && steps.plan.outputs.run == 'true'
run: go tool task clean
# Publish parity (features/templates → ephemeral OCI registry). Daily only, its own
# job so it doesn't steal a runtime shard's runner.
parity-publish-full:
needs: [lint-and-test, daily-changes]
if: needs.daily-changes.outputs.run == 'true'
# Daily and dispatched only: this repository's own code.
runs-on: runs-on/fleet=docker8/env=production
# p90 3.3 min on GitHub's runners.
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
submodules: recursive
- uses: ./.github/actions/setup-parity-runtime
- run: go tool task coverage:parity-publish
- name: Coverage summary
if: always()
run: go tool task coverage:summary SRC=artifacts/coverage/data/publish TITLE=parity:publish
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: always()
with:
name: covdata-publish
path: artifacts/coverage/data/publish
if-no-files-found: error
- if: always()
run: go tool task clean
# Single gate + cross-lane coverage for ALL events (absorbs the old push/PR
# parity-runtime aggregator, the daily report, and the per-PR coverage-report):
# gates the runtime matrix (and, on daily, publish) into one pass/fail, and merges
# every lane's covdata (unit + e2e + contract, plus the daily runtime shards +
# publish) into the one true cross-lane number.
parity-runtime-gate:
if: always()
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [lint-and-test, e2e, parity, parity-runtime, parity-publish-full]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
- name: Download all lane covdata
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
pattern: covdata-*
path: artifacts/coverage/data
- name: Normalize lane dirs
run: go tool task coverage:unpack
- name: Merged coverage report
run: go tool task coverage:merge
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: covdata-merged
path: artifacts/coverage/data/merged.out
if-no-files-found: warn
# Final verdict last, so coverage is posted even when a shard failed. A skipped
# lane (publish on push/PR, or the whole matrix on a quiet daily) counts as pass.
- name: Gate on runtime + publish
env:
RUNTIME_RESULT: ${{ needs.parity-runtime.result }}
PUBLISH_RESULT: ${{ needs.parity-publish-full.result }}
run: go tool task parity:gate
cross-compile:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: lint-and-test
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
- run: go tool task build:cross