-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlint
More file actions
executable file
·129 lines (114 loc) · 5.44 KB
/
Copy pathlint
File metadata and controls
executable file
·129 lines (114 loc) · 5.44 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
#!/bin/bash
set -e
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
LINT_PATHS=(src tests ci)
# Python stages run first: they need no Rust toolchain, so a host without
# soldr/rustup/cargo-dylint still gets full Python coverage (#262).
echo "Running ruff ${LINT_PATHS[*]}"
uv run ruff check --fix "${LINT_PATHS[@]}"
echo "Running black ${LINT_PATHS[*]}"
uv run black "${LINT_PATHS[@]}"
echo "Running isort ${LINT_PATHS[*]}"
uv run isort --profile black "${LINT_PATHS[@]}"
echo "Running pyright ${LINT_PATHS[*]}"
uv run pyright "${LINT_PATHS[@]}"
echo "Running keyboard interrupt checker ${LINT_PATHS[*]}"
uv run python ci/lint_python/keyboard_interrupt_checker.py "${LINT_PATHS[@]}"
# Rust linting goes through soldr so the zccache compile cache is hit.
# Install soldr with: uv tool install soldr (or see zackees/soldr).
if ! command -v soldr &> /dev/null; then
echo "Error: soldr is required for Rust linting. Install with: uv tool install soldr" >&2
exit 1
fi
echo Running cargo fmt check
soldr cargo fmt --all --check
echo Running cargo clippy
soldr cargo clippy --workspace --all-targets -- -D warnings
DYLINT_VERSION="6.0.3"
DYLINT_TOOLCHAIN="nightly-2026-03-26"
DYLINT_DIR="$SCRIPT_DIR/dylints/ban_std_pathbuf"
DYLINT_TARGET_DIR="${FASTLED_DYLINT_TARGET_DIR:-${RUNNER_TEMP:-${TMPDIR:-/tmp}}/fastled-dylint-target}"
DYLINT_LIBRARY_DIR="$DYLINT_TARGET_DIR/dylint/libraries/$DYLINT_TOOLCHAIN"
DYLINT_SKIP_REASON=""
if ! command -v cargo-dylint &> /dev/null; then
DYLINT_SKIP_REASON="cargo-dylint $DYLINT_VERSION is not installed (soldr cargo install cargo-dylint --version $DYLINT_VERSION --locked)"
elif ! uv run python "$SCRIPT_DIR/ci/lint_python/dylint_version_checker.py" cargo-dylint "$DYLINT_VERSION"; then
DYLINT_SKIP_REASON="cargo-dylint $DYLINT_VERSION is required (soldr cargo install cargo-dylint --version $DYLINT_VERSION --locked --force)"
elif ! command -v rustup &> /dev/null; then
DYLINT_SKIP_REASON="rustup is required for cargo-dylint's internal driver build"
fi
if [ -n "$DYLINT_SKIP_REASON" ] && [ -n "${CI:-}" ]; then
echo "Error: dylint prerequisites are missing in CI: $DYLINT_SKIP_REASON" >&2
exit 1
fi
if [ -z "$DYLINT_SKIP_REASON" ]; then
echo Running ban_std_pathbuf dylint
RUSTUP_BIN="$(command -v rustup || true)"
# cargo-dylint 6.x's driver toolchain check requires RUSTUP_HOME to be set
# explicitly; CI exports it but local shells typically rely on rustup's
# implicit default and fail with "environment variable not found: RUSTUP_HOME".
export RUSTUP_HOME="${RUSTUP_HOME:-$("$RUSTUP_BIN" show home)}"
RUSTUP_BIN_DIR="$(dirname "$RUSTUP_BIN")"
DYLINT_CARGO_SHIM_DIR="$(mktemp -d)"
DYLINT_PREVIOUS_DEFAULT="$(rustup default 2>/dev/null | sed 's/ (default)$//')"
cleanup_dylint_toolchain() {
rm -rf "$DYLINT_CARGO_SHIM_DIR"
if [ -n "$DYLINT_PREVIOUS_DEFAULT" ]; then
rustup default "$DYLINT_PREVIOUS_DEFAULT" >/dev/null || true
fi
}
trap cleanup_dylint_toolchain EXIT
cat > "$DYLINT_CARGO_SHIM_DIR/cargo" <<EOF
#!/bin/sh
exec "$RUSTUP_BIN" run "$DYLINT_TOOLCHAIN" cargo "\$@"
EOF
chmod +x "$DYLINT_CARGO_SHIM_DIR/cargo"
rustup default "$DYLINT_TOOLCHAIN" >/dev/null
(
cd "$DYLINT_DIR"
RUSTUP_TOOLCHAIN="$DYLINT_TOOLCHAIN" CARGO_TARGET_DIR="$DYLINT_LIBRARY_DIR" soldr cargo build --release
)
case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*)
DYLINT_BUILT_LIBRARY="$(find "$DYLINT_LIBRARY_DIR" -path "*/release/ban_std_pathbuf.dll" ! -path "*/deps/*" -print -quit)"
DYLINT_LIBRARY_NAME="ban_std_pathbuf@$DYLINT_TOOLCHAIN.dll"
;;
Darwin*)
DYLINT_BUILT_LIBRARY="$(find "$DYLINT_LIBRARY_DIR" -path "*/release/libban_std_pathbuf.dylib" ! -path "*/deps/*" -print -quit)"
DYLINT_LIBRARY_NAME="libban_std_pathbuf@$DYLINT_TOOLCHAIN.dylib"
;;
*)
DYLINT_BUILT_LIBRARY="$(find "$DYLINT_LIBRARY_DIR" -path "*/release/libban_std_pathbuf.so" ! -path "*/deps/*" -print -quit)"
DYLINT_LIBRARY_NAME="libban_std_pathbuf@$DYLINT_TOOLCHAIN.so"
;;
esac
if [ -z "$DYLINT_BUILT_LIBRARY" ]; then
echo "Error: built ban_std_pathbuf dylint library was not found under $DYLINT_LIBRARY_DIR" >&2
exit 1
fi
DYLINT_NAMED_LIBRARY="$DYLINT_LIBRARY_DIR/release/$DYLINT_LIBRARY_NAME"
mkdir -p "$DYLINT_LIBRARY_DIR/release"
cp "$DYLINT_BUILT_LIBRARY" "$DYLINT_NAMED_LIBRARY"
# cargo-dylint builds an internal driver and intentionally unsets RUSTUP_TOOLCHAIN
# for that nested build. Use a short-lived cargo shim plus a temporary rustup
# default so the nested driver build uses the pinned nightly in its temp dir.
PATH="$DYLINT_CARGO_SHIM_DIR:$RUSTUP_BIN_DIR:$PATH" RUSTUP_TOOLCHAIN="$DYLINT_TOOLCHAIN" CARGO_TARGET_DIR="$DYLINT_TARGET_DIR" \
cargo-dylint dylint --workspace --lib-path "$DYLINT_NAMED_LIBRARY" -- --all-targets
cleanup_dylint_toolchain
trap - EXIT
fi
if [ -n "$DYLINT_SKIP_REASON" ]; then
# Local hosts without the dylint prerequisites still get a green lint: every
# other stage ran. CI never reaches here -- the guard above fails hard when
# $CI is set, so the dylint stage cannot be silently dropped in CI (#262).
echo "" >&2
echo "==============================================================" >&2
echo "dylint not run: $DYLINT_SKIP_REASON" >&2
echo "Every other lint stage ran and passed." >&2
echo "Install the prerequisite and re-run ./lint for full coverage." >&2
echo "==============================================================" >&2
echo "Linting complete (dylint skipped)!"
exit 0
fi
echo Linting complete!
exit 0