-
Notifications
You must be signed in to change notification settings - Fork 51
OpenSSF silver badge: reproducible build #1240
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
32 commits
Select commit
Hold shift + click to select a range
113d993
cmake reproducible builds
mgovers 0f432fb
reproducible builds + workflow
mgovers c916bf0
add reproducible build to github actions
mgovers 23b76e9
rename steps
mgovers 4914dc9
gcc reproducibility
mgovers f851552
fix preset
mgovers 8f39a2e
fix typo
mgovers db86996
fix typo
mgovers b0b4094
fix correct gcc version
mgovers 374754d
fix msvc conda prefix
mgovers 8ca8a35
clean up build dir
mgovers 623452f
remove unused
mgovers 6642d0a
fix typo
mgovers 6b382cf
msvc reproducible
mgovers 24443ed
attempt force msvc deterministic
mgovers 2bcee2c
also force clang-cl deterministic
mgovers 2ff99f4
remove unknown flags clang-cl
mgovers f32f85f
random seed and datetime apparently not added to compiler arguments
mgovers 6793efd
Merge branch 'main' into feature/reproducible-build
mgovers 2ce7832
disable other workflows except for reproducibility
mgovers 12a7fc4
reproducible build windows
mgovers 09d6416
fix script for linux
mgovers 1da6be5
test script for macos
mgovers ae9e722
fix typo
mgovers 6604d4f
restore CI; reproducible build in nightly
mgovers c7156f8
resolve some (not all) comments
mgovers 07770e1
remove redundant if: runner.os == 'windows'
mgovers aafc5ae
apple clang preset
mgovers 7c55026
add forgotten build preset
mgovers df67e5e
cmake shared linker flags
mgovers a75da94
reverse + reproducibility
mgovers 59a654d
typo
mgovers 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| # SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]> | ||
| # | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| name: Build and Test C++ and Python | ||
|
|
||
| # Controls when the workflow will run | ||
| on: | ||
| # run pipeline from another workflow | ||
| workflow_call: | ||
| # run this workflow manually from the Actions tab | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-build-reproducibility | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| check-power-grid-model-c-linux: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| compiler: [gcc, clang] | ||
| include: | ||
| - c_compiler: gcc-14 | ||
| cxx_compiler: g++-14 | ||
| - c_compiler: clang-18 | ||
| cxx_compiler: clang++-18 | ||
|
|
||
| env: | ||
| CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew | ||
| PRESET: ci-${{ matrix.compiler }}-reproducible | ||
| HOMEBREW_FORCE_BREWED_CURL: 1 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Install packages | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y ninja-build gcc-14 g++-14 clang-18 | ||
| sudo ln -s /usr/bin/clang-18 /usr/local/bin/clang | ||
| sudo ln -s /usr/bin/clang++-18 /usr/local/bin/clang++ | ||
| sudo ln -s /usr/bin/gcc-14 /usr/local/bin/gcc | ||
| sudo ln -s /usr/bin/g++-14 /usr/local/bin/g++ | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
|
|
||
| - name: Install pgm-build-dependencies | ||
| run: | | ||
| uv tool install https://github.com/PowerGridModel/pgm-build-dependencies/releases/latest/download/pgm_build_dependencies-0.1.0-py3-none-any.whl | ||
| pgm-build-setup-ga-ci | ||
|
|
||
| - name: Build twice | ||
| run: | | ||
| cmake --preset ${{ env.PRESET }} | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install | ||
| mv install/${{ env.PRESET }} install/${{ env.PRESET }}-1 | ||
| mv cpp_build/ cpp_build_1/ | ||
| cmake --preset ${{ env.PRESET }} | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install | ||
| mv install/${{ env.PRESET }} install/${{ env.PRESET }}-2 | ||
| mv cpp_build/ cpp_build_2/ | ||
|
|
||
| - name: Compare builds | ||
| run: | | ||
| diff -qr install/${{ env.PRESET }}-1 install/${{ env.PRESET }}-2 | ||
| if [ $? -ne 0 ]; then | ||
| echo "Build mismatch detected" | ||
| exit 1 | ||
| fi | ||
| echo "Builds are identical" | ||
|
|
||
| check-reproducibility-c-windows: | ||
| runs-on: windows-latest | ||
| strategy: | ||
| matrix: | ||
| compiler: [msvc, clang-cl] | ||
TonyXiang8787 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| env: | ||
| PRESET: ci-${{ matrix.compiler }}-reproducible | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
|
|
||
| - name: Install pgm-build-dependencies | ||
| run: | | ||
| uv tool install https://github.com/PowerGridModel/pgm-build-dependencies/releases/latest/download/pgm_build_dependencies-0.1.0-py3-none-any.whl | ||
| pgm-build-setup-ga-ci | ||
|
|
||
| - uses: ./.github/actions/enable-msvc | ||
|
|
||
| - name: Build twice | ||
| run: | | ||
| cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE } | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE } | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE } | ||
| mv install/${{ env.PRESET }} install/${{ env.PRESET }}-1; if(!$?) { Exit $LASTEXITCODE } | ||
| mv cpp_build/ cpp_build_1/; if(!$?) { Exit $LASTEXITCODE } | ||
| cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE } | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE } | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE } | ||
| mv install/${{ env.PRESET }} install/${{ env.PRESET }}-2; if(!$?) { Exit $LASTEXITCODE } | ||
| mv cpp_build/ cpp_build_2/; if(!$?) { Exit $LASTEXITCODE } | ||
|
|
||
| - name: Compare builds | ||
| run: | | ||
| $hash1 = Get-ChildItem -Path install/${{ env.PRESET }}-1 -Recurse -File | Get-FileHash | Sort-Object Path | ||
| $hash2 = Get-ChildItem -Path install/${{ env.PRESET }}-2 -Recurse -File | Get-FileHash | Sort-Object Path | ||
| Compare-Object $hash1 $hash2 -Property Hash -PassThru -IncludeEqual | ForEach-Object { | ||
| $currentPath = $_.Path | ||
|
|
||
| if ($_.SideIndicator -eq '==') { | ||
| Write-Host "Files match: $currentPath" | ||
| } else { | ||
| Write-Error "Build mismatch detected: $currentPath"; | ||
| Exit 1 | ||
| } | ||
| } | ||
| if ($LASTEXITCODE -eq 1) { Exit 1 } | ||
| Write-Host "Builds are identical" | ||
|
|
||
| check-reproducibility-c-macos: | ||
| runs-on: macos-latest | ||
| env: | ||
| CMAKE_PREFIX_PATH: /usr/local | ||
| PRESET: ci-apple-clang-reproducible | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up XCode | ||
| uses: maxim-lobanov/setup-xcode@v1 | ||
| with: | ||
| xcode-version: latest-stable | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
|
|
||
| - name: Install pgm-build-dependencies | ||
| run: | | ||
| uv tool install https://github.com/PowerGridModel/pgm-build-dependencies/releases/latest/download/pgm_build_dependencies-0.1.0-py3-none-any.whl | ||
| pgm-build-setup-ga-ci | ||
|
|
||
| - name: Build twice | ||
| run: | | ||
| cmake --preset ${{ env.PRESET }} | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install | ||
| mv install/${{ env.PRESET }} install/${{ env.PRESET }}-1 | ||
| mv cpp_build/ cpp_build_1 | ||
| cmake --preset ${{ env.PRESET }} | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 | ||
| cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install | ||
| mv install/${{ env.PRESET }} install/${{ env.PRESET }}-2 | ||
| mv cpp_build/ cpp_build_2 | ||
|
|
||
| - name: Compare builds | ||
| run: | | ||
| diff -qr install/${{ env.PRESET }}-1 install/${{ env.PRESET }}-2 | ||
| if [ $? -ne 0 ]; then | ||
| echo "Build mismatch detected" | ||
| exit 1 | ||
| fi | ||
| echo "Builds are identical" | ||
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
Oops, something went wrong.
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.