Files
solvecraft/solidcore/scripts/ci/check-rust-version.sh
bherbruck 4579e1ad50 Every package builds on the Rust release it declares (solidcore 1.85, ops and convert 1.88), and CI checks it (#3112) (#13563)
* ci: build each package on the Rust release its rust-version declares (#3112)

solidcore declares rust-version 1.85, but nothing checks it: rust-toolchain.toml pins
1.98 for every job. Since fc2212694 the crate no longer builds on 1.91, and it has not
built on 1.85 for longer. This job installs each declared version and runs
`cargo +<version> check` on the packages that declare it. It fails on main.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* solidcore builds on Rust 1.85 again, the release it declares; ops and convert declare 1.88 (#3112)

- blend_corner/mixed.rs: pass the side's curves to `nth_mut` as a slice
  (`as_mut_slice()`). Rust before 1.98 tried to unsize the argument of `of2m`
  instead of its result and refused the call (E0308, E0277): 1.91 to 1.97 could not
  build solidcore.
- fillet_corner/p1.rs, heal/face_props.rs, surface/volume/p2.rs: an error is passed
  on when its reason is a given one through a `matches!` guard on `&e`, not an
  `e @ (... { reason, .. })` binding. Binding a field after a by-move `@` builds
  only from 1.91 (E0382 on 1.85 to 1.90). Same arms, same order, same result.
- solidcore-convert and solidcore-ops depend on solidcore-record, which needs 1.88
  (edition 2024 let chains); they declared the workspace's 1.85, which cargo refuses.
  They now declare 1.88, like solidcore-tess.

With this, every package builds on the rust-version it declares
(scripts/ci/check-rust-version.sh): solidcore, solidcore-ssi, nurbs-grid-mesh and
xtask on 1.85; solidcore-record, -convert, -ops and -tess on 1.88. The whole
workspace also builds on 1.91, the reporter's toolchain.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ops: pair the mitred rounds with as_chunks (Rust 1.88), as clippy asks now ops declares 1.88 (#3112)

With rust-version 1.88, clippy's MSRV-aware `chunks_exact_with_const_size` lint
fires on `mitred.chunks_exact(2)`. `as_chunks::<2>()` gives the same pairs as
`[EdgeId; 2]` arrays and drops an odd last one, so the arm for a short chunk goes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci: the rust-version check fails when no package declares a rust-version (#3112)

If `cargo metadata` gives no package with a rust_version (a renamed field, a
jq filter that stops matching), the loop ran zero times and the check passed
with nothing checked. It now stops with an error instead.

The header says the scope is library and binaries on purpose (no
--all-targets: dev-dependencies may need a newer compiler than the package),
and the failure message says a dependency can be the cause too, pointing at
cargo's "requires rustc" line.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Ahmad Khan <khanahmad4527@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-08 18:41:14 -05:00

31 lines
1.9 KiB
Bash
Executable File
Vendored

#!/usr/bin/env bash
# Builds every workspace package that declares a `rust-version` with that Rust release, so
# the declared minimum is one the code actually compiles on. rust-toolchain.toml pins a newer
# release for everything else; this check is the only one that runs an older compiler.
# Packages declaring the same version are checked together (`cargo +<version> check -p ...`).
# Scope is the library and binaries only, on purpose: no `--all-targets`. A rust-version is a
# promise about what a consumer compiles; tests and benches would pull dev-dependencies that
# may need a newer compiler than the package itself.
# Needs rustup (installs each version's minimal profile) and jq.
# Usage: check-rust-version.sh
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
fail=0
# "<version> <package>" for each package with a declared rust-version, grouped by version.
pairs=$(cargo metadata --no-deps --format-version 1 --locked |
jq -r '.packages[] | select(.rust_version != null) | "\(.rust_version) \(.name)"' | sort -V)
# An empty list would skip the loop and pass with nothing checked; fail instead.
[ -n "$pairs" ] || { echo "::error::no package declares rust-version"; exit 1; }
for version in $(cut -d' ' -f1 <<<"$pairs" | uniq); do
packages=$(awk -v v="$version" '$1 == v { printf " -p %s", $2 }' <<<"$pairs")
echo "::group::Rust $version:$packages"
rustup toolchain install "$version" --profile minimal --no-self-update
# shellcheck disable=SC2086 # one -p per package
if ! cargo "+$version" check --locked $packages; then
echo "::error::A package declares rust-version $version but does not build on it:$packages. Either the code or a dependency needs a newer release (cargo's \"requires rustc\" line above names the dependency). Make the code build on $version, hold that dependency at an older version, or raise the package's rust-version to the oldest release it builds on."
fail=1
fi
echo "::endgroup::"
done
exit $fail