-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTaskfile.yml
222 lines (202 loc) · 6.22 KB
/
Taskfile.yml
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
version: "3"
dotenv:
- .env
tasks:
# Python tasks
py:_init:
internal: true
preconditions:
# Check UV installed
- sh: uv --version
msg: "UV is not installed. Please install it before running this task."
cmds:
- |
if test -d .venv; then
echo Found existing virtual env at .venv. Removing...
rm -fR .venv
else
echo No venv exist. Creating anew...
fi
# Create a virtual environment
- uv venv --python python
# Create local .env file if it doesn't exist
- test -f .env || cp .env.example .env
# Sync dependencies
- task: py:sync
# Set up pre-commit
- pre-commit install
- echo "Done"
py:init:
desc: "Checks system python is correct and sets up environment"
preconditions:
# Make sure .venv doesn't exist
- sh: test ! -d .venv
msg: "A virtual environment already exists. Please remove it before running or use py:init-force."
cmds:
- task: py:_init
py:init-force:
desc: "Checks system python is correct and recreates the environment"
prompt: "Are you sure you want to recreate the virtual environment?"
cmds:
- task: clean-all-caches
- task: clean-test
- task: py:_init
py:sync:
desc: "Sync dependencies & install project"
cmd: uv sync --all-extras --locked --compile-bytecode --python python
lint:
desc: "Run linters"
cmds:
- uv run pre-commit run --all-files
- typos
# Cleanup tasks
clean-pyc:
desc: remove Python file artifacts
cmds:
- find . -name '*.pyc' -not -path '*/.venv/*' -not -path '*/.tox/*' -exec rm -f {} +
- find . -name '*.pyo' -not -path '*/.venv/*' -not -path '*/.tox/*' -exec rm -f {} +
- find . -name '*~' -not -path '*/.venv/*' -not -path '*/.tox/*' -exec rm -f {} +
- find . -name '__pycache__' -not -path '*/.venv/*' -not -path '*/.tox/*' -exec rm -fr {} +
clean-test:
desc: remove test and coverage artifacts
cmds:
- rm -f .coverage
- rm -f .coverage.*
- rm -f coverage.xml
- rm -f report.xml
- rm -fr htmlcov/
- rm -fr .pytest_cache
- rm -fr testtemp/
clean-lint-caches:
desc: remove lint (mypy, ruff) caches
cmds:
- rm -fr .mypy_cache
- rm -fr .ruff_cache
clean-all-caches:
desc: remove all caches including Taskfile
cmds:
- task: clean-pyc
- task: clean-lint-caches
- rm -fr .pytest_cache
- rm -fr .task
clean:
desc: Clean up everything. Similar to doing a fresh clone except for .env
cmds:
- task: clean-all-caches
- task: clean-test
- cargo clean
# Build tasks
build:rel:
sources:
- crates/**/*.*
- Cargo.toml
- Cargo.lock
generates:
- target/release/*.*
cmds:
- cargo build --release --workspace
build:stats_polars:
sources:
- crates/**/*.*
- Cargo.toml
- Cargo.lock
generates:
- target/with_polars/*.*
cmds:
- cargo build -r --features polars --package sas-lexer-cli --target-dir target/with_polars
build:dev:
sources:
- crates/**/*.*
- Cargo.toml
- Cargo.lock
- src/**/*.*
- pyproject.toml
- uv.lock
generates:
- target/debug/*.*
cmds:
- maturin develop --uv -r
# Test tasks
test:
desc: Run tests
cmds:
# Test docs
- cargo test -p sas-lexer --doc
# First without macro_sep feature
- cargo test -p sas-lexer --all-targets
# Then with macro_sep feature
- cargo test -p sas-lexer --all-targets --features macro_sep --features serde
# Finally run python tests, but in an isolated environment and without editable
- uv run --isolated --no-editable pytest
# Performance tasks
perf:profile:
desc: Profile the application
cmds:
- cargo bench --bench lexer -- --profile-time 5
- |
echo "Path to the profile: target/criterion/lex/lex/profile/flamegraph.svg"
perf:cur:
deps:
- build:rel
cmds:
- hyperfine -N -w 10 "target/release/sas-lexer lex {{.SAS_LEX_SAMPLES}}"
- hyperfine -N -w 5 "target/release/sas-lexer lex {{.PERF_LARGE_SAMPLE}}"
perf:compare:
desc: Compare the performance of the current build with the given SHA
deps:
- build:rel
preconditions:
# Check that the working directory is clean, no staged or unstaged changes
- git diff --quiet
requires:
vars:
- SHA
cmds:
# Create a tempdir for current build
- mkdir -p tmpdir/
- defer: rm -rf tmpdir/
# Copy the current build to the tempdir
- cp target/release/sas-lexer tmpdir/
# Checkout the given SHA
- git checkout {{.SHA}}
# This will ensure we rebuild the project back at HEAD
- defer: cargo build --release
- defer: git checkout -
# Build the given SHA
- cargo build --release
# Compare the performance of the current build with the given SHA
- hyperfine -w 10 "tmpdir/sas-lexer lex {{.SAS_LEX_SAMPLES}}" "target/release/sas-lexer lex {{.SAS_LEX_SAMPLES}}"
- hyperfine -w 5 "tmpdir/sas-lexer lex {{.PERF_LARGE_SAMPLE}}" "target/release/sas-lexer lex {{.PERF_LARGE_SAMPLE}}"
# Release tasks
release-rust:
desc: Release a new version of the main sas-lexer crate
vars:
RELEASE_LEVEL:
sh: |
printf "major\nminor\npatch\nrelease\nrc\nbeta\nalpha" | fzf --prompt="Select release level: "
DRY_RUN:
sh: |
printf "yes\nno" | fzf --prompt="Dry run? "
cmds:
- |
if [ "{{.DRY_RUN}}" = "yes" ]; then
cargo release -p sas-lexer {{.RELEASE_LEVEL}}
else
cargo release -p sas-lexer -x {{.RELEASE_LEVEL}}
fi
release-py:
desc: Release a new version of the python package
vars:
RELEASE_LEVEL:
sh: |
printf "major\nminor\npatch\nrelease\nrc\nbeta\nalpha" | fzf --prompt="Select release level: "
DRY_RUN:
sh: |
printf "yes\nno" | fzf --prompt="Dry run? "
cmds:
- |
if [ "{{.DRY_RUN}}" = "yes" ]; then
cargo release -p sas-lexer-py {{.RELEASE_LEVEL}}
else
cargo release -p sas-lexer-py -x {{.RELEASE_LEVEL}}
fi