Skip to content

Commit 15fcbb9

Browse files
ci: Only run-tests if tests/demo/examples/core is modified (#210)
#### Relevant issue or PR #205 #### Description of changes Add filter to only `run-tests` if `tests` `demo` `examples` `tesseract-core` is modified #### Testing done This will be the test (if run-tests doesn't trigger) --------- Co-authored-by: Dion Häfner <dion.haefner@simulation.science>
1 parent 0b0aedc commit 15fcbb9

2 files changed

Lines changed: 53 additions & 16 deletions

File tree

.github/workflows/run_tests.yml

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,57 @@ jobs:
140140

141141
outputs:
142142
matrix: ${{ steps.get-matrix.outputs.matrix }}
143+
demos: ${{ steps.get-matrix.outputs.demos }}
143144

144145
steps:
145146
- name: Set up Git repository
146147
uses: actions/checkout@v4
147148

148-
- name: Get available unit Tesseracts
149+
- name: Get all changed files
150+
id: changed-files
151+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46
152+
with:
153+
files: |
154+
tesseract_core/**
155+
tests/endtoend_tests/**
156+
demo/**
157+
examples/**
158+
production.uv.lock
159+
.github/workflows/run_tests.yml
160+
161+
- name: Get available test matrix
149162
id: get-matrix
150163
env:
151-
E2E_TEST_DIR: examples
164+
EXAMPLES_DIR: examples
165+
DEMO_DIR: demo
152166
run: |
153-
# get JSON array of directories in E2E_TEST_DIR
167+
# if no changed files in the current PR, skip E2E tests
168+
if [[ "${{ steps.changed-files.outputs.any_changed }}" != "true" && ${{ github.event_name == 'pull_request' }} ]]; then
169+
echo "No changed files detected, skipping E2E tests."
170+
echo "matrix=[]" >> $GITHUB_OUTPUT
171+
echo "demos=[]" >> $GITHUB_OUTPUT
172+
exit 0
173+
fi
174+
# get JSON array of directories in EXAMPLES_DIR
154175
subjobs=$(
155-
find "${{ env.E2E_TEST_DIR }}" -type d -maxdepth 1 -mindepth 1 -exec basename {} \; \
176+
find "${{ env.EXAMPLES_DIR }}" -type d -maxdepth 1 -mindepth 1 -exec basename {} \; \
156177
| jq -R -s -c 'split("\n")[:-1]'
157178
)
158179
# add "base" to subjobs
159180
subjobs=$(echo "$subjobs" | jq -c -r '. + ["base"]')
160-
printf 'matrix=%s' "$subjobs" >> $GITHUB_OUTPUT
181+
printf 'matrix=%s\n' "$subjobs" >> $GITHUB_OUTPUT
182+
183+
# get JSON array of directories in DEMO_DIR
184+
demos=$(
185+
find "${{ env.DEMO_DIR }}" -type d -maxdepth 1 -mindepth 1 -exec basename {} \; \
186+
| jq -R -s -c 'split("\n")[:-1]'
187+
)
188+
printf 'demos=%s\n' "$demos" >> $GITHUB_OUTPUT
161189
162190
tests-e2e:
163-
needs: get-e2e-matrix
191+
needs: [get-e2e-matrix]
192+
193+
if: needs.get-e2e-matrix.outputs.matrix != '[]'
164194

165195
strategy:
166196
matrix:
@@ -184,17 +214,17 @@ jobs:
184214
arch: "arm"
185215
docker-engine: "docker"
186216
unit-tesseract: "base"
217+
- os: "ubuntu-24.04"
218+
python-version: "3.12"
219+
arch: "arm"
220+
docker-engine: "docker"
221+
unit-tesseract: "pyvista-arm64"
187222
# Run tests using Podman
188223
- os: "ubuntu-24.04"
189224
python-version: "3.12"
190225
arch: "x64"
191226
docker-engine: "podman"
192227
unit-tesseract: "base"
193-
- os: "ubuntu-24.04"
194-
python-version: "3.12"
195-
arch: "arm"
196-
docker-engine: "docker"
197-
unit-tesseract: "pyvista-arm64"
198228

199229
fail-fast: false
200230

@@ -216,6 +246,7 @@ jobs:
216246
with:
217247
auto-update-conda: true
218248
python-version: ${{ matrix.python-version }}
249+
channels: defaults
219250

220251
- name: Set up uv
221252
uses: astral-sh/setup-uv@v6
@@ -272,14 +303,17 @@ jobs:
272303
fail_ci_if_error: true
273304

274305
tests-demos:
306+
needs: [get-e2e-matrix]
307+
308+
if: needs.get-e2e-matrix.outputs.demos != '[]'
309+
275310
strategy:
276311
matrix:
277312
os: [ubuntu-latest]
278313
# test with oldest supported Python version only (for slow tests)
279314
python-version: ["3.10"]
280315

281-
demo:
282-
- data-assimilation-4dvar
316+
demo: ${{ fromJson(needs.get-e2e-matrix.outputs.demos) }}
283317

284318
fail-fast: false
285319

@@ -314,24 +348,25 @@ jobs:
314348
315349
316350
all-ok:
351+
if: always()
317352
needs: [tests-base, tests-e2e, tests-demos]
318353

319354
runs-on: ubuntu-latest
320355

321356
steps:
322357
- name: Check for errors
323358
run: |
324-
if [ "${{ needs.tests-base.result }}" != "success" ]; then
359+
if [[ "${{ needs.tests-base.result }}" != "success" && "${{ needs.tests-base.result }}" != "skipped" ]]; then
325360
echo "Base tests failed"
326361
exit 1
327362
fi
328363
329-
if [ "${{ needs.tests-e2e.result }}" != "success" ]; then
364+
if [[ "${{ needs.tests-e2e.result }}" != "success" && "${{ needs.tests-e2e.result }}" != "skipped" ]]; then
330365
echo "E2E tests failed"
331366
exit 1
332367
fi
333368
334-
if [ "${{ needs.tests-demos.result }}" != "success" ]; then
369+
if [[ "${{ needs.tests-demos.result }}" != "success" && "${{ needs.tests-demos.result }}" != "skipped" ]]; then
335370
echo "Demo tests failed"
336371
exit 1
337372
fi

.github/workflows/test_pip_install.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Test installation via pip
33
on:
44
# run on PRs for validation
55
pull_request:
6+
paths:
7+
- 'requirements.txt'
68

79

810
jobs:

0 commit comments

Comments
 (0)