From 749340392262c698a8ec099525f38be8033367d9 Mon Sep 17 00:00:00 2001 From: gruebel Date: Fri, 16 May 2025 22:58:28 +0200 Subject: [PATCH] leverage fallback resolver for MSRV check --- .cargo/config.toml | 3 ++ .github/workflows/ci.yml | 30 +++++++++---------- scripts/msrv.sh | 55 ++++------------------------------- scripts/msrv_config.json | 14 --------- scripts/patch_dependencies.sh | 10 ------- 5 files changed, 23 insertions(+), 89 deletions(-) create mode 100644 .cargo/config.toml delete mode 100644 scripts/msrv_config.json delete mode 100755 scripts/patch_dependencies.sh diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000..18a3cb3183 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[resolver] +# https://doc.rust-lang.org/cargo/reference/config.html#resolverincompatible-rust-versions +incompatible-rust-versions = "fallback" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ffa891ae1..78c0d30151 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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) @@ -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: cargo-check-external-types@0.2.0 - name: external-type-check - run: | - cargo install cargo-check-external-types@0.1.13 - 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: @@ -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 diff --git a/scripts/msrv.sh b/scripts/msrv.sh index 30c080a33b..97537ad4b2 100755 --- a/scripts/msrv.sh +++ b/scripts/msrv.sh @@ -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 " - 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 diff --git a/scripts/msrv_config.json b/scripts/msrv_config.json deleted file mode 100644 index 05f9f5615c..0000000000 --- a/scripts/msrv_config.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "1.75.0": [ - "opentelemetry/Cargo.toml", - "opentelemetry-sdk/Cargo.toml", - "opentelemetry-stdout/Cargo.toml", - "opentelemetry-http/Cargo.toml", - "opentelemetry-jaeger-propagator/Cargo.toml", - "opentelemetry-zipkin/Cargo.toml", - "opentelemetry-appender-log/Cargo.toml", - "opentelemetry-appender-tracing/Cargo.toml", - "opentelemetry-otlp/Cargo.toml", - "opentelemetry-proto/Cargo.toml" - ] -} diff --git a/scripts/patch_dependencies.sh b/scripts/patch_dependencies.sh deleted file mode 100755 index 6a1e7de61b..0000000000 --- a/scripts/patch_dependencies.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -function patch_version() { - local latest_version=$(cargo search --limit 1 $1 | head -1 | cut -d'"' -f2) - echo "patching $1 from $latest_version to $2" - cargo update -p $1:$latest_version --precise $2 -} - -patch_version url 2.5.2 #https://github.com/servo/rust-url/issues/992 -patch_version native-tls 0.2.13 # 0.2.14 needs rustc v1.80