Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
238 lines (213 loc) · 7.37 KB
/
Copy pathTaskfile.yml
File metadata and controls
238 lines (213 loc) · 7.37 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
---
# https://taskfile.dev
version: '3'
set:
- nounset
- errexit
- pipefail
silent: true
# This sets the watch interval to .5s; https://taskfile.dev/usage/#watch-tasks
interval: '500ms'
tasks:
lock:
desc: Update uv.lock if pyproject.toml has changed
internal: true
sources:
- pyproject.toml
generates:
- uv.lock
cmds:
- uv lock
init-uv:
desc: Initializes uv if uv.lock changes
internal: true
sources:
- uv.lock
cmds:
- uv sync
runner-apt-install:
desc: Install something on a GitHub Actions runner via apt
internal: true
status:
- '{{if eq .GITHUB_ACTIONS "true"}}exit 1{{end}}'
requires:
vars: [TOOLS]
preconditions:
- sudo apt-get update
platforms: [linux]
cmds:
- for:
var: TOOLS
split: ','
as: tool
cmd: sudo apt-get install -y --no-install-recommends {{.tool}}
mac-brew-install:
desc: Install something on a mac via brew
internal: true
platforms: [darwin]
requires:
vars: [TOOLS]
cmds:
- for:
var: TOOLS
split: ','
as: tool
cmd: brew install {{.tool}}
init-install-tools:
desc: Install required tools
internal: true
cmds:
- task: runner-apt-install
vars:
TOOLS: xclip
- task: mac-brew-install
vars:
TOOLS: opentofu
init-npm:
desc: Install node dependencies if package-lock.json changes
internal: true
sources:
- package-lock.json
cmds:
- npm ci
init:
desc: Initialize the repo for local use; intended to be run after git clone
deps: [lock]
cmds:
- task: init-uv
- task: init-npm
- task: init-install-tools
- uv run playwright install --with-deps chromium
dev:
desc: Run the Astro dev server for the site (labs are not served here; use task build + task open)
cmds:
- npm run dev
build-labs:
desc: Build the Sphinx labs into build/ (tests read build/labs/)
internal: true
sources:
- docs/**/*.md
- docs/**/*.py
- docs/**/*.rst
- docs/_static/**/*
- docs/_templates/**/*
- public/analytics.js
cmds:
# Same font files the Astro site self-hosts, so the labs match without a third-party request
- mkdir -p docs/_static/fonts
- cp node_modules/@fontsource-variable/bricolage-grotesque/files/bricolage-grotesque-latin-wght-normal.woff2 node_modules/@fontsource-variable/jetbrains-mono/files/jetbrains-mono-latin-wght-normal.woff2 node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-{400,500,600}-normal.woff2 docs/_static/fonts/
# Cookie banner + Google Analytics, shared with the Astro site (public/analytics.js)
- mkdir -p docs/_static/consent
- cp node_modules/vanilla-cookieconsent/dist/cookieconsent.umd.js node_modules/vanilla-cookieconsent/dist/cookieconsent.css public/analytics.js docs/_static/consent/
- uv run sphinx-build -b html docs build
build-site:
desc: Build the Astro site into dist/
internal: true
sources:
- src/**/*
- public/**/*
- data/**/*
- docs/ref/jz-content.md
- docs/labs/*.md
- astro.config.mjs
- package-lock.json
cmds:
- npm run build
build:
desc: Build the whole site into dist/ (Astro pages + Sphinx labs merged in)
cmds:
- task: build-site
- task: build-labs
# Sphinx owns the labs and their references/assets; Astro owns every top-level page, so those are excluded.
# Excludes are anchored to the top level so build/labs/index.html still ships.
- rsync -a --exclude /index.html --exclude /about-me.html --exclude /resume.html --exclude /meet-with-jon.html --exclude /playlist.html --exclude /workshop.html --exclude /youtube.html build/ dist/
open:
desc: Open the built home page
deps: [build]
cmds:
- open {{.ROOT_DIR}}/dist/index.html
resume:
desc: Regenerate public/resume.pdf from resume/Jon Zeolla Resume.html (always runs; the GitHub chart in it is live)
cmds:
- node resume/print-pdf.mjs
test-site:
desc: Test the Astro site; run after `task build`
cmds:
- npm test
- npx astro check
- python3 -I scripts/check_links.py dist
- uv run pytest -n0 tests/test_site.py
test:
desc: Run the lab tests (deploys EC2 via OpenTofu; local macOS only for now)
deps: [clean, build]
# Tests only work locally for now
platforms: [darwin]
env:
LOG_LEVEL: '{{ .CLI_ARGS | default "INFO" }}'
# Not used; change -n0 below to -n "${NUMBER_OF_LABS}" when tests are parallelizable
NUMBER_OF_LABS:
sh: find docs/labs/ -name '*.md' | wc -l
cmds:
- uv run pytest -n0 -v tests/ --log-cli-level "${LOG_LEVEL}"
# Essentially an alias
deploy:
desc: Deploy the lab environment
cmds:
- task: deploy-lab
# Essentially an alias
lab:
desc: Deploy the lab environment
cmds:
- task: deploy-lab
deploy-lab:
desc: Deploy the lab environment
cmds:
- cd lab && tofu init && tofu apply -auto-approve
destroy:
desc: Run tofu destroys and cleanup all of the labs and test opentofu modules
cmds:
- cd lab && tofu init && tofu destroy -auto-approve
- |
if [[ -z "${LAB+x}" ]]; then
for dir in $(find tests -type d -maxdepth 1 -mindepth 1); do
pushd "${dir}" >/dev/null
echo "Running destroy in ${dir}..."
tofu init
tofu destroy -auto-approve
popd >/dev/null
done
else
pushd "tests/${LAB}" >/dev/null
echo "Running destroy in tests/${LAB}..."
tofu init
tofu destroy -auto-approve
popd >/dev/null
fi
update:
desc: Update the project dependencies (Python via uv, Node via npm-check-updates), and other misc components
cmds:
- '{{if ne .GITHUB_ACTIONS "true"}}brew upgrade uv{{end}}'
- uv lock --upgrade
# Bumps package.json ranges to the latest versions (majors included); the PR workflow builds and tests the result
- npx --yes npm-check-updates --upgrade
- npm install
clean:
desc: Clean up build artifacts, cache files/directories, temp files, etc.
cmds:
- rm -rf {{.ROOT_DIR}}/build/
- rm -rf {{.ROOT_DIR}}/dist/
- rm -rf {{.ROOT_DIR}}/.astro/
- find {{.ROOT_DIR}} -type d -name '.mypy_cache' -exec rm -rf {} +
- find {{.ROOT_DIR}} -type d -name '.pytest_cache' -exec rm -rf {} +
- find {{.ROOT_DIR}} -type d -name '.ruff_cache' -exec rm -rf {} +
- find {{.ROOT_DIR}} -type d -name '.task' -exec rm -rf {} +
- find {{.ROOT_DIR}} -type d -name '__pycache__' -exec rm -rf {} +
- find {{.ROOT_DIR}} -type d -name 'coverage-reports' -exec rm -rf {} +
- find {{.ROOT_DIR}} -type f -name '*.pyc' -delete
- find {{.ROOT_DIR}} -type f -name '.DS_Store' -delete
- find {{.ROOT_DIR}} -type f -name '.Thumbs.db' -delete
- find {{.ROOT_DIR}} -type f -name '.coverage' -delete
- find {{.ROOT_DIR}} -type d -name '.terraform' -exec rm -rf {} +
- find {{.ROOT_DIR}} -type f -name '.terraform.lock.hcl' -delete
# Leaving this commented out because it could accidentally kill state for a deployed environment; the above terraform lines should be enough
# - find {{.ROOT_DIR}}/tests -type d -maxdepth 1 -mindepth 1 -exec rm -rf {} +