From 2421286a6ba0d9bdd0041a16a4047415ef2f9aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 20 Nov 2026 07:56:40 +0100 Subject: [PATCH 1/2] Add CI job for running Cargo tests with the stable toolchain --- .../test-x86_64-cargo-stable/Dockerfile | 23 +++++++++++++++++++ src/ci/docker/scripts/cargo-stable-tests.sh | 13 +++++++++++ src/ci/github-actions/jobs.yml | 4 ++++ 3 files changed, 40 insertions(+) create mode 100644 src/ci/docker/host-x86_64/test-x86_64-cargo-stable/Dockerfile create mode 100644 src/ci/docker/scripts/cargo-stable-tests.sh diff --git a/src/ci/docker/host-x86_64/test-x86_64-cargo-stable/Dockerfile b/src/ci/docker/host-x86_64/test-x86_64-cargo-stable/Dockerfile new file mode 100644 index 0000000000000..851403382d67e --- /dev/null +++ b/src/ci/docker/host-x86_64/test-x86_64-cargo-stable/Dockerfile @@ -0,0 +1,23 @@ +FROM ubuntu:26.04 + +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python3 \ + git \ + cmake \ + libssl-dev \ + pkg-config \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + +COPY /scripts/cargo-stable-tests.sh /tmp/cargo-stable-tests.sh +ENV SCRIPT="bash /tmp/cargo-stable-tests.sh" diff --git a/src/ci/docker/scripts/cargo-stable-tests.sh b/src/ci/docker/scripts/cargo-stable-tests.sh new file mode 100644 index 0000000000000..faf9d2d6753e3 --- /dev/null +++ b/src/ci/docker/scripts/cargo-stable-tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Run Cargo tests using the stable Rust compiler + +TOOLCHAIN=stable + +rustup install --no-self-update "${TOOLCHAIN}" + +RUSTC=$(rustup +"${TOOLCHAIN}" which rustc) +RUSTDOC=$(rustup +"${TOOLCHAIN}" which rustdoc) + +# Run Cargo tests with the given toolchain +../x test cargo --set build.rustc="${RUSTC}" --set build.rustdoc="${RUSTDOC}" diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index ae32952b3653b..e4bb645b38ad4 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -397,6 +397,10 @@ auto: doc_url: https://rustc-dev-guide.rust-lang.org/tests/rust-for-linux.html <<: *job-linux-4c + # Runs Cargo tests with the stable compiler toolchain. + - name: test-x86_64-cargo-stable + <<: *job-linux-4c + - name: test-x86_64-gnu <<: *job-linux-4c From 6fbca12889710805014066437a9c81e6d5396a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Mon, 23 Nov 2026 15:18:00 +0100 Subject: [PATCH 2/2] Keep Rustup installed as an opt-in --- src/ci/citool/src/jobs.rs | 9 +++++++++ src/ci/docker/run.sh | 1 + src/ci/docker/scripts/cargo-stable-tests.sh | 11 ++++++----- src/ci/github-actions/jobs.yml | 1 + src/ci/scripts/run-build-from-ci.sh | 5 ++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/ci/citool/src/jobs.rs b/src/ci/citool/src/jobs.rs index b94f12a37cc77..526ff29d2cc2b 100644 --- a/src/ci/citool/src/jobs.rs +++ b/src/ci/citool/src/jobs.rs @@ -29,6 +29,9 @@ pub struct Job { pub free_disk: Option, /// Documentation link to a resource that could help people debug this CI job. pub doc_url: Option, + /// Keep rustup installed in the CI environment of this job. + /// Normally, rustup is uninstalled at the start of the job. + pub keep_rustup: Option, /// Whether the job is executed on AWS CodeBuild. pub codebuild: Option, /// Which Python version (if any) is required. On Windows, this is typically required to run @@ -170,6 +173,7 @@ fn validate_job_database(db: &JobDatabase) -> anyhow::Result<()> { only_on_channel, free_disk, doc_url, + keep_rustup, codebuild, required_python_version, @@ -184,6 +188,7 @@ fn validate_job_database(db: &JobDatabase) -> anyhow::Result<()> { && *free_disk == auto_job.free_disk && *doc_url == auto_job.doc_url && *codebuild == auto_job.codebuild + && *keep_rustup == auto_job.keep_rustup && *required_python_version == auto_job.required_python_version { Ok(()) @@ -360,6 +365,10 @@ fn calculate_jobs( env.extend(crate::yaml_map_to_json(&job.env)); let full_name = format!("{prefix} - {}", job.name); + if job.keep_rustup.unwrap_or(false) { + env.insert("KEEP_RUSTUP_INSTALLED".to_string(), "1".into()); + } + // When the default `@bors try` job is executed (which is usually done // for benchmarking performance, running crater or for downloading the // built toolchain using `rustup-toolchain-install-master`), diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 91ea72a68028f..625c60c6cd518 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -368,6 +368,7 @@ docker \ --env PR_CI_JOB \ --env OBJDIR_ON_HOST="$objdir" \ --env CODEGEN_BACKENDS \ + --env KEEP_RUSTUP_INSTALLED \ --env LLVM_VERSION \ --env DISABLE_CI_RUSTC_IF_INCOMPATIBLE="$DISABLE_CI_RUSTC_IF_INCOMPATIBLE" \ --init \ diff --git a/src/ci/docker/scripts/cargo-stable-tests.sh b/src/ci/docker/scripts/cargo-stable-tests.sh index faf9d2d6753e3..ad0ffd02279d9 100644 --- a/src/ci/docker/scripts/cargo-stable-tests.sh +++ b/src/ci/docker/scripts/cargo-stable-tests.sh @@ -1,13 +1,14 @@ #!/bin/bash +set -eux + # Run Cargo tests using the stable Rust compiler TOOLCHAIN=stable rustup install --no-self-update "${TOOLCHAIN}" -RUSTC=$(rustup +"${TOOLCHAIN}" which rustc) -RUSTDOC=$(rustup +"${TOOLCHAIN}" which rustdoc) - -# Run Cargo tests with the given toolchain -../x test cargo --set build.rustc="${RUSTC}" --set build.rustdoc="${RUSTDOC}" +# We run Cargo tests directly, because we need to override the compiler used by Cargo's tests +# to stable. That would be non-trivial with the way bootstrap is currently set up. +cd src/tools/cargo || exit 1 +cargo +${TOOLCHAIN} test --workspace --exclude benchsuite --exclude resolver-tests diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index e4bb645b38ad4..737e084354a48 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -399,6 +399,7 @@ auto: # Runs Cargo tests with the stable compiler toolchain. - name: test-x86_64-cargo-stable + keep_rustup: true <<: *job-linux-4c - name: test-x86_64-gnu diff --git a/src/ci/scripts/run-build-from-ci.sh b/src/ci/scripts/run-build-from-ci.sh index 55e75800d91c4..0d067959d5e42 100755 --- a/src/ci/scripts/run-build-from-ci.sh +++ b/src/ci/scripts/run-build-from-ci.sh @@ -15,7 +15,10 @@ echo "::add-matcher::src/ci/github-actions/problem_matchers.json" # Remove any preexisting rustup installation since it can interfere # with the cargotest step and its auto-detection of things like Clippy in # the environment -rustup self uninstall -y || true +if [[ "${KEEP_RUSTUP_INSTALLED-0}" -ne "1" ]]; then + rustup self uninstall -y || true +fi + if [ -z "${IMAGE+x}" ]; then src/ci/run.sh else