generated from eblume/project-template
30 lines
979 B
Text
30 lines
979 B
Text
|
|
#!/usr/bin/env bash
|
||
|
|
#
|
||
|
|
# Project build hook (tech-spec §9): run the Rust workspace checks in CI.
|
||
|
|
#
|
||
|
|
# Invoked by .forgejo/workflows/build.yaml after the generic `prek` pass.
|
||
|
|
# Bootstraps a minimal Rust toolchain via rustup when the runner image lacks
|
||
|
|
# one, so the suite runs without a bespoke CI image. The headless nvim e2e
|
||
|
|
# suite is added here once heph.nvim exists.
|
||
|
|
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
if ! command -v cargo >/dev/null 2>&1; then
|
||
|
|
echo "cargo not found; bootstrapping Rust toolchain via rustup..."
|
||
|
|
export RUSTUP_HOME="${RUSTUP_HOME:-$HOME/.rustup}"
|
||
|
|
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
|
||
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
||
|
|
| sh -s -- -y --profile minimal
|
||
|
|
# shellcheck disable=SC1091
|
||
|
|
. "$CARGO_HOME/env"
|
||
|
|
rustup component add clippy rustfmt
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "== cargo fmt --check =="
|
||
|
|
cargo fmt --all --check
|
||
|
|
|
||
|
|
echo "== cargo clippy =="
|
||
|
|
cargo clippy --all-targets --all-features -- -D warnings
|
||
|
|
|
||
|
|
echo "== cargo test =="
|
||
|
|
cargo test --all
|