forked from canonical/ubuntu.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskfile.yaml
More file actions
153 lines (135 loc) · 3.16 KB
/
taskfile.yaml
File metadata and controls
153 lines (135 loc) · 3.16 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
version: "3"
vars:
VENV_DIR: .venv
VENV_BIN: "{{ .VENV_DIR }}/bin"
PYTHON_BIN: "{{ .VENV_BIN }}/python3"
PIP_BIN: "{{ .VENV_BIN }}/pip3"
env:
PORT: 8001
PYTHON_VERSION: "3.10"
NODE_VERSION: "20"
PATH: "{{ .VENV_BIN }}:$PATH"
dotenv: [".env.local", ".env"]
# Available tasks:
# - start (default)
# - install
# - shell
# - clean
# - test
# - lint
# - format
# - build
tasks:
default:
cmds:
- task: start
start:
desc: "Start the project"
deps:
- install
cmds:
- PATH="{{ .VENV_BIN }}:$PATH" yarn start
install:
desc: "Install Python and Node.js binaries and their packages"
deps:
- install-python
- install-yarn
cmds:
- echo "Installation complete"
shell:
desc: "Open a shell with the virtual environment activated"
deps:
- install
cmds:
- PATH="{{ .VENV_BIN }}:$PATH" $SHELL
clean:
cmds:
- rm -rf static/css static/js/dist node_modules {{ .VENV_DIR }} .task
test:
desc: "Run all project tests"
deps:
- install
cmds:
- PATH="{{ .VENV_BIN }}:$PATH" coverage run --source=webapp -m unittest $(find tests/ -name "test_*.py" ! -name "test_marketo.py")
- PATH="{{ .VENV_BIN }}:$PATH" yarn test-js --coverage
lint:
desc: "Run all project linting"
deps:
- install
cmds:
- PATH="{{ .VENV_BIN }}:$PATH" yarn lint-python
- PATH="{{ .VENV_BIN }}:$PATH" yarn lint-ts
- PATH="{{ .VENV_BIN }}:$PATH" yarn lint-js
- PATH="{{ .VENV_BIN }}:$PATH" yarn lint-scss
format:
desc: "Run all project formatting"
deps:
- install
cmds:
- PATH="{{ .VENV_BIN }}:$PATH" yarn format-python
- PATH="{{ .VENV_BIN }}:$PATH" yarn format-prettier
- npx stylelint --fix static/**/*.scss
build:
desc: "Build the project static files"
deps:
- install
cmds:
- PATH="{{ .VENV_BIN }}:$PATH" yarn build
# Custom tools versioning setup (mise, python, node, etc.)
setup-mise:
internal: true
desc: "Setup mise"
preconditions:
- which curl
status:
- ! which mise
cmds:
- curl https://mise.run | sh
setup-python:
deps:
- setup-mise
cmds:
- mise install python@{{ .PYTHON_VERSION }}
setup-node:
deps:
- setup-mise
cmds:
- mise install node@{{ .NODE_VERSION }}
# Python virtual environment
venv:
internal: true
desc: "Setup python virtual environment"
deps:
- setup-python
status:
- ! -f {{ .PYTHON_BIN }}
cmds:
- mise exec python@{{ .PYTHON_VERSION }} -- python3 -m venv .venv
- echo "Using Python $({{ .PYTHON_BIN }} --version)"
install-python:
internal: true
desc: "Install python packages"
deps:
- venv
sources:
- requirements.txt
generates:
- "{{ .VENV_DIR }}/*"
cmds:
- "{{ .PIP_BIN }} install -r requirements.txt"
# Node.js package manager
install-yarn:
internal: true
desc: "Install yarn packages"
deps:
- setup-node
status:
- which yarn
- which node
sources:
- yarn.lock
- package.json
generates:
- "node_modules/**"
cmds:
- yarn install