Skip to content

Commit 8c41217

Browse files
committed
Fail the CodSpeed job when the runner is not main's baseline machine
1 parent 3cb22c4 commit 8c41217

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎.github/workflows/codspeed.yaml‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,16 @@ jobs:
7474
fi
7575
python3 scripts/codspeed-environment.py "${args[@]}" --github-output
7676
77+
# A run on another machine cannot be compared with main's baseline, so it
78+
# is not uploaded. Fail rather than skip, so a run that measured nothing
79+
# is not shown as green; re-running the job draws a new runner.
80+
- name: Require the machine main was measured on
81+
if: ${{ steps.environment.outputs.match == 'false' }}
82+
run: |
83+
echo "::error title=CodSpeed runner mismatch::This runner is not the machine main's baseline was measured on (or no baseline recording could be read), so the benchmarks were not run. Re-run this job to draw another runner."
84+
exit 1
85+
7786
- name: Restore cache
78-
if: ${{ steps.environment.outputs.match != 'false' }}
7987
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
8088
with:
8189
path: ${{ env.CACHE_PATHS }}
@@ -84,11 +92,9 @@ jobs:
8492
continue-on-error: true
8593

8694
- name: Install cargo-codspeed
87-
if: ${{ steps.environment.outputs.match != 'false' }}
8895
run: cargo install cargo-codspeed --locked --version ^5
8996

9097
- name: Build the benchmark targets
91-
if: ${{ steps.environment.outputs.match != 'false' }}
9298
run: cargo codspeed build --locked --measurement-mode simulation -p rustpython -p rustpython-sre_engine
9399

94100
- name: Save cache
@@ -100,7 +106,6 @@ jobs:
100106
continue-on-error: true
101107

102108
- name: Run the benchmarks
103-
if: ${{ steps.environment.outputs.match != 'false' }}
104109
uses: CodSpeedHQ/action@373d6868929f444bc08d901fd0eb0ad52a8875ea # v5.2.1
105110
with:
106111
mode: simulation

‎scripts/codspeed-environment.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
2424
The rule this enforces: `main` defines the environment. Every run on it records
2525
what it measured on, and a run on any other ref measures only when it matches
26-
that recording. Anything else is skipped rather than uploaded, because an
27-
uploaded cross-environment run is published as a regression of the branch that
28-
happened to draw the other machine. A recording that cannot be read is
29-
"anything else" too: an unknown machine is not a matching one, and reading it as
30-
one would leave the guard open exactly while it has nothing to check against.
26+
that recording. Anything else is not uploaded, and the workflow fails the job,
27+
because an uploaded cross-environment run is published as a regression of the
28+
branch that happened to draw the other machine. A recording that cannot be
29+
read is "anything else" too: an unknown machine is not a matching one, and
30+
reading it as one would leave the guard open exactly while it has nothing to
31+
check against.
3132
3233
codspeed-environment.py --record build/codspeed-environment.json
3334
codspeed-environment.py --record CURRENT --reference REFERENCE --github-output

0 commit comments

Comments
 (0)