Skip to content

chore: leverage fallback resolver for MSRV check #2976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[resolver]
# https://doc.rust-lang.org/cargo/reference/config.html#resolverincompatible-rust-versions
incompatible-rust-versions = "fallback"
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
external-types:
strategy:
matrix:
example: [opentelemetry, opentelemetry-sdk, opentelemetry-otlp, opentelemetry-zipkin]
member: [opentelemetry, opentelemetry-sdk, opentelemetry-otlp, opentelemetry-zipkin]
runs-on: ubuntu-latest # TODO: Check if this could be covered for Windows. The step used currently fails on Windows.
steps:
- name: Harden the runner (Audit all outbound calls)
Expand All @@ -96,20 +96,20 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: nightly-2024-06-30
# Rust version should be kept in sync with the one the release was tested with
# https://github.com/awslabs/cargo-check-external-types/releases
toolchain: nightly-2025-05-04
components: rustfmt
- name: Patch dependencies versions
run: bash ./scripts/patch_dependencies.sh
- uses: taiki-e/install-action@33734a118689b0b418824fb78ea2bf18e970b43b # v2.50.4
with:
tool: [email protected]
- name: external-type-check
run: |
cargo install [email protected]
cd ${{ matrix.example }}
cargo check-external-types --all-features --config allowed-external-types.toml
working-directory: ${{ matrix.member }}
run: cargo check-external-types --all-features --config allowed-external-types.toml
msrv:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
rust: [1.75.0]
runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
Expand All @@ -121,14 +121,14 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
- name: Set up Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: stable
- uses: taiki-e/install-action@33734a118689b0b418824fb78ea2bf18e970b43b # v2.50.4
with:
toolchain: ${{ matrix.rust }}
- name: Patch dependencies versions
run: bash ./scripts/patch_dependencies.sh
tool: cargo-msrv
- name: Check MSRV for all crates
run: bash ./scripts/msrv.sh ${{ matrix.rust }}
run: bash ./scripts/msrv.sh
cargo-deny:
runs-on: ubuntu-latest # This uses the step `EmbarkStudios/cargo-deny-action@v1` which is only supported on Linux
continue-on-error: true # Prevent sudden announcement of a new advisory from failing ci
Expand Down
55 changes: 5 additions & 50 deletions scripts/msrv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,10 @@

set -eu

# Check if a version is specified as parameter
if [ $# -eq 0 ]; then
echo "No Rust version specified. Usage: $0 <rust-version>"
exit 1
fi
members=$(cargo metadata -q --no-deps --format-version 1 | jq -r '.packages[].manifest_path')

RUST_VERSION=$1

# Determine the directory containing the script
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")

# Path to the configuration file
CONFIG_FILE="$SCRIPT_DIR/msrv_config.json"

# Change to the root directory of the repository
cd "$SCRIPT_DIR/.."

echo "Current working directory: $(pwd)"

# function to check if specified toolchain is installed
check_rust_toolchain_installed() {
local version=$1
if ! rustup toolchain list | grep -q "$version"; then
echo "Rust toolchain $version is not installed. Please install it using 'rustup toolchain install $version'."
exit 1
fi
}

# check if specified toolchain is installed
check_rust_toolchain_installed "$RUST_VERSION"

# Extract the exact installed rust version string
installed_version=$(rustup toolchain list | grep "$RUST_VERSION" | awk '{print $1}')

# Read the configuration file and get the packages for the specified version
if [ -f "$CONFIG_FILE" ]; then
packages=$(jq -r --arg version "$RUST_VERSION" '.[$version] | .[]' "$CONFIG_FILE" | tr '\n' ' ')
if [ -z "$packages" ]; then
echo "No packages found for Rust version $RUST_VERSION in the configuration file."
exit 1
fi
else
echo "Configuration file $CONFIG_FILE not found."
exit 1
fi

# Check MSRV for the packages
for package in $packages; do
package=$(echo "$package" | tr -d '\r\n') # Remove any newline and carriage return characters
echo "Command: rustup run \"$installed_version\" cargo check --manifest-path=\"$package\" --all-features"
rustup run "$installed_version" cargo check --manifest-path=$package --all-features
for member in $members; do
echo "Verifying MSRV version for $member"
cargo msrv verify --manifest-path "$member" --output-format json
echo "" # just for nicer separation between packages
done
14 changes: 0 additions & 14 deletions scripts/msrv_config.json

This file was deleted.

10 changes: 0 additions & 10 deletions scripts/patch_dependencies.sh

This file was deleted.

Loading