-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJustfile
More file actions
219 lines (176 loc) · 5.72 KB
/
Justfile
File metadata and controls
219 lines (176 loc) · 5.72 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
mod guests
# default Just target - list recipes
default:
@just --list --list-submodules
# check Python formatting
check-python-fmt:
@echo ::group::check-python-fmt
uv --project=python-tooling run --isolated --locked -- ruff format --check
@echo ::endgroup::
# check Python lints
check-python-lint:
@echo ::group::check-python-lint
uv --project=python-tooling run --isolated --locked -- ruff check
@echo ::endgroup::
# ensure that Python lockfile is up-to-date
check-python-lock:
@echo ::group::check-python-lock
uv --project=python-tooling lock --check
@echo ::endgroup::
# check Python typing
check-python-ty:
@echo ::group::check-python-ty
uv --project=python-tooling run --isolated --locked -- ty check --error-on-warning
@echo ::endgroup::
# all Python checks
check-python: check-python-fmt check-python-lint check-python-lock check-python-ty
# check Rust files via `cargo build`
check-rust-build: guests::rust::check-build guests::python::check-build
# check Rust files via `cargo check` and no default features
check-rust-check-no-default-features $JUSTCHECK="1":
@echo ::group::check-rust-check-no-default-features
cargo check --workspace --no-default-features
@echo ::endgroup::
# check Rust files via `cargo check` and all features
check-rust-check-all-features $JUSTCHECK="1":
@echo ::group::check-rust-check-all-features
cargo check --workspace --all-features
@echo ::endgroup::
# check Rust files via `cargo clippy`
check-rust-clippy $JUSTCHECK="1":
@echo ::group::check-rust-clippy
cargo clippy --all-features --all-targets --workspace -- -D warnings
@echo ::endgroup::
# check Rust formatting
check-rust-fmt $JUSTCHECK="1":
@echo ::group::check-rust-fmt
cargo fmt --all -- --check
@echo ::endgroup::
# test Rust code
check-rust-test $RUST_BACKTRACE="1":
@echo ::group::check-rust-test
cargo test --all-features --workspace
@echo ::endgroup::
# build Rust docs
check-rust-doc $JUSTCHECK="1":
@echo ::group::check-rust-doc
cargo doc --document-private-items --no-deps --all-features --workspace
@echo ::endgroup::
# dry-run Rust benchmarks
check-rust-bench:
@echo ::group::check-rust-bench
cargo bench --profile=dev --all-features --workspace -- --test
@echo ::endgroup::
# check Rust dependencies with cargo-deny
check-rust-deny:
@echo ::group::check-rust-deny
cargo deny check
@echo ::endgroup::
# run ALL Rust checks
check-rust: check-rust-fmt check-rust-check-no-default-features check-rust-check-all-features check-rust-build check-rust-clippy check-rust-test check-rust-doc check-rust-bench check-rust-deny
# check spelling
check-spelling:
@echo ::group::check-spelling
typos
@echo ::endgroup::
# check TOML formatting
check-toml-fmt:
@echo ::group::check-toml-fmt
tombi format --check
@echo ::endgroup::
# lint TOML files with taplo
check-toml-lint:
@echo ::group::check-toml-lint
tombi lint
@echo ::endgroup::
# check TOML files
check-toml: check-toml-fmt check-toml-lint
# check WIT files
check-wit:
#!/usr/bin/env bash
set -euo pipefail
echo ::group::check-wit
readonly wit='wit/world.wit'
readonly sed_filter='s/^[^@]+@([0-9.]+).*/\1/g'
echo
if ! git diff --exit-code origin/main "$wit"; then
echo
echo "change detected"
version_main="$(git show origin/main:"$wit" | grep package | sed -E "$sed_filter")"
version_head="$(cat "$wit" | grep package | sed -E "$sed_filter")"
echo "version main: $version_main"
echo "version HEAD: $version_head"
if [ "$version_head" == "$version_main" ]; then
echo "please update the WIT version!"
echo ::endgroup::
exit 1
else
echo "WIT version was updated"
fi
else
echo
echo "no change detected"
fi
echo ::endgroup::
# lint YAML files
check-yaml:
@echo ::group::check-yaml
uv --project=python-tooling run --isolated --locked -- yamllint -s .
@echo ::endgroup::
# run ALL checks
check: check-python check-rust check-spelling check-toml check-wit check-yaml
# clean Rust build artifacts
clean-rust:
@echo ::group::clean-rust
cargo clean
@echo ::endgroup::
# clean build artifacts
clean: clean-rust guests::python::clean
# fix Python formatting
fix-python-fmt:
@echo ::group::fix-python-fmt
uv --project=python-tooling run --isolated --locked -- ruff format
@echo ::endgroup::
# fix Python lints
fix-python-lint:
@echo ::group::fix-python-lint
uv --project=python-tooling run --isolated --locked -- ruff check --fix
@echo ::endgroup::
# lock Python env
fix-python-lock:
@echo ::group::fix-python-lock
uv --project=python-tooling lock
@echo ::endgroup::
# fix Python-related issues
fix-python: fix-python-lint fix-python-fmt fix-python-lock
# fix Rust check/rustc warnings
fix-rust-check:
@echo ::group::fix-rust-check
cargo fix --workspace --allow-dirty --allow-staged
@echo ::endgroup::
# fix Rust clippy warnings
fix-rust-clippy:
@echo ::group::fix-rust-clippy
cargo clippy --all-targets --all-features --workspace --fix --allow-dirty --allow-staged
@echo ::endgroup::
# fix Rust formatting
fix-rust-fmt:
@echo ::group::fix-rust-fmt
cargo fmt --all
@echo ::endgroup::
# fix common Rust issues automatically
fix-rust: fix-rust-clippy fix-rust-check fix-rust-fmt
# fix typos
fix-spellcheck:
@echo ::group::fix-rust-fmt
typos --write-changes
@echo ::endgroup::
# fix TOML formatting
fix-toml-fmt:
@echo ::group::fix-toml-fmt
tombi format
@echo ::endgroup::
# fix common TOML issues
fix-toml: fix-toml-fmt
# fix common issues automatically
fix: fix-python fix-spellcheck fix-rust fix-toml