From 2f0192e97f3f8adf2c887e72757c4170226fd1b8 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Tue, 27 May 2025 19:32:36 +0800 Subject: [PATCH] CI: Check MSRV in CI As previously proposed on zulip and discussed in the coordination meeting, add a check to CI to see if servo still compiles with our minimum supported Rust version. To avoid requiring changes, we define our MSRV as the current version we are using now. This does not prevent us from updating the default compiler version, which we should still do, to get benefits like faster compile times, newer lints and making sure crown stays up-to-date. We simply test that libservo compiles in CI on Linux, since libservo (and dependencies) is what embedders would care about. We also don't need mach for this, so we just use cargo build. Signed-off-by: Jonathan Schwender --- .github/workflows/lint.yml | 39 +++++++++++++++++++++++++++++++++++++- Cargo.toml | 5 +++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 375a997b13d..84f3482cf7f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -43,9 +43,46 @@ jobs: run: | sudo apt update ./mach bootstrap - # TODO: Do GitHub anotaions + # TODO: Do GitHub annotations - name: Clippy run: | ./mach clippy --use-crown --locked -- -- --deny warnings - name: Tidy run: ./mach test-tidy --no-progress --all + + msrv_check: + name: Minimum supported Rust version check + runs-on: ubuntu-22.04 + env: + # This version should be kept in sync with the `rust-version` in our + # workspace Cargo.toml. Changes should be discussed on zulip. + MINIMUM_SUPPORTED_RUST_VERSION: "1.85.0" + steps: + - uses: actions/checkout@v4 + if: github.event_name != 'pull_request_target' + with: + fetch-depth: 1 + # This is necessary to checkout the pull request if this run was triggered via a + # `pull_request_target` event. + - uses: actions/checkout@v4 + if: github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 1 + - name: Set LIBCLANG_PATH env # needed for bindgen in mozangle + run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV + - name: Setup Python + if: ${{ runner.environment != 'self-hosted' }} + uses: ./.github/actions/setup-python + - name: Bootstrap dependencies + if: ${{ runner.environment != 'self-hosted' }} + run: | + sudo apt update + ./mach bootstrap --skip-lints + - name: Install MSRV + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${MINIMUM_SUPPORTED_RUST_VERSION} + - name: Compile libservo with MSRV + run: | + cargo +${MINIMUM_SUPPORTED_RUST_VERSION} build -p libservo --locked diff --git a/Cargo.toml b/Cargo.toml index 1373440d67e..78ac8b597ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,11 @@ authors = ["The Servo Project Developers"] license = "MPL-2.0" edition = "2024" publish = false +# We have yet to decide on a policy for updating the minimum supported rust version. +# Before increasing this, please open a discussion on zulip explaining the reason +# why we should consider increasing our minimum supported rust version. +# Please also note, that the **default** rust version in rust-toolchain.toml may be +# bumped freely. rust-version = "1.85.0" [workspace.dependencies]