Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
292 lines (270 loc) · 16.3 KB
/
Copy pathTaskfile.yml
File metadata and controls
292 lines (270 loc) · 16.3 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
version: '3'
vars:
TOOLS_BIN: '{{.ROOT_DIR}}/.tools/bin'
# Each tool is a release archive checked against this digest: the one in the release's own
# checksums file.
TOFU_VERSION: 1.12.6
TOFU_SHA256: 5dc43da4f750f33873dc25e94587128709e819e544b7be9016b255316153c3a8
TFLINT_VERSION: 0.64.0
TFLINT_SHA256: cca9d13e2e1d7a2c627af60ff899a3c9b74212899416aeb96ec764d2ef954537
TRIVY_VERSION: 0.74.0
TRIVY_SHA256: 2ae6fe3ee734b7fdf11335663e18c75ea12dccc76062f09f164a3b0f8be4371a
TFDOCS_VERSION: 0.24.0
TFDOCS_SHA256: 9005daf969de0b50134493a2c00078b49f5f5b39d021cda7c89bf4d4f3d776d3
# The version spin's versions.yaml pins: nothing else reads a workflow before GitHub runs it.
ACTIONLINT_VERSION: 1.7.12
ACTIONLINT_SHA256: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
# The shell in hack/ and in each workflow's steps (actionlint asks it). Its release has no
# checksums file: this is the archive's digest as first downloaded.
SHELLCHECK_VERSION: 0.11.0
SHELLCHECK_SHA256: 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198
# What the fresh install fetches spin's CLI with, from the release's public package, and checks it
# by. Cosign's release is the binary itself, its digest the one in cosign_checksums.txt.
COSIGN_VERSION: 3.1.3
COSIGN_SHA256: 4629c757b7618056f8ddd7e2625ae9fdd94c0372a65049520bc7d9df9efc7f71
ORAS_VERSION: 1.3.4
ORAS_SHA256: f27adb935022d94df8dc77719c322dda592c78a0d57a6f7dcdd8d900b248c454
# The modules whose inputs and outputs terraform-docs writes into their README.
DOCUMENTED: modules/controlplane modules/runners
# spin-stack/go-tools' gates, by commit: this repository has no go.mod to pin them as tools.
GO_TOOLS_VERSION: dfcf2c10f30b2b2c65cea37558cbf12881f8fde9
# testidentity's own: the commit that has it. taskgate at that commit also reads the scripts a
# task runs, which six of hack/'s fail - work of its own before GO_TOOLS_VERSION moves there.
TESTIDENTITY_VERSION: 1c6d5ec38bf52276bef65e89d94dc1865f73924c
# D2, the version spin-stack/ami pins, and its flags there: one light theme, each diagram its own
# size. Its release's own build rather than its image: the image came from Docker Hub, which
# GitHub's runners could not reach for a token on 2026-10-09, and failed every lint with it. The
# release renders the committed SVGs byte for byte as that image did.
# docs/diagrams/icons are taken from the packages that repository pins (versions.yaml there:
# aws-architecture-icons 07312026, simple-icons 16.33.0), checked against its digests, then
# rewritten by svgo (docs/diagrams/svgo.config.mjs).
SVGO_VERSION: 4.1.0
D2_VERSION: 0.9.0
D2_SHA256: 5669ddc46b99e942cc96078f4a4e36d5e62103348f4c05179ede27802fdd87a9
D2_FLAGS: >-
--layout elk --elk-nodeNodeBetweenLayers 56 --elk-edgeNodeBetweenLayers 20
--elk-padding '[top=40,left=24,bottom=24,right=24]' --theme 0 --pad 16 --scale 1
tasks:
tools:tofu:
desc: Install the pinned OpenTofu.
status:
- test -x {{.TOOLS_BIN}}/tofu && {{.TOOLS_BIN}}/tofu version | grep -q 'v{{.TOFU_VERSION}}$'
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/tofu.zip https://github.com/opentofu/opentofu/releases/download/v{{.TOFU_VERSION}}/tofu_{{.TOFU_VERSION}}_linux_amd64.zip
- echo "{{.TOFU_SHA256}} {{.TOOLS_BIN}}/tofu.zip" | sha256sum --check --quiet
- unzip -oq {{.TOOLS_BIN}}/tofu.zip tofu -d {{.TOOLS_BIN}}
- rm {{.TOOLS_BIN}}/tofu.zip
tools:tflint:
desc: Install the pinned TFLint.
status:
- test -x {{.TOOLS_BIN}}/tflint && {{.TOOLS_BIN}}/tflint --version | grep -q 'version {{.TFLINT_VERSION}}$'
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/tflint.zip https://github.com/terraform-linters/tflint/releases/download/v{{.TFLINT_VERSION}}/tflint_linux_amd64.zip
- echo "{{.TFLINT_SHA256}} {{.TOOLS_BIN}}/tflint.zip" | sha256sum --check --quiet
- unzip -oq {{.TOOLS_BIN}}/tflint.zip tflint -d {{.TOOLS_BIN}}
- rm {{.TOOLS_BIN}}/tflint.zip
tools:trivy:
desc: Install the pinned Trivy.
status:
- "test -x {{.TOOLS_BIN}}/trivy && {{.TOOLS_BIN}}/trivy --version | grep -q 'Version: {{.TRIVY_VERSION}}$'"
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/trivy.tgz https://github.com/aquasecurity/trivy/releases/download/v{{.TRIVY_VERSION}}/trivy_{{.TRIVY_VERSION}}_Linux-64bit.tar.gz
- echo "{{.TRIVY_SHA256}} {{.TOOLS_BIN}}/trivy.tgz" | sha256sum --check --quiet
- tar -xzf {{.TOOLS_BIN}}/trivy.tgz -C {{.TOOLS_BIN}} trivy
- rm {{.TOOLS_BIN}}/trivy.tgz
tools:terraform-docs:
desc: Install the pinned terraform-docs.
status:
- test -x {{.TOOLS_BIN}}/terraform-docs && {{.TOOLS_BIN}}/terraform-docs --version | grep -q 'v{{.TFDOCS_VERSION}} '
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/terraform-docs.tgz https://github.com/terraform-docs/terraform-docs/releases/download/v{{.TFDOCS_VERSION}}/terraform-docs-v{{.TFDOCS_VERSION}}-linux-amd64.tar.gz
- echo "{{.TFDOCS_SHA256}} {{.TOOLS_BIN}}/terraform-docs.tgz" | sha256sum --check --quiet
- tar -xzf {{.TOOLS_BIN}}/terraform-docs.tgz -C {{.TOOLS_BIN}} terraform-docs
- rm {{.TOOLS_BIN}}/terraform-docs.tgz
tools:actionlint:
desc: Install the pinned actionlint.
status:
- test -x {{.TOOLS_BIN}}/actionlint && {{.TOOLS_BIN}}/actionlint -version | grep -q '^{{.ACTIONLINT_VERSION}}$'
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/actionlint.tgz https://github.com/rhysd/actionlint/releases/download/v{{.ACTIONLINT_VERSION}}/actionlint_{{.ACTIONLINT_VERSION}}_linux_amd64.tar.gz
- echo "{{.ACTIONLINT_SHA256}} {{.TOOLS_BIN}}/actionlint.tgz" | sha256sum --check --quiet
- tar -xzf {{.TOOLS_BIN}}/actionlint.tgz -C {{.TOOLS_BIN}} actionlint
- rm {{.TOOLS_BIN}}/actionlint.tgz
tools:shellcheck:
desc: Install the pinned ShellCheck.
status:
- "test -x {{.TOOLS_BIN}}/shellcheck && {{.TOOLS_BIN}}/shellcheck --version | grep -q '^version: {{.SHELLCHECK_VERSION}}$'"
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/shellcheck.txz https://github.com/koalaman/shellcheck/releases/download/v{{.SHELLCHECK_VERSION}}/shellcheck-v{{.SHELLCHECK_VERSION}}.linux.x86_64.tar.xz
- echo "{{.SHELLCHECK_SHA256}} {{.TOOLS_BIN}}/shellcheck.txz" | sha256sum --check --quiet
- tar -xJf {{.TOOLS_BIN}}/shellcheck.txz -C {{.TOOLS_BIN}} --strip-components=1 shellcheck-v{{.SHELLCHECK_VERSION}}/shellcheck
- rm {{.TOOLS_BIN}}/shellcheck.txz
tools:cosign:
desc: Install the pinned cosign.
status:
- test -x {{.TOOLS_BIN}}/cosign && {{.TOOLS_BIN}}/cosign version 2>&1 | grep -q 'GitVersion:.*v{{.COSIGN_VERSION}}$'
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/cosign.new https://github.com/sigstore/cosign/releases/download/v{{.COSIGN_VERSION}}/cosign-linux-amd64
- echo "{{.COSIGN_SHA256}} {{.TOOLS_BIN}}/cosign.new" | sha256sum --check --quiet
- chmod +x {{.TOOLS_BIN}}/cosign.new && mv {{.TOOLS_BIN}}/cosign.new {{.TOOLS_BIN}}/cosign
tools:oras:
desc: Install the pinned ORAS.
status:
- "test -x {{.TOOLS_BIN}}/oras && {{.TOOLS_BIN}}/oras version | grep -q '^Version: *{{.ORAS_VERSION}}$'"
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/oras.tgz https://github.com/oras-project/oras/releases/download/v{{.ORAS_VERSION}}/oras_{{.ORAS_VERSION}}_linux_amd64.tar.gz
- echo "{{.ORAS_SHA256}} {{.TOOLS_BIN}}/oras.tgz" | sha256sum --check --quiet
- tar -xzf {{.TOOLS_BIN}}/oras.tgz -C {{.TOOLS_BIN}} oras
- rm {{.TOOLS_BIN}}/oras.tgz
tools:d2:
desc: Install the pinned D2.
status:
- test -x {{.TOOLS_BIN}}/d2 && {{.TOOLS_BIN}}/d2 --version | grep -q '^v{{.D2_VERSION}}$'
cmds:
- mkdir -p {{.TOOLS_BIN}}
- curl -fsSLo {{.TOOLS_BIN}}/d2.tgz https://github.com/terrastruct/d2/releases/download/v{{.D2_VERSION}}/d2-v{{.D2_VERSION}}-linux-amd64.tar.gz
- echo "{{.D2_SHA256}} {{.TOOLS_BIN}}/d2.tgz" | sha256sum --check --quiet
- tar -xzf {{.TOOLS_BIN}}/d2.tgz -C {{.TOOLS_BIN}} --strip-components=2 d2-v{{.D2_VERSION}}/bin/d2
- rm {{.TOOLS_BIN}}/d2.tgz
docs:
desc: Write each module's inputs and outputs into its README.
deps: [tools:terraform-docs]
cmds:
- for: {var: DOCUMENTED, split: ' '}
cmd: "{{.TOOLS_BIN}}/terraform-docs -c .terraform-docs.yml {{.ITEM}}"
diagrams:
desc: Render docs/diagrams/*.d2 into the SVGs beside them, the icons inside each.
deps: [tools:d2]
cmds:
# D2 embeds each icon whole, base64 and once per use: as AWS and simple-icons ship them,
# they made installation.svg 145 kB. An icon svgo has already rewritten comes out the same.
- go run github.com/spin-stack/go-tools/cmd/sfw@{{.GO_TOOLS_VERSION}} pnpm dlx svgo@{{.SVGO_VERSION}} -q --config docs/diagrams/svgo.config.mjs -f docs/diagrams/icons
- >-
for d in docs/diagrams/*.d2; do case $d in */_*) continue;; esac;
{{.TOOLS_BIN}}/d2 {{.D2_FLAGS}} "$d" "${d%.d2}.svg" >/dev/null || exit 1; done
# A picture nothing in a build reads is the one that drifts unnoticed: each SVG is rendered again
# and has to be the one committed, byte for byte (D2 lays out the same source the same way).
# Under 100 kB, the size past which a crawl of docs.spinbox.dev flags an image.
diagrams:check:
desc: Fail when a committed SVG is not what its .d2 renders to, or is 100 kB or more.
deps: [tools:d2]
cmds:
- >-
tmp=$(mktemp -d); trap 'rm -rf $tmp' EXIT;
for d in docs/diagrams/*.d2; do case $d in */_*) continue;; esac;
{{.TOOLS_BIN}}/d2 {{.D2_FLAGS}} "$d" "$tmp/$(basename ${d%.d2}).svg" >/dev/null || exit 1;
cmp -s "$tmp/$(basename ${d%.d2}).svg" "${d%.d2}.svg" || { echo "${d%.d2}.svg is not what $d renders to: task diagrams"; exit 1; };
[ "$(wc -c <"${d%.d2}.svg")" -lt 100000 ] || { echo "${d%.d2}.svg is 100 kB or more"; exit 1; }; done
lint:
desc: Format-check, validate, lint and scan the modules, the examples and bootstrap, and hold each module to its tests.
deps: [tools:tofu, tools:tflint, tools:trivy, tools:terraform-docs, tools:actionlint, tools:shellcheck]
# Nothing else parses these, and nothing runs them but an apply against an account - so a
# module that stopped validating is found by the operator it was written for. The provider
# is the one each lock file pins, cached under .tools so a second run downloads nothing.
env:
TF_PLUGIN_CACHE_DIR: "{{.ROOT_DIR}}/.tools/tofu-plugins"
cmds:
- mkdir -p {{.ROOT_DIR}}/.tools/tofu-plugins
- "{{.TOOLS_BIN}}/tofu fmt -recursive -check -diff"
# The pinned shellcheck, named: given none, actionlint takes whichever is on PATH, or skips.
- "{{.TOOLS_BIN}}/actionlint -shellcheck={{.TOOLS_BIN}}/shellcheck"
# Every workflow step one task, so what CI does is what a task here does; and no package
# installed but by pnpm through Socket's firewall.
- go run github.com/spin-stack/go-tools/cmd/taskgate@{{.GO_TOOLS_VERSION}}
- go run github.com/spin-stack/go-tools/cmd/sfw@{{.GO_TOOLS_VERSION}} check
# A test that writes git's author into the checkout makes every commit after it the test's;
# this refuses those commits before they reach main.
- go run github.com/spin-stack/go-tools/cmd/testidentity@{{.TESTIDENTITY_VERSION}} -base origin/main
- "{{.TOOLS_BIN}}/shellcheck hack/*.sh"
# The one Go program here, which only the fresh install's smoke runs: a file, with no module.
- test -z "$(gofmt -l hack/enroll)" || { gofmt -l hack/enroll; echo 'gofmt -w hack/enroll'; exit 1; }
- go vet hack/enroll/main.go
- bash hack/security-group-descriptions.sh $(find modules -name '*.tf')
# The fresh install's posture filters, which only that run feeds a real account's answers.
- bash hack/posture-test.sh
- for: ['.', examples/complete, examples/minimal, bootstrap]
cmd: "{{.TOOLS_BIN}}/tofu -chdir={{.ITEM}} init -backend=false -lockfile=readonly -input=false -no-color >/dev/null && {{.TOOLS_BIN}}/tofu -chdir={{.ITEM}} validate -no-color"
# The order a destroy has to happen in, which nothing else would see before the fresh install.
- bash hack/destroy-order.sh {{.TOOLS_BIN}}/tofu .
# What validate does not know (.tflint.hcl), against one configuration for every directory:
# an absolute path, since a relative one is looked for in each directory it walks into.
- "{{.TOOLS_BIN}}/tflint --init --config={{.ROOT_DIR}}/.tflint.hcl >/dev/null"
- "{{.TOOLS_BIN}}/tflint --recursive --config={{.ROOT_DIR}}/.tflint.hcl --format compact"
# AWS's misconfigurations, each one this installation decides against ignored at its
# resource with the reason (#trivy:ignore), so a new one fails here.
- "{{.TOOLS_BIN}}/trivy config --quiet --exit-code 1 --cache-dir {{.ROOT_DIR}}/.tools/trivy-cache --skip-dirs .tools ."
- for: {var: DOCUMENTED, split: ' '}
cmd: "{{.TOOLS_BIN}}/terraform-docs -c .terraform-docs.yml --output-check {{.ITEM}} >/dev/null || { echo '{{.ITEM}}/README.md is not what its variables and outputs say: task docs'; exit 1; }"
- task: diagrams:check
# What each module promises about who reaches what - the proxy the only machine the
# internet reaches, no role able to write IAM or read another's secrets, every disk
# encrypted - asserted against its plan, with no account.
- for: [modules/controlplane, modules/runners, bootstrap]
cmd: "{{.TOOLS_BIN}}/tofu -chdir={{.ITEM}} init -backend=false -lockfile=readonly -input=false -no-color >/dev/null && {{.TOOLS_BIN}}/tofu -chdir={{.ITEM}} test -no-color"
# The fresh install's steps (.github/workflows/fresh-install.yml), each against the account the
# run assumed: run here, they need its credentials and the variables the workflow sets.
fresh-install:tools:
desc: Install what the fresh install runs, and put it on the run's PATH.
cmds:
- task: tools:tofu
- task: tools:cosign
- task: tools:oras
- echo '{{.TOOLS_BIN}}' >> "${GITHUB_PATH:-/dev/stdout}"
fresh-install:
desc: >-
Run one step of the fresh install: task fresh-install -- release|cli|cost|domain|bootstrap|installation|delegate|undelegate|wait-machines|sign-in|smoke|posture|host-check|why.
cmds:
- bash hack/fresh-install.sh {{.CLI_ARGS}}
fresh-install:remove:
desc: Remove the fresh install and its bootstrap, whatever a run left of them.
cmds:
- bash hack/fresh-install-remove.sh
fresh-install:watch:
desc: Remove what the fresh install left in the account, closing any issue once it is clean.
cmds:
- bash hack/fresh-install-watch.sh
fresh-install:watch:report:
desc: Open an issue saying the watch did not finish, with what is still in the account.
cmds:
- bash hack/fresh-install-watch.sh --report
release:
desc: >-
Cut this module's next release: GITHUB_SHA, once Gate passed on it, tagged v<YYYYMMDD>.<NN>,
the next one today, with its GitHub release in GITHUB_REPOSITORY, as GH_TOKEN
(.github/workflows/release.yml).
cmds:
- bash hack/release.sh
# spin-stack/ship-it reads this module's releases and the pull request propose.yml opens for a
# deployment. GitHub's schedule does not wake it (its */5 ran 3 of 576 in 48 h), so the run that
# cut the release or opened the pull request does. A hint: ship-it reads the state itself, and its
# hourly cron catches a wake that was lost.
ship-it:wake:
desc: Wake spin-stack/ship-it with this run and its CONCLUSION, as GH_TOKEN (the release app's on ship-it; release.yml, propose.yml).
requires:
vars: [CONCLUSION]
cmds:
- |
set -euo pipefail
workflow=${GITHUB_WORKFLOW_REF%@*}
gh api repos/spin-stack/ship-it/dispatches -f event_type=wake \
-f "client_payload[repository]=${GITHUB_REPOSITORY}" \
-f "client_payload[workflow]=${workflow##*/}" \
-f "client_payload[run]=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
-f "client_payload[conclusion]=${CONCLUSION}"
propose:
desc: >-
Propose this commit to a deployment: a pull request in REPOSITORY moving it to this ref and
the newest release in REGION, as the app GH_TOKEN and APP_SLUG name.
deps: [tools:tofu]
env:
TOFU: "{{.TOOLS_BIN}}/tofu"
cmds:
- bash hack/propose.sh