From 93d2e5b4ba9d9ec38b378e18e698e94589f06ec2 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Tue, 3 Oct 2023 21:03:32 -0400 Subject: [PATCH] Split MSRV in Two Parts (#4204) * Split MSRV in two parts * Use toml * Fix CI * Update names and cache hits for various jobs * Comment --- .github/workflows/ci.yml | 114 +++++++++++++++++++++---- .github/workflows/cts.yml | 7 +- Cargo.toml | 2 +- examples/timestamp-queries/src/main.rs | 2 +- rust-toolchain => rust-toolchain.toml | 2 +- wgpu-core/Cargo.toml | 6 ++ wgpu-hal/Cargo.toml | 2 +- wgpu-types/Cargo.toml | 6 ++ 8 files changed, 119 insertions(+), 22 deletions(-) rename rust-toolchain => rust-toolchain.toml (95%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 981fcd349..4e85c569d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,11 @@ env: CARGO_TERM_COLOR: always RUST_LOG: info RUST_BACKTRACE: full - MSRV: 1.65 + # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. + REPO_MSRV: "1.70" + # This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates, + # to ensure that they can be used with firefox. + CORE_MSRV: "1.65" PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work RUSTFLAGS: --cfg=web_sys_unstable_apis -D warnings RUSTDOCFLAGS: -Dwarnings @@ -32,7 +36,7 @@ env: # It adds overhead to the build and another point of failure. jobs: - check-msrv: + check: strategy: fail-fast: false matrix: @@ -95,10 +99,11 @@ jobs: - name: checkout repo uses: actions/checkout@v4 - - name: Install MSRV toolchain + - name: Install Repo MSRV toolchain run: | - rustup toolchain install ${{ env.MSRV }} --no-self-update --profile=minimal --component clippy --target ${{ matrix.target }} - rustup default ${{ env.MSRV }} + rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy --target ${{ matrix.target }} + rustup override set ${{ env.REPO_MSRV }} + cargo -V - name: disable debug shell: bash @@ -176,6 +181,64 @@ jobs: # build docs cargo doc --target ${{ matrix.target }} --all-features --no-deps + # We run minimal checks on the MSRV of the core crates, ensuring that + # its dependency tree does not cause issues for firefox. + # + # We don't test all platforms, just ones with different dependency stacks. + check-core-msrv: + strategy: + fail-fast: false + matrix: + include: + # Windows + - name: Windows x86_64 + os: windows-2022 + target: x86_64-pc-windows-msvc + + # MacOS + - name: MacOS x86_64 + os: macos-12 + target: x86_64-apple-darwin + + # Linux + - name: Linux x86_64 + os: ubuntu-22.04 + target: x86_64-unknown-linux-gnu + + name: MSRV Check ${{ matrix.name }} + runs-on: ${{ matrix.os }} + + steps: + - name: checkout repo + uses: actions/checkout@v4 + + - name: Install Core MSRV toolchain + run: | + rustup toolchain install ${{ env.CORE_MSRV }} --no-self-update --profile=minimal --component clippy --target ${{ matrix.target }} + rustup override set ${{ env.CORE_MSRV }} + cargo -V + + - name: disable debug + shell: bash + run: | + mkdir -p .cargo + echo """ + [profile.dev] + debug = false" >> .cargo/config.toml + + - name: caching + uses: Swatinem/rust-cache@v2 + with: + key: msrv-check-${{ matrix.target }}-${{ env.CACHE_SUFFIX }} + + - name: check native + shell: bash + run: | + set -e + + # check wgpu-core with all features. This will also get wgpu-hal and wgpu-types. + cargo check --target ${{ matrix.target }} --all-features -p wgpu-core + wasm-test: name: Test WebAssembly runs-on: ubuntu-latest @@ -183,6 +246,12 @@ jobs: - name: checkout repo uses: actions/checkout@v4 + - name: Install Repo MSRV toolchain + run: | + rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy --target wasm32-unknown-unknown + rustup override set ${{ env.REPO_MSRV }} + cargo -V + - name: Install wasm-pack uses: taiki-e/install-action@v2 with: @@ -213,7 +282,6 @@ jobs: os: ubuntu-22.04 backends: vulkan gl - name: Test ${{ matrix.name }} runs-on: ${{ matrix.os }} @@ -311,6 +379,12 @@ jobs: - name: checkout repo uses: actions/checkout@v4 + - name: Install Repo MSRV toolchain + run: | + rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component rustfmt + rustup override set ${{ env.REPO_MSRV }} + cargo -V + - name: disable debug shell: bash run: | @@ -322,7 +396,7 @@ jobs: - name: caching uses: Swatinem/rust-cache@v2 with: - key: clippy-${{ matrix.target }}-${{ matrix.kind }}-${{ env.CACHE_SUFFIX }} + key: doctests-${{ env.CACHE_SUFFIX }} - name: run doctests shell: bash @@ -338,11 +412,17 @@ jobs: - name: checkout repo uses: actions/checkout@v4 + - name: Install Repo MSRV toolchain + run: | + rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component rustfmt + rustup override set ${{ env.REPO_MSRV }} + cargo -V + - name: run rustfmt run: | cargo fmt -- --check - check-msrv-cts_runner: + check-cts-runner: name: Clippy cts_runner runs-on: ubuntu-latest steps: @@ -351,8 +431,9 @@ jobs: - name: Install MSRV toolchain run: | - rustup toolchain install ${{ env.MSRV }} --no-self-update --profile=minimal --component clippy - rustup default ${{ env.MSRV }} + rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy + rustup override set ${{ env.REPO_MSRV }} + cargo -V - name: disable debug shell: bash @@ -365,14 +446,17 @@ jobs: - name: caching uses: Swatinem/rust-cache@v2 with: - key: cts_runner-${{ env.CACHE_SUFFIX }} + key: cts-runner-${{ env.CACHE_SUFFIX }} - name: build Deno run: | cargo clippy --manifest-path cts_runner/Cargo.toml + # Separate job so that new advisories don't block CI. + # + # This job is not required to pass for PRs to be merged. cargo-deny-check-advisories: - name: "Run `cargo deny check advisories`" + name: "cargo-deny advisories" runs-on: ubuntu-latest steps: - name: checkout repo @@ -383,10 +467,10 @@ jobs: with: command: check advisories arguments: --all-features --workspace - rust-version: ${{ env.MSRV }} + rust-version: ${{ env.REPO_MSRV }} cargo-deny-check-rest: - name: "Run `cargo deny check`" + name: "cargo-deny" runs-on: ubuntu-latest steps: - name: checkout repo @@ -397,4 +481,4 @@ jobs: with: command: check bans licenses sources arguments: --all-features --workspace - rust-version: ${{ env.MSRV }} + rust-version: ${{ env.REPO_MSRV }} diff --git a/.github/workflows/cts.yml b/.github/workflows/cts.yml index e4bb20e7b..35ac5b60a 100644 --- a/.github/workflows/cts.yml +++ b/.github/workflows/cts.yml @@ -11,7 +11,7 @@ env: CARGO_INCREMENTAL: false CARGO_TERM_COLOR: always RUST_BACKTRACE: full - MSRV: 1.65 + MSRV: "1.70" jobs: cts: @@ -49,10 +49,11 @@ jobs: cd cts git checkout $(cat ../wgpu/cts_runner/revision.txt) - - name: Install MSRV toolchain + - name: Install Repo MSRV toolchain run: | rustup toolchain install ${{ env.MSRV }} --no-self-update --profile=minimal --target ${{ matrix.target }} - rustup default ${{ env.MSRV }} + rustup override set ${{ env.MSRV }} + cargo -V - name: caching uses: Swatinem/rust-cache@v2 diff --git a/Cargo.toml b/Cargo.toml index 6c7412d26..1f15a39be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ default-members = [ [workspace.package] edition = "2021" -rust-version = "1.65" +rust-version = "1.70" keywords = ["graphics"] license = "MIT OR Apache-2.0" homepage = "https://wgpu.rs/" diff --git a/examples/timestamp-queries/src/main.rs b/examples/timestamp-queries/src/main.rs index d463ea657..b3939e281 100644 --- a/examples/timestamp-queries/src/main.rs +++ b/examples/timestamp-queries/src/main.rs @@ -141,7 +141,7 @@ impl Queries { encoder.resolve_query_set( &self.set, // TODO(https://github.com/gfx-rs/wgpu/issues/3993): Musn't be larger than the number valid queries in the set. - 0..self.next_unused_query as u32, + 0..self.next_unused_query, &self.resolve_buffer, 0, ); diff --git a/rust-toolchain b/rust-toolchain.toml similarity index 95% rename from rust-toolchain rename to rust-toolchain.toml index 0f2697d74..03d64db16 100644 --- a/rust-toolchain +++ b/rust-toolchain.toml @@ -5,6 +5,6 @@ # to the user in the error, instead of "error: invalid channel name '[toolchain]'". [toolchain] -channel = "1.65" +channel = "1.70" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index aa1c053ed..6c0a3172d 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -9,6 +9,12 @@ repository = "https://github.com/gfx-rs/wgpu" keywords = ["graphics"] license = "MIT OR Apache-2.0" +# Override the workspace's `rust-version` key. Firefox uses `cargo vendor` to +# copy the crates it actually uses out of the workspace, so it's meaningful for +# them to have less restrictive MSRVs individually than the workspace as a +# whole, if their code permits. See `../README.md` for details. +rust-version = "1.65" + [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index c339c12aa..acc26e062 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.60" +rust-version = "1.65" [package.metadata.docs.rs] # Ideally we would enable all the features. diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index fd0abb0dc..2b6c35298 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -9,6 +9,12 @@ repository = "https://github.com/gfx-rs/wgpu" keywords = ["graphics"] license = "MIT OR Apache-2.0" +# Override the workspace's `rust-version` key. Firefox uses `cargo vendor` to +# copy the crates it actually uses out of the workspace, so it's meaningful for +# them to have less restrictive MSRVs individually than the workspace as a +# whole, if their code permits. See `../README.md` for details. +rust-version = "1.65" + [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"]