Skip to content

Commit a82bc3f

Browse files
authored
Run hindcast tests only on change to hindcast module (#270)
* run hindcast only on change * always run hindcast on changes to master
1 parent 8db27f5 commit a82bc3f

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

.github/workflows/main.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,33 @@ on:
1010
- master
1111
- develop
1212
jobs:
13+
check-changes:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
wave_io_hindcast_changed: ${{ steps.changes.outputs.wave_io_hindcast }}
17+
should-run-hindcast: ${{ steps.hindcast-logic.outputs.should-run-hindcast }}
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
22+
- name: Check for changes in wave/io/hindcast
23+
id: changes
24+
uses: dorny/paths-filter@v2
25+
with:
26+
filters: |
27+
wave_io_hindcast:
28+
- 'mhkit/tests/wave/io/hindcast/**'
29+
30+
- id: hindcast-logic
31+
run: |
32+
if [[ "${{ github.event.pull_request.base.ref }}" == "master" || "${{ steps.changes.outputs.wave_io_hindcast }}" == "true" ]]; then
33+
echo "::set-output name=should-run-hindcast::true"
34+
else
35+
echo "::set-output name=should-run-hindcast::false"
36+
fi
37+
1338
prepare-cache:
39+
needs: [check-changes]
1440
runs-on: ubuntu-latest
1541
env:
1642
PYTHON_VER: 3.9
@@ -41,11 +67,16 @@ jobs:
4167
4268
- name: Prepare data
4369
run: |
44-
# pytest tests/test_specific_file.py::TestClass::test_function
4570
source activate TEST
4671
pytest mhkit/tests/river/test_io.py
4772
pytest mhkit/tests/tidal/test_io.py
4873
pytest mhkit/tests/wave/io/test_cdip.py
74+
75+
- name: Prepare Hindcast data
76+
if: (needs.check-changes.outputs.should-run-hindcast == 'true')
77+
run: |
78+
# pytest tests/test_specific_file.py::TestClass::test_function
79+
source activate TEST
4980
pytest mhkit/tests/wave/io/hindcast/test_hindcast.py
5081
pytest mhkit/tests/wave/io/hindcast/test_wind_toolkit.py
5182
@@ -158,7 +189,9 @@ jobs:
158189

159190
hindcast-calls:
160191
name: hindcast-${{ matrix.os }}/${{ matrix.python-version }}
161-
needs: [prepare-cache]
192+
needs: [check-changes, prepare-cache]
193+
if: (needs.check-changes.outputs.should-run-hindcast == 'true')
194+
162195
runs-on: ${{ matrix.os }}
163196
strategy:
164197
max-parallel: 1
@@ -211,6 +244,11 @@ jobs:
211244
coveralls:
212245
name: Indicate completion to coveralls.io
213246
needs: [conda-build, pip-build, hindcast-calls]
247+
if: |
248+
always() &&
249+
needs.conda-build.result == 'success' &&
250+
needs.pip-build.result == 'success' &&
251+
(needs.hindcast-calls.result == 'success' || needs.hindcast-calls.result == 'skipped')
214252
runs-on: ubuntu-latest
215253
container: python:3-slim
216254
steps:

0 commit comments

Comments
 (0)