Skip to content

Commit 11ed16b

Browse files
pks-tgitster
authored andcommitted
ci: verify minimum supported Rust version
In the current state of our Rust code base we don't really have any requirements for the minimum supported Rust version yet, as we don't use any features introduced by a recent version of Rust. Consequently, we have decided that we want to aim for a rather old version and edition of Rust, where the hope is that using an old version will make alternatives like gccrs viable earlier for compiling Git. But while we specify the Rust edition, we don't yet specify a Rust version. And even if we did, the Rust version would only be enforced for our own code, but not for any of our dependencies. We don't yet have any dependencies at the current point in time. But let's add some safeguards by specifying the minimum supported Rust version and using cargo-msrv(1) to verify that this version can be satisfied for all of our dependencies. Note that we fix the version of cargo-msrv(1) at v0.18.1. This is the latest release supported by Ubuntu's Rust version. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a94fe9a commit 11ed16b

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "gitcore"
33
version = "0.1.0"
44
edition = "2018"
5+
rust-version = "1.49.0"
56

67
[lib]
78
crate-type = ["staticlib"]

ci/install-dependencies.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ begin_group "Install dependencies"
1010
P4WHENCE=https://cdist2.perforce.com/perforce/r23.2
1111
LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
1212
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
13+
CARGO_MSRV_VERSION=0.18.4
14+
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
1315

1416
# Make sudo a no-op and execute the command directly when running as root.
1517
# While using sudo would be fine on most platforms when we are root already,
@@ -130,6 +132,12 @@ RustAnalysis)
130132
sudo apt-get -q -y install rustup
131133
rustup default stable
132134
rustup component add clippy rustfmt
135+
136+
wget -q "$CARGO_MSRV_WHENCE" -O "cargo-msvc.tgz"
137+
sudo mkdir -p "$CUSTOM_PATH"
138+
sudo tar -xf "cargo-msvc.tgz" --strip-components=1 \
139+
--directory "$CUSTOM_PATH" --wildcards "*/cargo-msrv"
140+
sudo chmod a+x "$CUSTOM_PATH/cargo-msrv"
133141
;;
134142
sparse)
135143
sudo apt-get -q -y install libssl-dev libcurl4-openssl-dev \

ci/run-rust-checks.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ then
1414
RET=1
1515
fi
1616

17+
if ! group "Check for minimum required Rust version" cargo msrv verify
18+
then
19+
RET=1
20+
fi
21+
1722
exit $RET

0 commit comments

Comments
 (0)