-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathjustfile
85 lines (67 loc) · 3.16 KB
/
justfile
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
# === Relevant CI variables ====================================
# CROSS - the path to cross (or cargo) executable
# TARGET_TRIPLE - the target triple to build/test for
# RELEASE_BUILD - if non-empty, build in release mode
# RUST_CHANNEL - the rust toolchain channel to use (default: stable)
CROSS := `which cross 2>/dev/null || which cargo 2>/dev/null`
RUST_CHANNEL := "stable"
TARGET_TRIPLE := `rustc -Vv | grep host | cut -d' ' -f2`
TARGET_FLAGS := "--workspace --all-targets --all-features"
RELEASE_FLAG := if env_var_or_default("RELEASE_BUILD", "") != "" { "--release" } else { "" }
DOC_TARGET_FLAGS := "--no-deps --target " + TARGET_TRIPLE + " --release --workspace --all-features"
WORKSPACE_CRATES := shell('$1 metadata --no-deps --format-version=1 | jq -r ".packages[].name" | tr "\n" " "', CROSS)
FMT_FLAGS := "--all -- --check"
CLIPPY_FLAGS := TARGET_FLAGS + " -- -D warnings"
export RUSTFLAGS := env_var_or_default("RUSTFLAGS", "--deny warnings")
export RUSTDOCFLAGS := env_var_or_default("RUSTDOCFLAGS", "--deny warnings")
# Default entry point: Run all verification steps
default: all
# Run the complete verification suite (formatting, linting, building, testing, documentation)
all: check build test doc
# Run all code quality checks (both formatting and linting)
check: fmt lint
# Run Clippy for static code analysis with strict warning enforcement
lint:
@echo "Running clippy..."
{{CROSS}} clippy {{CLIPPY_FLAGS}}
# Verify code formatting compliance with default rustfmt standards
fmt:
@echo "Checking formatting..."
{{CROSS}} fmt {{FMT_FLAGS}}
# Build the entire workspace with proper target configuration, mode is determined by RELEASE_BUILD
build:
@echo "Building workspace..."
{{CROSS}} build --target {{TARGET_TRIPLE}} {{TARGET_FLAGS}} {{RELEASE_FLAG}}
# Execute the test suite across the entire workspace (excludes documentation tests)
test:
@echo "Running all tests...(excluding doc)"
{{CROSS}} test '--target' {{TARGET_TRIPLE}} {{TARGET_FLAGS}}
# Build documentation for the entire workspace
doc-build:
@echo "Building documentation..."
echo "RUSTDOCFLAGS: {{RUSTDOCFLAGS}}"
{{CROSS}} doc {{DOC_TARGET_FLAGS}}
# Run documentation tests for each crate in the workspace (requires jq)
doc-test:
@echo "Running documentation tests for each workspace crate..."
for crate in {{WORKSPACE_CRATES}}; do \
echo "Testing docs for: $crate" && \
{{CROSS}} test --doc -p "$crate" || exit 1; \
done
# Build documentation and run documentation tests for each crate
doc: doc-build doc-test
# Prepare a release build with complete documentation
release:
@echo "Running a possible release build with docs..."
{{CROSS}} doc {{DOC_TARGET_FLAGS}} '--target-dir' /tmp/rasn-docs
# Set up or update the development environment with required Rust toolchain components
toolchain:
@echo "Setting up Rust toolchain {{RUST_CHANNEL}} for target {{TARGET_TRIPLE}}"
if [ "${GITHUB_JOB:-}" = "windows" ]; then \
rustup set auto-self-update disable; \
else \
rustup update; \
fi
rustup default {{RUST_CHANNEL}}
rustup target add {{TARGET_TRIPLE}}
rustup component add rustfmt clippy