Skip to content

Commit e7b073d

Browse files
Merge pull request #1240 from PowerGridModel/feature/reproducible-build
OpenSSF silver badge: reproducible build
2 parents 400a891 + 59a654d commit e7b073d

File tree

4 files changed

+386
-9
lines changed

4 files changed

+386
-9
lines changed

.github/workflows/build-test-release.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,9 @@ jobs:
118118
pgm-build-setup-ga-ci
119119
120120
- uses: ./.github/actions/enable-msvc
121-
if: runner.os == 'Windows'
122121

123122
- name: Build and test
124123
run: |
125-
# Resolve dirty PATH environment
126-
# TODO(mgovers): Remove after https://github.com/actions/runner-images/issues/10001 is resolved
127-
$env:PATH = ($env:PATH -split ';' | Where-Object { $_ -ne 'C:\Program Files\LLVM\bin' }) -join ';'
128-
129124
# generate cmake cache
130125
cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE }
131126
# build
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
name: Build and Test C++ and Python
6+
7+
# Controls when the workflow will run
8+
on:
9+
# run pipeline from another workflow
10+
workflow_call:
11+
# run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}-build-reproducibility
16+
cancel-in-progress: true
17+
18+
jobs:
19+
check-power-grid-model-c-linux:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
compiler: [gcc, clang]
24+
include:
25+
- c_compiler: gcc-14
26+
cxx_compiler: g++-14
27+
- c_compiler: clang-18
28+
cxx_compiler: clang++-18
29+
30+
env:
31+
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
32+
PRESET: ci-${{ matrix.compiler }}-reproducible
33+
HOMEBREW_FORCE_BREWED_CURL: 1
34+
35+
steps:
36+
- uses: actions/checkout@v6
37+
- name: Install packages
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y ninja-build gcc-14 g++-14 clang-18
41+
sudo ln -s /usr/bin/clang-18 /usr/local/bin/clang
42+
sudo ln -s /usr/bin/clang++-18 /usr/local/bin/clang++
43+
sudo ln -s /usr/bin/gcc-14 /usr/local/bin/gcc
44+
sudo ln -s /usr/bin/g++-14 /usr/local/bin/g++
45+
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v7
48+
49+
- name: Install pgm-build-dependencies
50+
run: |
51+
uv tool install https://github.com/PowerGridModel/pgm-build-dependencies/releases/latest/download/pgm_build_dependencies-0.1.0-py3-none-any.whl
52+
pgm-build-setup-ga-ci
53+
54+
- name: Build twice
55+
run: |
56+
cmake --preset ${{ env.PRESET }}
57+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1
58+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install
59+
mv install/${{ env.PRESET }} install/${{ env.PRESET }}-1
60+
mv cpp_build/ cpp_build_1/
61+
cmake --preset ${{ env.PRESET }}
62+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1
63+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install
64+
mv install/${{ env.PRESET }} install/${{ env.PRESET }}-2
65+
mv cpp_build/ cpp_build_2/
66+
67+
- name: Compare builds
68+
run: |
69+
diff -qr install/${{ env.PRESET }}-1 install/${{ env.PRESET }}-2
70+
if [ $? -ne 0 ]; then
71+
echo "Build mismatch detected"
72+
exit 1
73+
fi
74+
echo "Builds are identical"
75+
76+
check-reproducibility-c-windows:
77+
runs-on: windows-latest
78+
strategy:
79+
matrix:
80+
compiler: [msvc, clang-cl]
81+
82+
env:
83+
PRESET: ci-${{ matrix.compiler }}-reproducible
84+
85+
steps:
86+
- uses: actions/checkout@v6
87+
88+
- name: Install uv
89+
uses: astral-sh/setup-uv@v7
90+
91+
- name: Install pgm-build-dependencies
92+
run: |
93+
uv tool install https://github.com/PowerGridModel/pgm-build-dependencies/releases/latest/download/pgm_build_dependencies-0.1.0-py3-none-any.whl
94+
pgm-build-setup-ga-ci
95+
96+
- uses: ./.github/actions/enable-msvc
97+
98+
- name: Build twice
99+
run: |
100+
cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE }
101+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE }
102+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE }
103+
mv install/${{ env.PRESET }} install/${{ env.PRESET }}-1; if(!$?) { Exit $LASTEXITCODE }
104+
mv cpp_build/ cpp_build_1/; if(!$?) { Exit $LASTEXITCODE }
105+
cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE }
106+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE }
107+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE }
108+
mv install/${{ env.PRESET }} install/${{ env.PRESET }}-2; if(!$?) { Exit $LASTEXITCODE }
109+
mv cpp_build/ cpp_build_2/; if(!$?) { Exit $LASTEXITCODE }
110+
111+
- name: Compare builds
112+
run: |
113+
$hash1 = Get-ChildItem -Path install/${{ env.PRESET }}-1 -Recurse -File | Get-FileHash | Sort-Object Path
114+
$hash2 = Get-ChildItem -Path install/${{ env.PRESET }}-2 -Recurse -File | Get-FileHash | Sort-Object Path
115+
Compare-Object $hash1 $hash2 -Property Hash -PassThru -IncludeEqual | ForEach-Object {
116+
$currentPath = $_.Path
117+
118+
if ($_.SideIndicator -eq '==') {
119+
Write-Host "Files match: $currentPath"
120+
} else {
121+
Write-Error "Build mismatch detected: $currentPath";
122+
Exit 1
123+
}
124+
}
125+
if ($LASTEXITCODE -eq 1) { Exit 1 }
126+
Write-Host "Builds are identical"
127+
128+
check-reproducibility-c-macos:
129+
runs-on: macos-latest
130+
env:
131+
CMAKE_PREFIX_PATH: /usr/local
132+
PRESET: ci-apple-clang-reproducible
133+
134+
steps:
135+
- uses: actions/checkout@v6
136+
137+
- name: Set up XCode
138+
uses: maxim-lobanov/setup-xcode@v1
139+
with:
140+
xcode-version: latest-stable
141+
142+
- name: Install uv
143+
uses: astral-sh/setup-uv@v7
144+
145+
- name: Install pgm-build-dependencies
146+
run: |
147+
uv tool install https://github.com/PowerGridModel/pgm-build-dependencies/releases/latest/download/pgm_build_dependencies-0.1.0-py3-none-any.whl
148+
pgm-build-setup-ga-ci
149+
150+
- name: Build twice
151+
run: |
152+
cmake --preset ${{ env.PRESET }}
153+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1
154+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install
155+
mv install/${{ env.PRESET }} install/${{ env.PRESET }}-1
156+
mv cpp_build/ cpp_build_1
157+
cmake --preset ${{ env.PRESET }}
158+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1
159+
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install
160+
mv install/${{ env.PRESET }} install/${{ env.PRESET }}-2
161+
mv cpp_build/ cpp_build_2
162+
163+
- name: Compare builds
164+
run: |
165+
diff -qr install/${{ env.PRESET }}-1 install/${{ env.PRESET }}-2
166+
if [ $? -ne 0 ]; then
167+
echo "Build mismatch detected"
168+
exit 1
169+
fi
170+
echo "Builds are identical"

.github/workflows/nightly.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
with:
2323
create_release: false
2424

25+
check-build-reproducibility:
26+
uses: "./.github/workflows/check-build-reproducibility.yml"
27+
2528
check-code-quality:
2629
uses: "./.github/workflows/check-code-quality.yml"
2730

0 commit comments

Comments
 (0)