Include cxxbridge-cmd in Cargo.lock, check version consistency (#3712)

This adds cxxbridge-cmd to Cargo.lock per
https://github.com/dtolnay/cxx/issues/1407#issuecomment-2509136343

It adds an MSRV to `src/taskchampion-cpp/Cargo.toml` so that the
version of `Cargo.lock` is stil compatible with the MSRV.

It additionally adds a check of the Cargo metadata for all of the cxx*
versions agreeing, and for the MSRV's agreeing.
This commit is contained in:
Dustin J. Mitchell 2024-12-01 10:22:26 -05:00 committed by GitHub
parent e5ab1bc7a5
commit c2cb7f36a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 164 additions and 11 deletions

View file

@ -64,3 +64,19 @@ jobs:
with:
command: fmt
args: --all -- --check
cargo-metadata:
runs-on: ubuntu-latest
name: "Cargo Metadata"
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustfmt
toolchain: stable
override: true
- name: "Check metadata"
run: ".github/workflows/metadata-check.sh"

73
.github/workflows/metadata-check.sh vendored Executable file
View file

@ -0,0 +1,73 @@
#! /bin/bash
# Check the 'cargo metadata' for various requirements
set -e
META=$(mktemp)
trap 'rm -rf -- "${META}"' EXIT
cargo metadata --locked --format-version 1 > "${META}"
get_version() {
local package="${1}"
jq -r '.packages[] | select(.name == "'"${package}"'") | .version' "${META}"
}
get_msrv() {
local package="${1}"
jq -r '.packages[] | select(.name == "'"${package}"'") | .rust_version' "${META}"
}
# check that the cxx packages all have the same version
check_cxx_versions() {
local cxx_version=$(get_version "cxx")
local cxx_build_version=$(get_version "cxx-build")
local cxxbridge_cmd_version=$(get_version "cxx-build")
local cxxbridge_flags_version=$(get_version "cxxbridge-flags")
local cxxbridge_macro_version=$(get_version "cxxbridge-macro")
ok=true
echo "Found cxx version ${cxx_version}"
if [ "${cxx_version}" != "${cxx_build_version}" ]; then
echo "Found differing cxx-build version ${cxx_build_version}"
ok = false
fi
if [ "${cxx_version}" != "${cxxbridge_cmd_version}" ]; then
echo "Found differing cxxbridge-cmd version ${cxxbridge_cmd_version}"
ok = false
fi
if [ "${cxx_version}" != "${cxxbridge_flags_version}" ]; then
echo "Found differing cxxbridge-flags version ${cxxbridge_flags_version}"
ok = false
fi
if [ "${cxx_version}" != "${cxxbridge_macro_version}" ]; then
echo "Found differing cxxbridge-macro version ${cxxbridge_macro_version}"
ok = false
fi
if ! $ok; then
echo "All cxx packages must be at the same version. Fix this in src/taskchampion-cpp/Cargo.toml."
exit 1
else
echo "✓ All cxx packages are at the same version."
fi
}
check_msrv() {
local taskchampion_msrv=$(get_msrv taskchampion)
local taskchampion_lib_msrv=$(get_msrv taskchampion-lib)
echo "Found taskchampion MSRV ${taskchampion_msrv}"
echo "Found taskchampion-lib MSRV ${taskchampion_lib_msrv}"
if [ "${taskchampion_msrv}" != "${taskchampion_lib_msrv}" ]; then
echo "Those MSRVs should be the same (or taskchampion-lib should be greater, in which case adjust this script)"
exit 1
else
echo "✓ MSRVs are at the same version."
fi
}
check_cxx_versions
check_msrv

View file

@ -118,6 +118,7 @@ jobs:
# If this version is old enough to cause errors, or older than the
# TaskChampion MSRV, bump it to the MSRV of the currently-required
# TaskChampion package; if necessary, bump that version as well.
# This should match the MSRV in `src/taskchampion-cpp/Cargo.toml`.
toolchain: "1.73.0" # MSRV
override: true