@@ -3,7 +3,7 @@ name: ladybug concurrent-writes CI
33# Produces:
44# - JSONL test results (one record per test case)
55# - Markdown test summary → GitHub Step Summary
6- # - Before/after benchmark JSON files
6+ # - Before/after benchmark JSON files (both built on the same ubuntu runner)
77# - Benchmark comparison → PR comment + GitHub Step Summary
88
99on :
@@ -20,7 +20,7 @@ concurrency:
2020 cancel-in-progress : true
2121
2222jobs :
23- # ─── Build ───────── ───────────────────────────────────────────────────────
23+ # ─── Build (branch) ───────────────────────────────────────────────────────
2424 build :
2525 name : Build (${{ matrix.os }})
2626 runs-on : ${{ matrix.os }}
6767 path : build/relwithdebinfo
6868 retention-days : 1
6969
70+ # ─── Build main (benchmark baseline) ─────────────────────────────────────
71+ # Runs in parallel with the branch build. The build output is cached across
72+ # workflow runs (main rarely changes) so this is typically ~1 min after the
73+ # first run.
74+ build-main :
75+ name : Build main (benchmark baseline)
76+ runs-on : ubuntu-latest
77+ if : github.event_name == 'pull_request' || github.ref == 'refs/heads/feat/concurrent-writes'
78+
79+ steps :
80+ - uses : actions/checkout@v4
81+ with :
82+ ref : main
83+
84+ - name : Install dependencies
85+ run : |
86+ sudo apt-get update -qq
87+ sudo apt-get install -y cmake ninja-build
88+
89+ - name : Cache CMake build (main)
90+ uses : actions/cache@v4
91+ with :
92+ path : build
93+ key : build-main-ubuntu-latest-${{ hashFiles('CMakeLists.txt', 'src/**/*.h') }}
94+ restore-keys : build-main-ubuntu-latest-
95+
96+ - name : Configure (CMake + Ninja)
97+ run : |
98+ cmake -B build/relwithdebinfo -G Ninja \
99+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
100+ -DBUILD_TESTS=TRUE \
101+ -DENABLE_BACKTRACES=TRUE \
102+ .
103+
104+ - name : Build
105+ run : cmake --build build/relwithdebinfo --parallel 4
106+
107+ - name : Upload main build
108+ uses : actions/upload-artifact@v4
109+ with :
110+ name : ladybug-main-build-ubuntu-latest
111+ path : build/relwithdebinfo
112+ retention-days : 1
113+
70114 # ─── Test ─────────────────────────────────────────────────────────────────
71115 test :
72116 name : Test (${{ matrix.os }})
@@ -132,50 +176,38 @@ jobs:
132176
133177 # ─── Benchmark ────────────────────────────────────────────────────────────
134178 #
135- # Produces a before/after comparison:
136- #
137- # baseline.json — captured on main (unpatched ladybug)
138- # committed to the repo; CI reads it if present
139- # branch-results.json — captured on this branch
140- # comparison.md — diff table posted as PR comment + Step Summary
141- #
142- # To capture a new baseline locally (e.g. after a significant ladybug update):
143- #
144- # git checkout main
145- # make relwithdebinfo # or: cmake ... && cmake --build ...
146- # python3 benchmarks/run_benchmarks.py \
147- # --build-dir build/relwithdebinfo \
148- # --dataset-dir dataset \
149- # --output benchmarks/baseline.json --label main
179+ # Both main and feat/concurrent-writes are built on the same ubuntu-latest
180+ # runner (in the build and build-main jobs above) so the comparison is
181+ # apples-to-apples regardless of local hardware.
150182 #
151- # # Also archive to results/ for posterity:
152- # cp benchmarks/baseline.json \
153- # benchmarks/results/main-$(git rev-parse --short HEAD)-$(date +%Y%m%d).json
154- #
155- # git add benchmarks/baseline.json benchmarks/results/ \
156- # && git commit -m "bench: capture baseline"
157- #
158- # # Generate a history report:
159- # python3 benchmarks/report.py --output benchmarks/results/report.md
183+ # The main build is heavily cached — after the first run it typically
184+ # restores in ~1 min. The branch build is downloaded as a pre-built artifact.
160185 #
161186 benchmark :
162187 name : Benchmark (ubuntu-latest)
163- needs : build
188+ needs : [ build, build-main]
164189 runs-on : ubuntu-latest
165190 if : github.event_name == 'pull_request' || github.ref == 'refs/heads/feat/concurrent-writes'
166191
167192 steps :
168193 - uses : actions/checkout@v4
169194
170- - name : Download build (ubuntu)
195+ - name : Download branch build (ubuntu)
171196 uses : actions/download-artifact@v4
172197 with :
173198 name : ladybug-build-ubuntu-latest
174199 path : build/relwithdebinfo
175200
201+ - name : Download main build (ubuntu)
202+ uses : actions/download-artifact@v4
203+ with :
204+ name : ladybug-main-build-ubuntu-latest
205+ path : build-main/relwithdebinfo
206+
176207 - name : Restore binary permissions
177208 run : |
178- find build/relwithdebinfo -type f | xargs chmod +x 2>/dev/null || true
209+ find build/relwithdebinfo -type f | xargs chmod +x 2>/dev/null || true
210+ find build-main/relwithdebinfo -type f | xargs chmod +x 2>/dev/null || true
179211
180212 - name : Fetch dataset (shallow)
181213 run : |
@@ -186,27 +218,32 @@ jobs:
186218 with :
187219 python-version : " 3.11"
188220
221+ - name : Benchmark main (in-runner baseline)
222+ run : |
223+ git fetch --depth=1 origin main
224+ MAIN_SHA=$(git rev-parse --short FETCH_HEAD)
225+ python3 benchmarks/run_benchmarks.py \
226+ --build-dir build-main/relwithdebinfo \
227+ --dataset-dir dataset \
228+ --output benchmarks/ci-baseline.json \
229+ --label "main (${MAIN_SHA})"
230+
189231 - name : Run benchmarks (branch)
190232 run : |
191233 python3 benchmarks/run_benchmarks.py \
192234 --build-dir build/relwithdebinfo \
193235 --dataset-dir dataset \
194236 --output benchmarks/branch-results.json \
195- --label "${{ github.head_ref || github.ref_name }}"
237+ --label "${{ github.head_ref || github.ref_name }} ($(git rev-parse --short HEAD)) "
196238
197- - name : Compare against baseline
239+ - name : Compare branch vs main (same runner)
198240 id : compare
199241 run : |
200- if [ -f benchmarks/baseline.json ]; then
201- python3 benchmarks/compare_benchmarks.py \
202- --baseline benchmarks/baseline.json \
203- --branch benchmarks/branch-results.json \
204- --output benchmarks/comparison.md
205- echo "has_baseline=true" >> "$GITHUB_OUTPUT"
206- else
207- python3 -c "open('benchmarks/comparison.md','w').write('## \u26a1 Concurrent-write benchmark comparison\n\n> **No baseline found.** To capture one, run on \`main\`:\n> \`\`\`\n> python3 benchmarks/run_benchmarks.py \\\\\n> --build-dir build/relwithdebinfo \\\\\n> --dataset-dir dataset \\\\\n> --output benchmarks/baseline.json --label main\n> \`\`\`\n> Then commit \`benchmarks/baseline.json\` to the repo.\n')"
208- echo "has_baseline=false" >> "$GITHUB_OUTPUT"
209- fi
242+ python3 benchmarks/compare_benchmarks.py \
243+ --baseline benchmarks/ci-baseline.json \
244+ --branch benchmarks/branch-results.json \
245+ --output benchmarks/comparison.md
246+ echo "has_baseline=true" >> "$GITHUB_OUTPUT"
210247
211248 - name : Write benchmark comparison to Step Summary
212249 run : cat benchmarks/comparison.md >> $GITHUB_STEP_SUMMARY
@@ -245,10 +282,9 @@ jobs:
245282 --output benchmarks/results/report.md 2>/dev/null || true
246283
247284 - name : Fail CI if regressions detected
248- if : steps.compare.outputs.has_baseline == 'true'
249285 run : |
250286 python3 benchmarks/compare_benchmarks.py \
251- --baseline benchmarks/baseline.json \
287+ --baseline benchmarks/ci- baseline.json \
252288 --branch benchmarks/branch-results.json
253289
254290 - name : Upload benchmark artifacts
@@ -257,6 +293,7 @@ jobs:
257293 with :
258294 name : benchmark-results
259295 path : |
296+ benchmarks/ci-baseline.json
260297 benchmarks/branch-results.json
261298 benchmarks/comparison.md
262299 benchmarks/results/
0 commit comments