Skip to content

ci: Only run-tests if tests/demo/examples/core is modified #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 51 additions & 16 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,57 @@ jobs:

outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
demos: ${{ steps.get-matrix.outputs.demos }}

steps:
- name: Set up Git repository
uses: actions/checkout@v4

- name: Get available unit Tesseracts
- name: Get all changed files
id: changed-files
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46
with:
files: |
tesseract_core/**
tests/endtoend_tests/**
demo/**
examples/**
production.uv.lock
.github/workflows/run_tests.yml

- name: Get available test matrix
id: get-matrix
env:
E2E_TEST_DIR: examples
EXAMPLES_DIR: examples
DEMO_DIR: demo
run: |
# get JSON array of directories in E2E_TEST_DIR
# if no changed files in the current PR, skip E2E tests
if [[ "${{ steps.changed-files.outputs.any_changed }}" != "true" && ${{ github.event_name == 'pull_request' }} ]]; then
echo "No changed files detected, skipping E2E tests."
echo "matrix=[]" >> $GITHUB_OUTPUT
echo "demos=[]" >> $GITHUB_OUTPUT
exit 0
fi
# get JSON array of directories in EXAMPLES_DIR
subjobs=$(
find "${{ env.E2E_TEST_DIR }}" -type d -maxdepth 1 -mindepth 1 -exec basename {} \; \
find "${{ env.EXAMPLES_DIR }}" -type d -maxdepth 1 -mindepth 1 -exec basename {} \; \
| jq -R -s -c 'split("\n")[:-1]'
)
# add "base" to subjobs
subjobs=$(echo "$subjobs" | jq -c -r '. + ["base"]')
printf 'matrix=%s' "$subjobs" >> $GITHUB_OUTPUT
printf 'matrix=%s\n' "$subjobs" >> $GITHUB_OUTPUT

# get JSON array of directories in DEMO_DIR
demos=$(
find "${{ env.DEMO_DIR }}" -type d -maxdepth 1 -mindepth 1 -exec basename {} \; \
| jq -R -s -c 'split("\n")[:-1]'
)
printf 'demos=%s\n' "$demos" >> $GITHUB_OUTPUT

tests-e2e:
needs: get-e2e-matrix
needs: [get-e2e-matrix]

if: needs.get-e2e-matrix.outputs.matrix != '[]'

strategy:
matrix:
Expand All @@ -184,17 +214,17 @@ jobs:
arch: "arm"
docker-engine: "docker"
unit-tesseract: "base"
- os: "ubuntu-24.04"
python-version: "3.12"
arch: "arm"
docker-engine: "docker"
unit-tesseract: "pyvista-arm64"
# Run tests using Podman
- os: "ubuntu-24.04"
python-version: "3.12"
arch: "x64"
docker-engine: "podman"
unit-tesseract: "base"
- os: "ubuntu-24.04"
python-version: "3.12"
arch: "arm"
docker-engine: "docker"
unit-tesseract: "pyvista-arm64"

fail-fast: false

Expand All @@ -216,6 +246,7 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: defaults

- name: Set up uv
uses: astral-sh/setup-uv@v6
Expand Down Expand Up @@ -272,14 +303,17 @@ jobs:
fail_ci_if_error: true

tests-demos:
needs: [get-e2e-matrix]

if: needs.get-e2e-matrix.outputs.demos != '[]'

strategy:
matrix:
os: [ubuntu-latest]
# test with oldest supported Python version only (for slow tests)
python-version: ["3.10"]

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

fail-fast: false

Expand Down Expand Up @@ -314,24 +348,25 @@ jobs:


all-ok:
if: always()
needs: [tests-base, tests-e2e, tests-demos]

runs-on: ubuntu-latest

steps:
- name: Check for errors
run: |
if [ "${{ needs.tests-base.result }}" != "success" ]; then
if [[ "${{ needs.tests-base.result }}" != "success" && "${{ needs.tests-base.result }}" != "skipped" ]]; then
echo "Base tests failed"
exit 1
fi

if [ "${{ needs.tests-e2e.result }}" != "success" ]; then
if [[ "${{ needs.tests-e2e.result }}" != "success" && "${{ needs.tests-e2e.result }}" != "skipped" ]]; then
echo "E2E tests failed"
exit 1
fi

if [ "${{ needs.tests-demos.result }}" != "success" ]; then
if [[ "${{ needs.tests-demos.result }}" != "success" && "${{ needs.tests-demos.result }}" != "skipped" ]]; then
echo "Demo tests failed"
exit 1
fi
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_pip_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Test installation via pip
on:
# run on PRs for validation
pull_request:
paths:
- 'requirements.txt'


jobs:
Expand Down
Loading