this repo has no description
1# cmprss Development Commands
2# Run `just` to see available recipes
3
4alias b := build
5alias t := test
6
7[private]
8default:
9 @just --list
10
11# =============================================================================
12# Development Workflows
13# =============================================================================
14
15# Quick development feedback (build + test + lint)
16dev:
17 just build
18 just test
19 just lint clippy
20
21# Run automatic fixes (clippy fix + nix fixes + format)
22fix:
23 cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features
24 statix fix .
25 deadnix --edit .
26 just fmt
27
28# =============================================================================
29# Building
30# =============================================================================
31
32# Build the project (debug or release)
33build mode='debug':
34 cargo build --all-targets --all-features {{ if mode == "release" { "--release" } else { "" } }} --quiet
35
36# =============================================================================
37# Testing
38# =============================================================================
39
40# Run tests
41test *args:
42 #!/usr/bin/env bash
43 set -e
44 args="{{ args }}"
45
46 if [ -z "$args" ]; then
47 cargo nextest run --no-default-features
48 exit 0
49 fi
50
51 case "$args" in
52 full)
53 ./bin/test.sh
54 ;;
55 *)
56 cargo nextest run --no-default-features "$args"
57 ;;
58 esac
59
60# =============================================================================
61# Linting (Static Analysis)
62# =============================================================================
63
64# Run linter(s): clippy, deny, typos, statix, deadnix, shellcheck, actionlint, all
65lint +tools='clippy deny typos statix deadnix shellcheck actionlint':
66 #!/usr/bin/env bash
67 set -e
68 for tool in {{ tools }}; do
69 case "$tool" in
70 clippy)
71 echo "=== Running clippy ==="
72 cargo clippy --all-targets --all-features -- -D warnings
73 ;;
74 deny)
75 echo "=== Running cargo-deny ==="
76 cargo deny check
77 ;;
78 typos)
79 echo "=== Running typos ==="
80 typos --config .config/typos.toml
81 ;;
82 statix)
83 echo "=== Running statix ==="
84 statix check .
85 ;;
86 deadnix)
87 echo "=== Running deadnix ==="
88 deadnix --fail .
89 ;;
90 shellcheck)
91 echo "=== Running shellcheck ==="
92 find . -name "*.sh" -type f -exec shellcheck {} +
93 ;;
94 actionlint)
95 echo "=== Running actionlint ==="
96 find .github/workflows -name "*.yml" -exec actionlint {} +
97 ;;
98 all)
99 just lint clippy deny typos statix deadnix shellcheck actionlint
100 ;;
101 *)
102 echo "Unknown linter: $tool"
103 echo "Options: clippy, deny, typos, statix, deadnix, shellcheck, actionlint, all"
104 exit 1
105 ;;
106 esac
107 done
108
109# =============================================================================
110# Formatting
111# =============================================================================
112
113# Run formatters: (default), check
114fmt mode='':
115 #!/usr/bin/env bash
116 set -e
117 case "{{ mode }}" in
118 check)
119 cargo fmt -- --check
120 alejandra . --check --quiet
121 prettier --check . --log-level warn
122 typos --config .config/typos.toml
123 ;;
124 *)
125 cargo fmt
126 alejandra . --quiet
127 prettier --write . --log-level warn
128 typos --write-changes --config .config/typos.toml
129 ;;
130 esac
131
132# =============================================================================
133# Coverage
134# =============================================================================
135
136# Generate coverage report
137coverage:
138 cargo tarpaulin --skip-clean --include-tests --output-dir coverage --out lcov --no-default-features
139
140# Generate coverage using nix
141nix-coverage:
142 nix build .#coverage --out-link coverage
143
144# =============================================================================
145# CI
146# =============================================================================
147
148# Run CI locally: local (default), full (containers), nix
149ci mode='local':
150 #!/usr/bin/env bash
151 set -e
152 case "{{ mode }}" in
153 local)
154 just fix
155 just lint
156 just build
157 just test
158 just build release
159 ;;
160 full)
161 act
162 ;;
163 nix)
164 just nix check
165 ;;
166 *)
167 echo "Unknown mode: {{ mode }}"
168 echo "Options: local, full, nix"
169 exit 1
170 ;;
171 esac
172
173# =============================================================================
174# Nix
175# =============================================================================
176
177# Nix commands: build, check, fmt
178nix action='check':
179 #!/usr/bin/env bash
180 set -e
181 case "{{ action }}" in
182 build)
183 nix build
184 ;;
185 check)
186 nix flake check
187 ;;
188 fmt)
189 nix fmt
190 ;;
191 *)
192 echo "Unknown action: {{ action }}"
193 echo "Options: build, check, fmt"
194 exit 1
195 ;;
196 esac
197
198# =============================================================================
199# Commit
200# =============================================================================
201
202# Interactive conventional commit
203commit:
204 ./bin/commit.sh