From ab3e8b0308cd45c8e21bebf2adb4e8a9c0dd59f5 Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Tue, 15 Apr 2025 13:41:23 +0530 Subject: [PATCH 1/4] Add reproducibility check --- .github/workflows/repro_check.yml | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/repro_check.yml diff --git a/.github/workflows/repro_check.yml b/.github/workflows/repro_check.yml new file mode 100644 index 0000000000000..6b3065ca489d9 --- /dev/null +++ b/.github/workflows/repro_check.yml @@ -0,0 +1,67 @@ +name: Build and Diff Projects + +on: + push: + branches: + - master + - reproducible + pull_request: + branches: + - master + - reproducible + +jobs: + build_and_compare: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' # Adjust to the version you need + + - name: Copy source files to two separate folders + run: | + # Copy source files into two separate folders + mkdir ../buildA ../buildA_extended + # Copy the repo contents into both + cp -r "$(pwd)" ../buildA + cp -r "$(pwd)" ../buildA_extended + + echo "Present Directory : `pwd`" + echo "work contents : `ls ..`" + + - name: Build source 1 + run: | + echo "Repo storage available: `df -h .`" + cd ../buildA + SOURCE_DIR=$(dirname $(find . -maxdepth 2 -name x.py)) + $SOURCE_DIR/configure --set rust.channel=nightly + $SOURCE_DIR/x.py build --stage 1 -j8 + + - name: Build source 2 + run: | + cd ../buildA_extended + SOURCE_DIR=$(dirname $(find . -maxdepth 2 -name x.py)) + $SOURCE_DIR/configure --set rust.channel=nightly + $SOURCE_DIR/x.py build --stage 1 -j8 + + - name: Compare builds using git diff + run: | + # Go back to the root directory + cd .. + + # Ensure the directories exist + if [[ ! -d "buildA" || ! -d "buildA_extended" ]]; then + echo "Error: Build directories not found!" + exit 1 + fi + + # Perform a diff between the two builds + buildA_stage1=`find buildA/build -name stage1` + buildA2_stage1=`find buildA_extended/build -name stage1` + diff -r $buildA_stage1/bin $buildA2_stage1/bin || echo "Differences found!" + From a09d499beb78da66c4c202911560b9a8e2ff92ec Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Tue, 15 Apr 2025 15:16:33 +0530 Subject: [PATCH 2/4] Remove unwanted files after build --- .github/workflows/repro_check.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/repro_check.yml b/.github/workflows/repro_check.yml index 6b3065ca489d9..e0ddaab43cf0d 100644 --- a/.github/workflows/repro_check.yml +++ b/.github/workflows/repro_check.yml @@ -34,20 +34,32 @@ jobs: echo "Present Directory : `pwd`" echo "work contents : `ls ..`" - - name: Build source 1 + - name: Build and store binaries from source 1 run: | echo "Repo storage available: `df -h .`" cd ../buildA SOURCE_DIR=$(dirname $(find . -maxdepth 2 -name x.py)) $SOURCE_DIR/configure --set rust.channel=nightly - $SOURCE_DIR/x.py build --stage 1 -j8 + $SOURCE_DIR/x.py build --stage 1 -j$(($(nproc)*2/3)) + rm -rf $SOURCE_DIR + STAGE1_DIR=`find build -name stage1` + cp -r "$STAGE1_DIR" . + echo "Contents stage 1 dir : `ls stage1`" + rm -rf build - - name: Build source 2 + - name: Build and store binaries from source 2 run: | cd ../buildA_extended + echo "Repo storage available: `df -h .`" SOURCE_DIR=$(dirname $(find . -maxdepth 2 -name x.py)) $SOURCE_DIR/configure --set rust.channel=nightly - $SOURCE_DIR/x.py build --stage 1 -j8 + $SOURCE_DIR/x.py build --stage 1 -j$(($(nproc)*2/3)) + rm -rf $SOURCE_DIR + STAGE1_DIR=`find build -name stage1` + cp -r "$STAGE1_DIR" . + echo "Contents stage 1 dir : `ls stage1`" + rm -rf build + cd .. - name: Compare builds using git diff run: | @@ -61,7 +73,4 @@ jobs: fi # Perform a diff between the two builds - buildA_stage1=`find buildA/build -name stage1` - buildA2_stage1=`find buildA_extended/build -name stage1` - diff -r $buildA_stage1/bin $buildA2_stage1/bin || echo "Differences found!" - + diff -r buildA/stage1 buildA_extended/stage1 || echo "Differences found!" From 46485be6584837888716a234723f386b1fb3f6c6 Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Thu, 17 Apr 2025 10:59:11 +0530 Subject: [PATCH 3/4] use diffscope to compare stage2 builds --- .github/workflows/repro_check.yml | 63 +++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/.github/workflows/repro_check.yml b/.github/workflows/repro_check.yml index e0ddaab43cf0d..f5d2a8018df9f 100644 --- a/.github/workflows/repro_check.yml +++ b/.github/workflows/repro_check.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - reproducible pull_request: branches: - master @@ -34,43 +33,69 @@ jobs: echo "Present Directory : `pwd`" echo "work contents : `ls ..`" - - name: Build and store binaries from source 1 + - name: Build and store buildA binaries run: | echo "Repo storage available: `df -h .`" - cd ../buildA + pushd ../buildA SOURCE_DIR=$(dirname $(find . -maxdepth 2 -name x.py)) $SOURCE_DIR/configure --set rust.channel=nightly - $SOURCE_DIR/x.py build --stage 1 -j$(($(nproc)*2/3)) + $SOURCE_DIR/x.py build --stage 2 -j$(($(nproc)*2/3)) rm -rf $SOURCE_DIR - STAGE1_DIR=`find build -name stage1` - cp -r "$STAGE1_DIR" . - echo "Contents stage 1 dir : `ls stage1`" + STAGE2_DIR=`find build -name stage2` + cp -r "$STAGE2_DIR" . + echo "Contents stage 2 dir : `ls stage2`" rm -rf build + popd - - name: Build and store binaries from source 2 + - name: Build and store buildA_extended binaries run: | - cd ../buildA_extended echo "Repo storage available: `df -h .`" + pushd ../buildA_extended SOURCE_DIR=$(dirname $(find . -maxdepth 2 -name x.py)) $SOURCE_DIR/configure --set rust.channel=nightly - $SOURCE_DIR/x.py build --stage 1 -j$(($(nproc)*2/3)) + $SOURCE_DIR/x.py build --stage 2 -j$(($(nproc)*2/3)) rm -rf $SOURCE_DIR - STAGE1_DIR=`find build -name stage1` - cp -r "$STAGE1_DIR" . - echo "Contents stage 1 dir : `ls stage1`" + STAGE2_DIR=`find build -name stage2` + cp -r "$STAGE2_DIR" . + echo "Contents stage 2 dir : `ls stage2`" rm -rf build - cd .. + popd - - name: Compare builds using git diff + - name: Install diffoscope run: | - # Go back to the root directory - cd .. + sudo apt-get update + sudo apt-get install -y diffoscope + - name: Compare builds + run: | # Ensure the directories exist - if [[ ! -d "buildA" || ! -d "buildA_extended" ]]; then + if [[ ! -d "../buildA" || ! -d "../buildA_extended" ]]; then echo "Error: Build directories not found!" exit 1 fi # Perform a diff between the two builds - diff -r buildA/stage1 buildA_extended/stage1 || echo "Differences found!" + diffoscope ../buildA/stage2 ../buildA_extended/stage2 > diffoscope_output.txt || echo "Differences found!" + + - name: Upload diffoscope output + uses: actions/upload-artifact@v4 + with: + name: diffoscope-report + path: diffoscope_output.txt + + - name: Archive buildA and buildA_extended + run: | + tar -czf buildA.tar.gz ../buildA + tar -czf buildA_extended.tar.gz ../buildA_extended + + - name: Upload buildA artifact + uses: actions/upload-artifact@v4 + with: + name: buildA + path: buildA.tar.gz + + - name: Upload buildA_extended artifact + uses: actions/upload-artifact@v4 + with: + name: buildA_extended + path: buildA_extended.tar.gz From 3b21dd6a21a7e0bc5ca993d833532359f96f7337 Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Fri, 18 Apr 2025 16:56:55 +0530 Subject: [PATCH 4/4] reduce number of steps --- .github/workflows/repro_check.yml | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/repro_check.yml b/.github/workflows/repro_check.yml index f5d2a8018df9f..337bf7c26a060 100644 --- a/.github/workflows/repro_check.yml +++ b/.github/workflows/repro_check.yml @@ -22,20 +22,10 @@ jobs: with: python-version: '3.x' # Adjust to the version you need - - name: Copy source files to two separate folders - run: | - # Copy source files into two separate folders - mkdir ../buildA ../buildA_extended - # Copy the repo contents into both - cp -r "$(pwd)" ../buildA - cp -r "$(pwd)" ../buildA_extended - - echo "Present Directory : `pwd`" - echo "work contents : `ls ..`" - - name: Build and store buildA binaries run: | - echo "Repo storage available: `df -h .`" + mkdir ../buildA + cp -r "$(pwd)" ../buildA pushd ../buildA SOURCE_DIR=$(dirname $(find . -maxdepth 2 -name x.py)) $SOURCE_DIR/configure --set rust.channel=nightly @@ -49,7 +39,8 @@ jobs: - name: Build and store buildA_extended binaries run: | - echo "Repo storage available: `df -h .`" + mkdir ../buildA_extended + cp -r "$(pwd)" ../buildA_extended pushd ../buildA_extended SOURCE_DIR=$(dirname $(find . -maxdepth 2 -name x.py)) $SOURCE_DIR/configure --set rust.channel=nightly @@ -61,13 +52,10 @@ jobs: rm -rf build popd - - name: Install diffoscope + - name: Compare builds and archive artifacts run: | sudo apt-get update sudo apt-get install -y diffoscope - - - name: Compare builds - run: | # Ensure the directories exist if [[ ! -d "../buildA" || ! -d "../buildA_extended" ]]; then echo "Error: Build directories not found!" @@ -77,17 +65,15 @@ jobs: # Perform a diff between the two builds diffoscope ../buildA/stage2 ../buildA_extended/stage2 > diffoscope_output.txt || echo "Differences found!" + tar -czf buildA.tar.gz ../buildA + tar -czf buildA_extended.tar.gz ../buildA_extended + - name: Upload diffoscope output uses: actions/upload-artifact@v4 with: name: diffoscope-report path: diffoscope_output.txt - - name: Archive buildA and buildA_extended - run: | - tar -czf buildA.tar.gz ../buildA - tar -czf buildA_extended.tar.gz ../buildA_extended - - name: Upload buildA artifact uses: actions/upload-artifact@v4 with: