Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
325 lines (252 loc) · 15.2 KB
/
Copy pathMakefile
File metadata and controls
325 lines (252 loc) · 15.2 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
.PHONY: test-testing-tailnet test test-flake-autopilot test-ghcr-tag-guard test-release-on-merge test-retry-approved-pr-ci test-secret-broker-request test-secret-broker-response test-semver-validation test-setup-semstat test-linear-pr-commenter test-link-backport-prs test-fork-review-check test-select-backport-source-prs test-release-notification test-linear-release-sync test-linear-cve-summary test-delete-previous-head-image test-aws-test-infra test-cleanup-head-charts test-advance-action-tags test-ci-test-notify test-auto-approve-bot-prs test-ai-pr-review test-ai-step test-release-summary test-release-notes test-publish-helm-chart test-govulncheck test-cognitive-complexity test-go-licenses test-run-ginkgo test-sticky-pr-comment test-s3-artifact-upload test-repository-dispatch test-parse-label-filter test-release-branch-freeze test-prerelease-setup test-vcluster-release test-platform-release test-release-lib test-subtree-mirror test-oss-commit-sync test-oss-mirror-staleness test-backport-legacy-allowlist test-backport-legacy-split test-backport-fix-imports test-promote-release test-wait-for-release test-cve-scan test-commitlint test-resolve-github-release test-comment-triggered-check test-conflict-check build-linear-release-sync lint check-bats-jobs check-edit-last install-auto-doc generate-docs check-docs help
ACTIONS_DIR := .github/actions
.PHONY: test-check-action-pins
.PHONY: test-resolve-pr-event
.PHONY: test-qa-review-gate
.PHONY: test-ui-verifier-image
WORKFLOWS_DIR := .github/workflows
SCRIPTS_DIR := .github/scripts
# --- auto-doc -----------------------------------------------------------
AUTO_DOC_VERSION := 3.6.0
# Detect OS and arch for binary download
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_S),Darwin)
AUTO_DOC_OS := Darwin
else
AUTO_DOC_OS := Linux
endif
ifeq ($(UNAME_M),arm64)
AUTO_DOC_ARCH := arm64
else ifeq ($(UNAME_M),aarch64)
AUTO_DOC_ARCH := arm64
else
AUTO_DOC_ARCH := x86_64
endif
AUTO_DOC_BIN := .bin/auto-doc
$(AUTO_DOC_BIN):
@mkdir -p .bin
curl -sSfL "https://github.com/tj-actions/auto-doc/releases/download/v$(AUTO_DOC_VERSION)/auto-doc_$(AUTO_DOC_VERSION)_$(AUTO_DOC_OS)_$(AUTO_DOC_ARCH).tar.gz" \
| tar xz -C .bin auto-doc
install-auto-doc: $(AUTO_DOC_BIN) ## install auto-doc CLI
generate-docs: $(AUTO_DOC_BIN) ## regenerate docs from action.yml / workflow YAML
@# Composite actions
@for action_yml in $(ACTIONS_DIR)/*/action.yml; do \
dir=$$(dirname "$$action_yml"); \
readme="$$dir/README.md"; \
if [ -f "$$readme" ]; then \
$(AUTO_DOC_BIN) -f "$$action_yml" -o "$$readme" && \
echo " updated $$readme"; \
fi; \
done
@# Reusable workflows
@for doc in docs/workflows/*.md; do \
name=$$(basename "$$doc" .md); \
wf="$(WORKFLOWS_DIR)/$$name.yaml"; \
if [ -f "$$wf" ]; then \
$(AUTO_DOC_BIN) -f "$$wf" -r -o "$$doc" && \
echo " updated $$doc"; \
fi; \
done
check-docs: generate-docs ## verify docs are up to date (fails if drift detected)
@# Check that every action has a README with auto-doc markers
@fail=0; \
for action_yml in $(ACTIONS_DIR)/*/action.yml; do \
dir=$$(dirname "$$action_yml"); \
name=$$(basename "$$dir"); \
readme="$$dir/README.md"; \
if [ ! -f "$$readme" ]; then \
echo "ERROR: $$dir has action.yml but no README.md"; \
fail=1; \
elif ! grep -q 'AUTO-DOC-INPUT:START' "$$readme"; then \
echo "ERROR: $$readme is missing AUTO-DOC-INPUT markers"; \
fail=1; \
fi; \
done; \
for wf in $(WORKFLOWS_DIR)/*.yaml; do \
if grep -q 'workflow_call' "$$wf"; then \
name=$$(basename "$$wf" .yaml); \
doc="docs/workflows/$$name.md"; \
if [ ! -f "$$doc" ]; then \
echo "ERROR: reusable workflow $$wf has no doc at $$doc"; \
fail=1; \
fi; \
fi; \
done; \
if [ "$$fail" -eq 1 ]; then exit 1; fi
@# Check that generated content matches committed content
@if ! git diff --quiet -- '*.md'; then \
echo ""; \
echo "ERROR: Generated docs are out of date. Run 'make generate-docs' and commit the changes."; \
echo ""; \
git diff --stat -- '*.md'; \
echo ""; \
git diff -- '*.md'; \
exit 1; \
fi
@echo "Docs are up to date."
help: ## show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-30s %s\n", $$1, $$2}'
test: test-ui-verifier-image test-testing-tailnet test-ghcr-tag-guard test-release-on-merge test-retry-approved-pr-ci test-secret-broker-request test-secret-broker-response test-semver-validation test-setup-semstat test-linear-pr-commenter test-link-backport-prs test-fork-review-check test-select-backport-source-prs test-release-notification test-linear-release-sync test-linear-cve-summary test-delete-previous-head-image test-aws-test-infra test-cleanup-head-charts test-advance-action-tags test-auto-approve-bot-prs test-ai-pr-review test-ai-step test-release-summary test-release-notes test-ci-test-notify test-go-licenses test-publish-helm-chart test-govulncheck test-cognitive-complexity test-run-ginkgo test-sticky-pr-comment test-s3-artifact-upload test-repository-dispatch test-parse-label-filter test-release-branch-freeze test-prerelease-setup test-vcluster-release test-platform-release test-release-lib test-subtree-mirror test-oss-commit-sync test-oss-mirror-staleness test-backport-legacy-allowlist test-backport-legacy-split test-backport-fix-imports test-promote-release test-wait-for-release test-cve-scan test-commitlint test-resolve-github-release test-comment-triggered-check test-conflict-check ## run all action tests
test-retry-approved-pr-ci: ## run approved PR CI retry pytest tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/retry-approved-pr-ci/test/ -q
test: test-check-action-pins
test: test-flake-autopilot
test: test-resolve-pr-event
test-resolve-pr-event: ## run pull request event handoff tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/resolve-pr-event/test/ -q
test-ghcr-tag-guard: ## run GHCR publication guard tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/ghcr-tag-guard/test/ -q
test-qa-review-gate: ## run qa-review-gate pytest tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/qa-review-gate/test/ -q
test-check-action-pins: ## run action-pin unit tests and offline zizmor integration tests
uv run --with pytest==8.3.3 --with zizmor==1.30.1 pytest $(ACTIONS_DIR)/check-action-pins/test/ -q
test-secret-broker-request: ## run secret-broker-request pytest tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/secret-broker-request/test/ -q
test-secret-broker-response: ## run secret-broker-response pytest tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/secret-broker-response/test/ -q
test-release-on-merge: ## run release-on-merge pytest tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/release-on-merge/test -q
test-semver-validation: ## run semver-validation bats tests
bats $(ACTIONS_DIR)/semver-validation/test/*.bats
test-setup-semstat: ## run setup-semstat bats tests
bats $(ACTIONS_DIR)/setup-semstat/test/*.bats
test-linear-pr-commenter: ## run linear-pr-commenter unit tests
cd $(ACTIONS_DIR)/linear-pr-commenter/src && go test -v ./...
test-link-backport-prs: ## run link-backport-prs unit tests
cd $(ACTIONS_DIR)/link-backport-prs/src && go test -v ./...
test-fork-review-check: ## run fork-review-check unit tests
cd $(ACTIONS_DIR)/fork-review-check/src && go test -v ./...
bats $(ACTIONS_DIR)/fork-review-check/test/*.bats
test-select-backport-source-prs: ## run select-backport-source-prs bats tests
bats $(ACTIONS_DIR)/select-backport-source-prs/test/*.bats
test-release-notification: ## run release-notification pytest + bats tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/release-notification/test/ -q
bats $(ACTIONS_DIR)/release-notification/test/*.bats
test-linear-release-sync: ## run linear-release-sync unit tests
cd $(ACTIONS_DIR)/linear-release-sync/src && go test -v ./...
test-linear-cve-summary: ## run linear-cve-summary unit tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/linear-cve-summary/test/ -q
test-delete-previous-head-image: ## run delete-previous-head-image unit tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/delete-previous-head-image/test/ -q
test-testing-tailnet: ## run testing-tailnet unit tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/testing-tailnet/test/ -q
test-aws-test-infra: ## run aws-test-infra unit tests
cd $(ACTIONS_DIR)/aws-test-infra/src && go test -v -race -count=1 ./...
bats $(ACTIONS_DIR)/aws-test-infra/test
test-cleanup-head-charts: ## run cleanup-head-charts bats tests
bats $(SCRIPTS_DIR)/cleanup-head-charts/test/cleanup-head-charts.bats
test-advance-action-tags: ## run action tag advancement bats tests
bats $(SCRIPTS_DIR)/advance-action-tags/test/*.bats
test-auto-approve-bot-prs: ## run auto-approve-bot-prs bats tests
bats $(ACTIONS_DIR)/auto-approve-bot-prs/test/*.bats
python3 -m unittest discover -s $(ACTIONS_DIR)/auto-approve-bot-prs/test -p 'test_*.py'
test-ai-pr-review: ## run ai-pr-review bats tests
bats $(ACTIONS_DIR)/ai-pr-review/test/*.bats
test-ai-step: ## run ai-step bats + python tests (python needs: pip install pytest jsonschema)
bats $(ACTIONS_DIR)/ai-step/test/*.bats
python3 -m pytest $(ACTIONS_DIR)/ai-step/test/ -q
test-flake-autopilot: ## run flake-autopilot bats + python tests (python needs: pip install pytest)
bats $(ACTIONS_DIR)/flake-autopilot/test/*.bats
python3 -m pytest $(ACTIONS_DIR)/flake-autopilot/test/ -q
test-release-summary: ## run release-summary pytest + bats tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/release-summary/test/ -q
bats $(ACTIONS_DIR)/release-summary/test/*.bats
test-release-notes: ## run release-notes pytest tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/release-notes/test/ -q
test-ci-test-notify: ## run ci-test-notify bats tests
bats $(ACTIONS_DIR)/ci-test-notify/test
test-publish-helm-chart: ## run publish-helm-chart bats tests (requires mikefarah/yq on PATH)
bats $(ACTIONS_DIR)/publish-helm-chart/test/run.bats
test-govulncheck: ## run govulncheck bats tests
bats $(ACTIONS_DIR)/govulncheck/test/*.bats
test-cognitive-complexity: ## run cognitive-complexity bats tests
bats $(ACTIONS_DIR)/cognitive-complexity/test/*.bats
test-cve-scan: ## run cve-scan bats tests
bats $(ACTIONS_DIR)/cve-scan/test/*.bats
test-go-licenses: ## run go-licenses bats tests
bats $(ACTIONS_DIR)/go-licenses/test/*.bats
test-run-ginkgo: ## run run-ginkgo bats and focus selection tests
bats $(ACTIONS_DIR)/run-ginkgo/test/*.bats
cd $(ACTIONS_DIR)/run-ginkgo/test/focus && go test -count=1 ./...
test-sticky-pr-comment: ## run sticky-pr-comment bats tests
bats $(ACTIONS_DIR)/sticky-pr-comment/test/*.bats
test-s3-artifact-upload: ## run s3-artifact-upload bats tests
bats $(ACTIONS_DIR)/s3-artifact-upload/test/*.bats
test-repository-dispatch: ## run repository-dispatch bats tests
bats $(ACTIONS_DIR)/repository-dispatch/test/*.bats
test-parse-label-filter: ## run parse-label-filter bats tests
bats $(ACTIONS_DIR)/parse-label-filter/test
test-comment-triggered-check: ## run comment-triggered-check bats tests
bats $(ACTIONS_DIR)/comment-triggered-check/test
test-conflict-check: ## run conflict-check bats tests
bats $(ACTIONS_DIR)/conflict-check/test/*.bats
test-release-branch-freeze: ## run release-branch-freeze bats tests
bats $(ACTIONS_DIR)/release-branch-freeze/test
test-prerelease-setup: ## run prerelease-setup bats tests
bats $(ACTIONS_DIR)/prerelease-setup/test
test-vcluster-release: ## run vcluster-release bats tests (requires mikefarah/yq on PATH)
bats $(ACTIONS_DIR)/vcluster-release/test/*.bats
test-platform-release: ## run platform-release bats tests (requires mikefarah/yq on PATH)
bats $(ACTIONS_DIR)/platform-release/test/*.bats
test-release-lib: ## run release-lib bats and pytest tests (shared by the release actions)
bats $(ACTIONS_DIR)/release-lib/test/*.bats
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/release-lib/test/ -q
test-promote-release: ## run promote-release bats tests
bats $(ACTIONS_DIR)/promote-release/test/*.bats
test-subtree-mirror: ## run subtree-mirror bats tests
bats $(ACTIONS_DIR)/subtree-mirror/test/run.bats
test-oss-commit-sync: ## run oss-commit-sync bats tests
bats $(ACTIONS_DIR)/oss-commit-sync/test/*.bats
test-oss-mirror-staleness: ## run oss-mirror-staleness bats tests
bats $(ACTIONS_DIR)/oss-mirror-staleness/test/*.bats
test-backport-legacy-allowlist: ## run backport-legacy-allowlist bats tests
bats $(ACTIONS_DIR)/backport-legacy-allowlist/test/run.bats
test-backport-legacy-split: ## run backport-legacy-split bats tests
bats $(ACTIONS_DIR)/backport-legacy-split/test/run.bats
test-backport-fix-imports: ## run backport-fix-imports pytest tests
uv run --with pytest==8.3.3 pytest $(ACTIONS_DIR)/backport-fix-imports/test/ -q
test-wait-for-release: ## run wait-for-release bats tests
bats $(ACTIONS_DIR)/wait-for-release/test/*.bats
test-commitlint: ## run commitlint bats tests
bats $(ACTIONS_DIR)/commitlint/test/*.bats
test-resolve-github-release: ## run resolve-github-release bats tests
bats $(ACTIONS_DIR)/resolve-github-release/test/*.bats
build-linear-release-sync: ## build linear-release-sync binary (linux/amd64)
cd $(ACTIONS_DIR)/linear-release-sync/src && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o ../linear-release-sync-linux-amd64 .
lint: check-bats-jobs check-edit-last ## run actionlint and zizmor on workflows
actionlint .github/workflows/*.yaml
zizmor .github/
# `gh pr comment --edit-last` edits whatever comment the token's user posted
# last, so on a PR where two automations share a bot account one overwrites the
# other (conflict-check wiped backport-fix-imports' comment, DEVOPS-1739).
check-edit-last: ## fail if a workflow or action edits the last PR comment blindly
@if grep -rn -e '--edit-last' $(WORKFLOWS_DIR) $(ACTIONS_DIR) --include='*.yaml' --include='*.yml' --include='*.sh' --include='*.py'; then \
echo "ERROR: --edit-last can overwrite another automation's comment; use the sticky-pr-comment action with a marker."; \
exit 1; \
fi
# bats-action only installs bats; it has no `tests` input. Unknown inputs are a
# warning, so a job that hands it a path and stops there goes green having run
# nothing, which is how 23 suites stayed dead without anyone noticing.
check-bats-jobs: ## fail if a workflow installs bats but never runs a suite
@fail=0; \
for wf in $(WORKFLOWS_DIR)/*.yaml; do \
grep -q 'bats-core/bats-action' "$$wf" || continue; \
if awk '/bats-core\/bats-action/{w=1;next} \
w && /^[[:space:]]*tests:/{found=1;exit} \
w && /^[[:space:]]*- /{w=0} \
END{exit !found}' "$$wf"; then \
echo "ERROR: $$wf passes a 'tests' input to bats-action, which has no such input; the suite never runs."; \
fail=1; \
fi; \
if ! grep -qE '^[[:space:]]*(run: )?bats[[:space:]]' "$$wf"; then \
echo "ERROR: $$wf installs bats but never runs it; add a 'run: bats <path>/*.bats' step."; \
fail=1; \
fi; \
done; \
if [ "$$fail" -eq 1 ]; then exit 1; fi; \
echo "Every workflow that installs bats runs a suite."
# Reusable workflow tests (test-*.yaml for workflow_call workflows) run in CI only.
# They require GitHub event context and cannot be executed locally.
test-ui-verifier-image: ## run UI verifier image bats tests
bats $(ACTIONS_DIR)/ui-verifier-image/test/*.bats