-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Add CI job for checking stdlib semver compatibility #160253
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1cdee12
Allow specifying the baseline commit for stdlib semver check
Kobzol 4774caa
Handle non-fatal errors from cargo-semver-checks
Kobzol f6f7f3b
Add CI job for checking stdlib semver compatibility
Kobzol 4ba53b5
Use sccache to speed up compilation of cargo-semver-checks
Kobzol 1ae00c8
Add a mechanism to skip running stdlib semver check
Kobzol 732127e
Speed up compilation of cargo-semver-checks
Kobzol ac88fca
Add documentation about the stdlib semver check job to RDG and add `d…
Kobzol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Change this file to explicitly acknowledge making a breaking change to the Rust standard library. | ||
| If this file is modified in the same PR as the breaking change, then CI will not fail due to the | ||
| breaking change being detected by cargo-semver-checks. | ||
|
|
||
| Last change is for: https://github.com/rust-lang/rust/pull/160253 |
31 changes: 31 additions & 0 deletions
31
src/ci/docker/host-x86_64/x86_64-gnu-stdlib-semver-check/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| FROM ubuntu:26.04 | ||
|
|
||
| ARG DEBIAN_FRONTEND=noninteractive | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| g++ \ | ||
| make \ | ||
| ninja-build \ | ||
| file \ | ||
| curl \ | ||
| ca-certificates \ | ||
| python3 \ | ||
| git \ | ||
| cmake \ | ||
| sudo \ | ||
| gdb \ | ||
| libssl-dev \ | ||
| pkg-config \ | ||
| xz-utils \ | ||
| mingw-w64 \ | ||
| zlib1g-dev \ | ||
| libzstd-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY scripts/sccache.sh /scripts/ | ||
| RUN sh /scripts/sccache.sh | ||
|
|
||
| ENV RUST_CONFIGURE_ARGS="--build=x86_64-unknown-linux-gnu" | ||
| ENV RUSTC_WRAPPER=/usr/local/bin/sccache | ||
|
|
||
| COPY /scripts/std-semver-check.sh /tmp/std-semver-check.sh | ||
| ENV SCRIPT="bash /tmp/std-semver-check.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| BUILD_DIR=$(realpath ./build/x86_64-unknown-linux-gnu) | ||
|
|
||
| # Install the latest version of cargo-semver-checks, so that once the JSON doc format changes, | ||
| # we will eventually get a csc version that supports it | ||
| # Speed up compilation by reducing optimizations settings a bit | ||
| RUSTC="${BUILD_DIR}"/stage0/bin/rustc \ | ||
| CARGO_PROFILE_RELEASE_LTO=false \ | ||
| CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16 \ | ||
| "${BUILD_DIR}"/stage0/bin/cargo install cargo-semver-checks --locked | ||
|
|
||
| # Provide path to cargo-semver-checks | ||
| export PATH=${PATH}:/cargo/bin | ||
|
|
||
| # Explicitly compute the baseline commit (the first git parent, which is the latest upstream main | ||
| # commit), so that it is shown in the commit log and so that the command can be easily reproduced | ||
| # locally. | ||
| PARENT=$(git rev-parse HEAD^1) | ||
|
|
||
| # Run the test | ||
| python3 ../x.py test std-semver-check --set rust.stdlib-semver-baseline=${PARENT} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Standard library semantic versioning breakage check | ||
|
|
||
| The `x86_64-gnu-stdlib-semver-check` job runs the [`cargo-semver-checks`][csc] (c-s-c) tool on the standard library (`core`, `alloc` and `std`) in order to find potential unintended semantic versioning (semver) breakages. It does so by analyzing the rustdoc JSON output (from the `rust-docs-json` component) of the parent merge commit, and the current commit being merged. When it runs, one of five things can happen: | ||
|
|
||
| 1. Everything proceeds correctly, c-s-c does not find any breakage. | ||
| 2. The rustdoc JSON version was bumped recently, and c-s-c cannot handle it yet. This case will result in the test ending with a success, and printing a warning that c-s-c needs to be updated. Once c-s-c releases a version that supports the new JSON format, it should go to 1. again. | ||
| - We currently install the latest released version of c-s-c in this job, so its version does not need to be updated manually in the `rust-lang/rust` repository. | ||
| 3. c-s-c detects a breakage, but it is a false positive. In this case, please report the false positive to [this][semver-topic] Zulip channel, and [bump the stamp file](#bumping-the-stdlib-semver-stamp-file). | ||
| 4. c-s-c detects a real breakage, and it helped you find unintended beakage. Yay! In this case, please consider reporting the success to [this][semver-topic] Zulip channel. | ||
| 5. c-s-c detects a real breakage, but you want to land it anyway (maybe it is an edge case that was FCPed). In that case, [bump the stamp file](#bumping-the-stdlib-semver-stamp-file). | ||
|
|
||
| ## Bumping the stdlib semver stamp file | ||
|
|
||
| If you want to let CI pass on a PR where c-s-c detects breakage (whether it is real or not), you have to modify the `src/bootstrap/stdlib-semver-check-stamp` file. Please update the PR number in which you modify this file at the bottom of the file. This will ensure that the test will stay green, regardless of what c-s-c detects. | ||
|
|
||
| ## Running the check manually | ||
|
|
||
| You can manually run the semver check locally using `./x test std-semver-check --set rust.stdlib-semver-baseline=${PARENT}`, where `PARENT` is a commit SHA against which you want to compare the in-tree stdlib. If you do not specify it, bootstrap will select the latest upstream commit that it finds in your local git history. | ||
|
|
||
| [semver-topic]: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Breakages.20detected.20by.20cargo-semver-checks/with/615570111 | ||
| [csc]: https://github.com/obi1kenobi/cargo-semver-checks |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.