-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Explore adding a reproducibility test to rust test infrastructure. #139793
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
Open
biabbas
wants to merge
3
commits into
rust-lang:master
Choose a base branch
from
biabbas:reproducible
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+98
−0
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Workflow that runs after a merge to master, builds toolchain in 2 different | ||
# directories to check for reproducible builds. This check helps track which | ||
# commits cause reproducibility issues. This check should pass before stable | ||
# releases are made. | ||
|
||
name: Reproducibility check | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build_and_compare: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build and store toolchains | ||
run: | | ||
# Define build function | ||
build_toolchain() { | ||
local dir_name="$1" | ||
echo "Building in $dir_name..." | ||
|
||
mkdir "../$dir_name" | ||
cp -r . "../$dir_name/rust" | ||
pushd "../$dir_name" | ||
|
||
# Find source directory | ||
SOURCE_DIR="./rust" | ||
|
||
# Build rust till stage 2 | ||
$SOURCE_DIR/x.py build --stage 2 | ||
|
||
# Remove copy of source directory to save space | ||
rm -rf "$SOURCE_DIR" | ||
|
||
# Save stage2 directory | ||
STAGE2_DIR=$(find build -name stage2) | ||
cp -r "$STAGE2_DIR" . | ||
echo "Contents of stage2 dir in $dir_name: $(ls stage2)" | ||
|
||
# Clean up to save space | ||
rm -rf build | ||
popd | ||
} | ||
|
||
# Build both | ||
build_toolchain buildA | ||
build_toolchain buildA_extended | ||
|
||
# Compare the two builds | ||
- name: Compare builds | ||
id: compare | ||
run: | | ||
# Ensure the directories exist | ||
if [[ ! -d "../buildA" || ! -d "../buildA_extended" ]]; then | ||
echo "Error: Build directories not found!" | ||
exit 1 | ||
fi | ||
mv ../buildA ../buildA_extended . | ||
# Perform a recursive diff between the stage2 directories of both builds | ||
# If there are differences, record the result so we can upload artifacts and then fail later | ||
# The binaries should be identical, so the cause of difference should be analysed and fixed | ||
# appropriately. | ||
if diff -r buildA/stage2 buildA_extended/stage2; then | ||
echo "No differences found." | ||
echo "has_diff=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "Differences found!" | ||
echo "has_diff=true" >> $GITHUB_OUTPUT | ||
fi | ||
|
||
# Upload buildA and buildA_extended directories as an artifact (for debugging purposes) | ||
# The artifacts contain the stage2 folder from both builds. The artifact are | ||
# helpful to debug the reproducibility issue when this test fails. | ||
- name: Upload buildA artifact | ||
if: steps.compare.outputs.has_diff == 'true' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: buildA | ||
path: buildA | ||
|
||
- name: Upload buildA_extended artifact | ||
if: steps.compare.outputs.has_diff == 'true' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: buildA_extended | ||
path: buildA_extended | ||
|
||
# Fail the job if differences were found between the builds | ||
- name: Fail the job if there are differences | ||
if: steps.compare.outputs.has_diff == 'true' | ||
run: | | ||
echo "Differences found between buildA and buildA_extended, Reproducibility check failed" | ||
exit 1 |
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.