-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint.sh
More file actions
executable file
·34 lines (30 loc) · 1.35 KB
/
Copy pathlint.sh
File metadata and controls
executable file
·34 lines (30 loc) · 1.35 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
#!/usr/bin/env bash
# Run clippy on all targets in the devcontainer's locked Nix toolchain. ./update.sh
# keeps it aligned with rust-toolchain.toml. Like build.sh, prefer vk on PATH
# (microVM); --docker forces Docker. Forward extra arguments to clippy (e.g. --fix).
set -euo pipefail
cd "$(dirname "$0")"
FORCE_DOCKER=""
args=()
for arg in "$@"; do
case "$arg" in
--docker) FORCE_DOCKER=1 ;;
*) args+=("$arg") ;;
esac
done
if [ -z "$FORCE_DOCKER" ] && command -v vk >/dev/null 2>&1; then
# Dogfood the vk on PATH: it builds the devcontainer image and runs clippy in a microVM
# with the repo mounted at the workdir. --net lets cargo fetch crates; the workspace
# compile needs every CPU and enough RAM to avoid rustc OOMs.
echo "lint.sh: linting with vk from PATH ($(command -v vk)); pass --docker to force Docker" >&2
exec vk run \
--file .devcontainer/Dockerfile --context .devcontainer --target enc-build \
--workdir "$PWD" --net --cpus host --mem 4G \
-- cargo clippy --workspace --all-targets --locked -- -D warnings "${args[@]}"
fi
docker build --target enc-build -t enc-build -f .devcontainer/Dockerfile .devcontainer
docker run --rm \
--user "$(id -u):$(id -g)" -e HOME=/tmp -e CARGO_HOME=/work/target/.cargo-home \
-v "$PWD":/work -w /work \
enc-build \
cargo clippy --workspace --all-targets --locked -- -D warnings "${args[@]}"