Skip to content

Commit 031c5be

Browse files
Add CI workflow for flaky runs (#2618)
Co-authored-by: Erik van Sebille <e.vansebille@uu.nl>
1 parent aeb3d76 commit 031c5be

3 files changed

Lines changed: 62 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,66 @@ jobs:
126126
with:
127127
name: Unittest report ${{ matrix.os }}-${{ matrix.pixi-environment }}
128128
path: ${{ env.COVERAGE_REPORT }}
129+
flaky-unit-test:
130+
name: "Flaky unit tests: ${{ matrix.os }} | pixi run -e ${{ matrix.pixi-environment }} tests -m 'flaky'"
131+
runs-on: ${{ matrix.os }}-latest
132+
needs: [cache-pixi-lock]
133+
permissions:
134+
contents: read
135+
env:
136+
COVERAGE_REPORT: "${{ matrix.os }}_${{ matrix.pixi-environment }}_unit_test_report.html"
137+
strategy:
138+
fail-fast: false
139+
matrix:
140+
os: [ubuntu]
141+
pixi-environment: [test]
142+
steps:
143+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
144+
with:
145+
persist-credentials: false
146+
- name: Restore cached pixi lockfile
147+
uses: Parcels-code/pixi-lock/restore@38495788b79a5ff26009aecc15daa9a8310b8832 # v0.1.0
148+
with:
149+
cache-key: ${{ needs.cache-pixi-lock.outputs.cache-key }}
150+
- uses: prefix-dev/setup-pixi@fef5c9568ca6c4ff7707bf840ab0692ba3f08293 # v0.9.0
151+
with:
152+
pixi-version: ${{ needs.cache-pixi-lock.outputs.pixi-version }}
153+
locked: false # TODO: Remove once v7 of the lock file is removed, or once we stop having external source dependencies https://github.com/Parcels-code/Parcels/pull/2550#issuecomment-4088660238
154+
cache: true
155+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
156+
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
157+
- name: Restore cached hypothesis directory
158+
id: restore-hypothesis-cache
159+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
160+
with:
161+
path: .hypothesis/
162+
key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }}
163+
restore-keys: |
164+
cache-hypothesis-${{ runner.os }}-
165+
- name: Unit test
166+
id: unit-test
167+
run: |
168+
pixi run -e ${{ matrix.pixi-environment }} tests -m 'flaky' -v -s --cov=parcels --cov-report=xml --html="${COVERAGE_REPORT}" --self-contained-html
169+
# explicitly save the cache so it gets updated, also do this even if it fails.
170+
- name: Save cached hypothesis directory
171+
id: save-hypothesis-cache
172+
if: always() && steps.unit-test.outcome != 'skipped'
173+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
174+
with:
175+
path: .hypothesis/
176+
key: cache-hypothesis-${{ runner.os }}-${{ github.run_id }}
177+
- name: Codecov
178+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
179+
env:
180+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # zizmor: ignore[secrets-outside-env]
181+
with:
182+
flags: unit-tests
183+
- name: Upload test results
184+
if: ${{ always() }} # Always run this step, even if tests fail
185+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
186+
with:
187+
name: Flaky unittest report ${{ matrix.os }}-${{ matrix.pixi-environment }}
188+
path: ${{ env.COVERAGE_REPORT }}
129189
integration-test:
130190
name: "Integration: ${{ matrix.os }} | pixi run -e ${{ matrix.pixi-environment }} tests-notebooks"
131191
runs-on: ${{ matrix.os }}-latest

pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pytest-html = "*"
7777
pytest-cov = "*"
7878

7979
[feature.test.tasks]
80-
tests = { cmd = "pytest", description = "Run the test suite." }
80+
tests = { cmd = "pytest -m 'not flaky'", description = "Run the test suite." }
8181
tests-notebooks = { cmd = "pytest --nbval-lax docs/user_guide/examples", description = "Run the user guide example notebooks as tests." }
8282

8383

tests/datasets/test_remote.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def tmp_path_parcels_example_data(monkeypatch, tmp_path):
1111
return tmp_path
1212

1313

14+
@pytest.mark.flaky
1415
@pytest.mark.parametrize("url", [remote._ODIE.get_url(filename) for filename in remote._ODIE.registry.keys()])
1516
def test_pooch_registry_url_reponse(url):
1617
response = requests.head(url)

0 commit comments

Comments
 (0)