Skip to content

Commit fb3bba6

Browse files
authored
Merge pull request #321 from CCPBioSim/320-feature-automate-regression-baseline
Add CI workflow for updating regression test baselines
2 parents 5687d4e + 71169b1 commit fb3bba6

2 files changed

Lines changed: 80 additions & 3 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Update Regression Baselines
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: update-regression-baselines-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
update-baselines:
15+
name: Update regression baselines
16+
runs-on: ubuntu-24.04
17+
timeout-minutes: 30
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
22+
with:
23+
ref: ${{ github.ref }}
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
27+
with:
28+
python-version: "3.14"
29+
cache: pip
30+
31+
- name: Install testing dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
python -m pip install -e .[testing]
35+
36+
- name: Update regression baselines
37+
run: pytest tests/regression --update-baselines
38+
39+
- name: Commit updated baselines
40+
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6
41+
with:
42+
commit_message: "test(regression): update baselines"
43+
commit_user_name: github-actions[bot]
44+
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com

docs/developer_guide.rst

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,46 @@ Run tests with coverage::
6060

6161
pytest --cov CodeEntropy --cov-report=term-missing
6262

63-
Update regression baselines::
63+
Run a specific test::
64+
65+
pytest tests/unit/.../test_file.py::test_function
66+
67+
Updating Regression Baselines
68+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69+
70+
Regression baselines should only be updated when a change intentionally alters
71+
the expected numerical output of CodeEntropy. Do not update baselines simply
72+
because a regression test fails.
73+
74+
Before updating baselines, confirm that:
75+
76+
- The code change is intentional and understood.
77+
- The new output has been reviewed.
78+
- The regression difference is expected.
79+
- The pull request explains why the baselines changed.
80+
81+
For local updates, run::
6482

6583
pytest tests/regression --update-baselines
6684

67-
Run a specific test::
85+
For pull requests, baselines can also be updated using the GitHub Actions
86+
workflow **Update Regression Baselines**.
6887

69-
pytest tests/unit/.../test_file.py::test_function
88+
To use it:
89+
90+
1. Push your changes to your PR branch.
91+
2. Open the **Actions** tab on GitHub.
92+
3. Select **Update Regression Baselines**.
93+
4. Click **Run workflow**.
94+
5. Select your PR branch.
95+
6. Run the workflow.
96+
97+
The workflow runs the regression tests with ``--update-baselines`` and commits
98+
any changed baseline files back to the selected branch.
99+
100+
Only use this workflow when the baseline changes are intentional. If a regression
101+
test fails unexpectedly, investigate the failure instead of updating the
102+
baseline.
70103

71104
Regression Test Data
72105
--------------------

0 commit comments

Comments
 (0)