-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
144 lines (110 loc) · 4.08 KB
/
justfile
File metadata and controls
144 lines (110 loc) · 4.08 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
# Run all recipes inside the Flox environment
set shell := ["flox", "activate", "--", "sh", "-cu"]
[private]
default:
@just --list
# Run a subset of checks as pre-commit hooks
pre-commit:
#!/usr/bin/env -S flox activate -- parallel --shebang --ungroup --jobs {{ num_cpus() }}
just prettier true
just format-toml true
just format-rust true
just lint-github-actions
just lint-markdown
just lint-rust
just lint-yaml
just test-rust
# Build the documentation for the crates
build-docs:
cargo doc --all-features --no-deps
# Check that all Cargo features compile
check-features:
cargo hack --feature-powerset check --lib --tests
# Check that typed-fields builds with the latest dependencies
check-latest-deps force="false":
#!/usr/bin/env bash
set -euo pipefail
# Abort if git is not clean (but ignore Flox's manifest.lock)
if [[ {{force}} != "true" && -n $(git status --porcelain -- ':!.flox/env/manifest.lock') ]]; then
echo "Git working directory is not clean. Commit or stash changes before running this recipe. Aborting."
git status --porcelain
exit 1
fi
# Update dependencies to latest versions
cargo update
# Run tests to ensure the latest versions are compatible
RUSTFLAGS="-D deprecated" cargo test --all-features --all-targets --locked
# Check that typed-fields builds with the minimal dependencies
check-minimal-deps force="false":
#!/usr/bin/env bash
set -euo pipefail
# Abort if git is not clean (but ignore Flox's manifest.lock)
if [[ {{force}} != "true" && -n $(git status --porcelain -- ':!.flox/env/manifest.lock') ]]; then
echo "Git working directory is not clean. Commit or stash changes before running this recipe. Aborting."
git status --porcelain
exit 1
fi
# Install the nightly toolchain if not already installed
rustup install nightly
# Update dependencies to minimal versions
rustup run nightly cargo update -Z direct-minimal-versions
# Run tests to ensure the minimal versions are compatible
RUSTFLAGS="-D deprecated" rustup run nightly cargo test --all-features --all-targets --locked
# Check the Minimum Supported Rust Version
check-msrv:
#!/usr/bin/env bash
set -euo pipefail
# Get the MSRV from the Cargo.toml
MSRV=$(cat Cargo.toml | grep 'rust-version =' | head -n 1 | cut -d '"' -f 2)
# Install the MSRV toolchain if not already installed
rustup install "${MSRV}"
# Run tests using the MSRV
RUSTFLAGS="-D deprecated" rustup run "${MSRV}" cargo check --all-features --all-targets
# Check that all dependencies in Cargo.toml are used
check-unused-deps:
#!/usr/bin/env bash
set -euo pipefail
# Install the nightly toolchain if not already installed
rustup install nightly
# Check for unused dependencies
rustup run nightly cargo udeps
# Format JSON files
format-json fix="false": (prettier fix "{json,json5}")
# Format Markdown files
format-markdown fix="false": (prettier fix "md")
# Format Rust files
format-rust fix="false":
cargo fmt {{ if fix != "true" { "--check" } else { "" } }}
# Format TOML files
format-toml fix="false":
taplo fmt {{ if fix != "true" { "--diff" } else { "" } }}
# Format YAML files
format-yaml fix="false": (prettier fix "{yaml,yml}")
# Lint dependent crates
lint-dependents:
cd tests/krate && cargo clippy -- -D warnings
# Lint GitHub Actions workflows
lint-github-actions:
zizmor -p .
# Lint Markdown files
lint-markdown:
markdownlint --ignore-path .gitignore **/*.md
# Lint Rust files
lint-rust:
cargo clippy --all-targets --all-features -- -D warnings
# Lint TOML files
lint-toml:
taplo check
# Lint YAML files
lint-yaml:
yamllint .
# Auto-format files with prettier
[private]
prettier fix="false" extension="*":
prettier {{ if fix == "true" { "--write" } else { "--list-different" } }} --ignore-unknown "**/*.{{ extension }}"
# Publish the crate to crates.io
publish:
cargo publish -p typed-fields --all-features --token $CARGO_REGISTRY_TOKEN
# Run the tests
test-rust:
cargo test --all-features --all-targets