-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
174 lines (155 loc) · 4.7 KB
/
Copy pathTaskfile.yml
File metadata and controls
174 lines (155 loc) · 4.7 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
---
# 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:
desc: Initialize the repo for local use; intended to be run after git clone
deps: [lock]
cmds:
- task: init-uv
- task: init-install-tools
- uv run playwright install --with-deps chromium
build:
desc: Build the project
# Sources are needed for auto-rebuilding via the taskfile watch feature
sources:
- docs/**/*.md
- docs/**/*.py
- docs/**/*.rst
cmds:
- uv run sphinx-build -b html docs build
open:
desc: Open the home page
deps: [build]
cmds:
- open {{.ROOT_DIR}}/build/index.html
test:
desc: Run the project tests
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, and other misc components
cmds:
- '{{if ne .GITHUB_ACTIONS "true"}}brew upgrade uv{{end}}'
- uv lock --upgrade
clean:
desc: Clean up build artifacts, cache files/directories, temp files, etc.
cmds:
- rm -rf {{.ROOT_DIR}}/build/
- 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 {} +