Merge branch 'ps/ci-rust'

CI improvements to handle the recent Rust integration better.

* ps/ci-rust:
  rust: support for Windows
  ci: verify minimum supported Rust version
  ci: check for common Rust mistakes via Clippy
  rust/varint: add safety comments
  ci: check formatting of our Rust code
  ci: deduplicate calls to `apt-get update`
This commit is contained in:
Junio C Hamano
2025-10-28 10:29:09 -07:00
9 changed files with 103 additions and 9 deletions

View File

@@ -10,6 +10,8 @@ begin_group "Install dependencies"
P4WHENCE=https://cdist2.perforce.com/perforce/r23.2
LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
JGITWHENCE=https://repo1.maven.org/maven2/org/eclipse/jgit/org.eclipse.jgit.pgm/6.8.0.202311291450-r/org.eclipse.jgit.pgm-6.8.0.202311291450-r.sh
CARGO_MSRV_VERSION=0.18.4
CARGO_MSRV_WHENCE=https://github.com/foresterre/cargo-msrv/releases/download/v$CARGO_MSRV_VERSION/cargo-msrv-x86_64-unknown-linux-musl-v$CARGO_MSRV_VERSION.tgz
# Make sudo a no-op and execute the command directly when running as root.
# While using sudo would be fine on most platforms when we are root already,
@@ -129,21 +131,28 @@ esac
case "$jobname" in
ClangFormat)
sudo apt-get -q update
sudo apt-get -q -y install clang-format
;;
StaticAnalysis)
sudo apt-get -q update
sudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \
libexpat-dev gettext make
;;
RustAnalysis)
sudo apt-get -q -y install rustup
rustup default stable
rustup component add clippy rustfmt
wget -q "$CARGO_MSRV_WHENCE" -O "cargo-msvc.tgz"
sudo mkdir -p "$CUSTOM_PATH"
sudo tar -xf "cargo-msvc.tgz" --strip-components=1 \
--directory "$CUSTOM_PATH" --wildcards "*/cargo-msrv"
sudo chmod a+x "$CUSTOM_PATH/cargo-msrv"
;;
sparse)
sudo apt-get -q update -q
sudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \
libexpat-dev gettext zlib1g-dev sparse
;;
Documentation)
sudo apt-get -q update
sudo apt-get -q -y install asciidoc xmlto docbook-xsl-ns make
test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||

22
ci/run-rust-checks.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
. ${0%/*}/lib.sh
set +x
if ! group "Check Rust formatting" cargo fmt --all --check
then
RET=1
fi
if ! group "Check for common Rust mistakes" cargo clippy --all-targets --all-features -- -Dwarnings
then
RET=1
fi
if ! group "Check for minimum required Rust version" cargo msrv verify
then
RET=1
fi
exit $RET