From e2436ac1b1f32163433638c62c105d122e9e8d15 Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Thu, 27 Mar 2025 20:10:23 +0000 Subject: [PATCH 1/7] Specific import for test_spring --- test/test_spring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_spring.py b/test/test_spring.py index d0dce19..b52543a 100644 --- a/test/test_spring.py +++ b/test/test_spring.py @@ -7,7 +7,7 @@ from firedrake.functionspace import VectorFunctionSpace from firedrake.utility_meshes import UnitSquareMesh, UnitTriangleMesh -from movement import SpringMover +from movement.spring import SpringMover class TestExceptions(unittest.TestCase): From d29ff382178281fba7d2716b69daa9b2cbddef7f Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Thu, 27 Mar 2025 20:11:15 +0000 Subject: [PATCH 2/7] Specific import for laplacian_smoothing --- test/test_laplacian_smoothing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_laplacian_smoothing.py b/test/test_laplacian_smoothing.py index af5c3f0..abd9415 100644 --- a/test/test_laplacian_smoothing.py +++ b/test/test_laplacian_smoothing.py @@ -3,7 +3,7 @@ from firedrake.utility_meshes import UnitSquareMesh -from movement import LaplacianSmoother +from movement.laplacian_smoothing import LaplacianSmoother class TestExceptions(unittest.TestCase): From e2a1659536f59bd5fbdfa1cac7743f72758fb702 Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Thu, 27 Mar 2025 20:13:08 +0000 Subject: [PATCH 3/7] Specific imports for test_forced_movement --- test/test_forced_movement.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_forced_movement.py b/test/test_forced_movement.py index a24e9dc..354a592 100644 --- a/test/test_forced_movement.py +++ b/test/test_forced_movement.py @@ -8,7 +8,8 @@ from firedrake.mesh import Mesh from firedrake.utility_meshes import RectangleMesh, UnitSquareMesh, UnitTriangleMesh -from movement import LaplacianSmoother, SpringMover +from movement.laplacian_smoothing import LaplacianSmoother +from movement.spring import SpringMover class BaseClasses: From d1e81e04c6df01fdf9823d53b1fd117ac25148ad Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Thu, 27 Mar 2025 20:22:25 +0000 Subject: [PATCH 4/7] Modular workflow handling --- .github/workflows/test_core.yml | 57 +++++++++++++++++++ .github/workflows/test_coverage.yml | 10 ++++ .github/workflows/test_demos.yml | 51 +++++++++++++++++ .../workflows/test_laplacian_smoothing.yml | 54 ++++++++++++++++++ .github/workflows/test_monge_ampere.yml | 53 +++++++++++++++++ .github/workflows/test_spring.yml | 54 ++++++++++++++++++ .github/workflows/test_suite.yml | 28 --------- 7 files changed, 279 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/test_core.yml create mode 100644 .github/workflows/test_coverage.yml create mode 100644 .github/workflows/test_demos.yml create mode 100644 .github/workflows/test_laplacian_smoothing.yml create mode 100644 .github/workflows/test_monge_ampere.yml create mode 100644 .github/workflows/test_spring.yml delete mode 100644 .github/workflows/test_suite.yml diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml new file mode 100644 index 0000000..39a7bb4 --- /dev/null +++ b/.github/workflows/test_core.yml @@ -0,0 +1,57 @@ +name: 'Spring-based tests' + +on: + # Run tests whenever commits modifying relevant files are pushed to an open PR + pull_request: + paths: + - 'movement/math.py' + - 'movement/monitor.py' + - 'movement/tangling.py' + - 'test/test_math.py' + - 'test/test_monitor.py' + - 'test/test_tangling.py' + - '.github/workflows/test_core.yml' + - 'pyproject.toml' + +# Cancel jobs running if new commits are pushed +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test_suite: + name: 'Test suite' + runs-on: ubuntu-latest + container: + image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + options: --user root + env: + TESTS: 'test/test_math.py test/test_monitor.py test/test_tangling.py' + # Allow executing mpiexec as root + OMPI_ALLOW_RUN_AS_ROOT: '1' + OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: '1' + # Since we are root we need to set PYTHONPATH to find the installed packages + PYTHONPATH: /home/firedrake/firedrake:/home/firedrake/movement:/home/firedrake/.local/lib/python3.12/site-packages + + steps: + - name: 'Check out the repo' + id: checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: 'Install package' + run: pip install --break-system-packages -e .[dev] + + - name: 'Run serial tests' + run: | + python3 $(which firedrake-clean) + python3 -m pytest -v -k "parallel[1] or not parallel" "${TESTS}" + + - name: 'Run parallel tests (nprocs = 2)' + run: | + if pytest --collect-only -m parallel[2] "${TESTS}" | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TESTS}" + fi diff --git a/.github/workflows/test_coverage.yml b/.github/workflows/test_coverage.yml new file mode 100644 index 0000000..3483634 --- /dev/null +++ b/.github/workflows/test_coverage.yml @@ -0,0 +1,10 @@ +name: 'Run Movement coverage test suite' + +on: + # Run test suite every Sunday at 1AM + schedule: + - cron: '0 1 * * 0' + +jobs: + test_suite: + uses: mesh-adaptation/docs/.github/workflows/reusable_test_suite.yml@main diff --git a/.github/workflows/test_demos.yml b/.github/workflows/test_demos.yml new file mode 100644 index 0000000..56306b3 --- /dev/null +++ b/.github/workflows/test_demos.yml @@ -0,0 +1,51 @@ +name: 'Integration test suite' + +on: + # Run demo tests whenever commits are pushed to an open PR + pull_request: + paths: + - '**.py' + - '.github/workflows/test_demos.yml' + - 'pyproject.toml' + +# Cancel jobs running if new commits are pushed +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test_suite: + name: 'Test suite' + runs-on: ubuntu-latest + container: + image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + options: --user root + env: + # Allow executing mpiexec as root + OMPI_ALLOW_RUN_AS_ROOT: '1' + OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: '1' + # Since we are root we need to set PYTHONPATH to find the installed packages + PYTHONPATH: /home/firedrake/firedrake:/home/firedrake/movement:/home/firedrake/.local/lib/python3.12/site-packages + + steps: + - name: 'Check out the repo' + id: checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: 'Install package' + run: pip install --break-system-packages -e .[dev] + + - name: 'Run serial tests' + run: | + python3 $(which firedrake-clean) + python3 -m pytest -v -k "parallel[1] or not parallel" test/test_demos.py + + - name: 'Run parallel tests (nprocs = 2)' + run: | + if pytest --collect-only -m parallel[2] test/test_demos.py | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] test/test_demos.py + fi diff --git a/.github/workflows/test_laplacian_smoothing.yml b/.github/workflows/test_laplacian_smoothing.yml new file mode 100644 index 0000000..8948b92 --- /dev/null +++ b/.github/workflows/test_laplacian_smoothing.yml @@ -0,0 +1,54 @@ +name: 'Laplacian smoothing tests' + +on: + # Run tests whenever commits modifying relevant files are pushed to an open PR + pull_request: + paths: + - 'movement/laplacian_smoothing.py' + - 'test/test_forced_movement.py' + - 'test/test_laplacian_smoothing.py' + - '.github/workflows/test_laplacian_smoothing.yml' + - 'pyproject.toml' + +# Cancel jobs running if new commits are pushed +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test_suite: + name: 'Test suite' + runs-on: ubuntu-latest + container: + image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + options: --user root + env: + TESTS: 'test/test_forced_movement.py test/test_laplacian_smoothing.py' + # Allow executing mpiexec as root + OMPI_ALLOW_RUN_AS_ROOT: '1' + OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: '1' + # Since we are root we need to set PYTHONPATH to find the installed packages + PYTHONPATH: /home/firedrake/firedrake:/home/firedrake/movement:/home/firedrake/.local/lib/python3.12/site-packages + + steps: + - name: 'Check out the repo' + id: checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: 'Install package' + run: pip install --break-system-packages -e .[dev] + + - name: 'Run serial tests' + run: | + python3 $(which firedrake-clean) + python3 -m pytest -v -k "parallel[1] or not parallel" "${TESTS}" + + - name: 'Run parallel tests (nprocs = 2)' + run: | + if pytest --collect-only -m parallel[2] "${TESTS}" | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TESTS}" + fi diff --git a/.github/workflows/test_monge_ampere.yml b/.github/workflows/test_monge_ampere.yml new file mode 100644 index 0000000..eff27bd --- /dev/null +++ b/.github/workflows/test_monge_ampere.yml @@ -0,0 +1,53 @@ +name: 'Monge-Ampere tests' + +on: + # Run tests whenever commits modifying relevant files are pushed to an open PR + pull_request: + paths: + - 'movement/monge_ampere.py' + - 'test/test_monge_ampere.py' + - '.github/workflows/test_monge_ampere.yml' + - 'pyproject.toml' + +# Cancel jobs running if new commits are pushed +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test_suite: + name: 'Test suite' + runs-on: ubuntu-latest + container: + image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + options: --user root + env: + TESTS: 'test/test_monge_ampere.py' + # Allow executing mpiexec as root + OMPI_ALLOW_RUN_AS_ROOT: '1' + OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: '1' + # Since we are root we need to set PYTHONPATH to find the installed packages + PYTHONPATH: /home/firedrake/firedrake:/home/firedrake/movement:/home/firedrake/.local/lib/python3.12/site-packages + + steps: + - name: 'Check out the repo' + id: checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: 'Install package' + run: pip install --break-system-packages -e .[dev] + + - name: 'Run serial tests' + run: | + python3 $(which firedrake-clean) + python3 -m pytest -v -k "parallel[1] or not parallel" "${TESTS}" + + - name: 'Run parallel tests (nprocs = 2)' + run: | + if pytest --collect-only -m parallel[2] "${TESTS}" | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TESTS}" + fi diff --git a/.github/workflows/test_spring.yml b/.github/workflows/test_spring.yml new file mode 100644 index 0000000..b924836 --- /dev/null +++ b/.github/workflows/test_spring.yml @@ -0,0 +1,54 @@ +name: 'Spring-based tests' + +on: + # Run tests whenever commits modifying relevant files are pushed to an open PR + pull_request: + paths: + - 'movement/laplacian_smoothing.py' + - 'test/test_forced_movement.py' + - 'test/test_spring.py' + - '.github/workflows/test_spring.yml' + - 'pyproject.toml' + +# Cancel jobs running if new commits are pushed +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test_suite: + name: 'Test suite' + runs-on: ubuntu-latest + container: + image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + options: --user root + env: + TESTS: 'test/test_forced_movement.py test/test_spring.py' + # Allow executing mpiexec as root + OMPI_ALLOW_RUN_AS_ROOT: '1' + OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: '1' + # Since we are root we need to set PYTHONPATH to find the installed packages + PYTHONPATH: /home/firedrake/firedrake:/home/firedrake/movement:/home/firedrake/.local/lib/python3.12/site-packages + + steps: + - name: 'Check out the repo' + id: checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: 'Install package' + run: pip install --break-system-packages -e .[dev] + + - name: 'Run serial tests' + run: | + python3 $(which firedrake-clean) + python3 -m pytest -v -k "parallel[1] or not parallel" "${TESTS}" + + - name: 'Run parallel tests (nprocs = 2)' + run: | + if pytest --collect-only -m parallel[2] "${TESTS}" | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TESTS}" + fi diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.yml deleted file mode 100644 index 7fa6e3d..0000000 --- a/.github/workflows/test_suite.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: 'Run Movement test suite' - -on: - # Run test suite whenever main is updated - push: - branches: - - main - paths: - - '**.py' - - '**.geo' - - '.github/workflows/test_suite.yml' - - 'pyproject.toml' - - # Run test suite whenever commits are pushed to an open PR - pull_request: - paths: - - '**.py' - - '**.geo' - - '.github/workflows/test_suite.yml' - - 'pyproject.toml' - - # Run test suite every Sunday at 1AM - schedule: - - cron: '0 1 * * 0' - -jobs: - test_suite: - uses: mesh-adaptation/docs/.github/workflows/reusable_test_suite.yml@main From 742424c7e3e49f2db132552f0fe7cc7de54ecbef Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Tue, 1 Apr 2025 08:26:13 +0100 Subject: [PATCH 5/7] TODO --- test/test_forced_movement.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_forced_movement.py b/test/test_forced_movement.py index 354a592..26a47ef 100644 --- a/test/test_forced_movement.py +++ b/test/test_forced_movement.py @@ -12,6 +12,7 @@ from movement.spring import SpringMover +# TODO: Hoist test base classes to a separate module class BaseClasses: """ Base classes for testing mesh movement under forcings. From 245df41f84f5fa457cca5e2d897061d46329ac53 Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Tue, 1 Apr 2025 08:37:05 +0100 Subject: [PATCH 6/7] Fix docker image and core workflow name --- .github/workflows/test_core.yml | 4 ++-- .github/workflows/test_demos.yml | 2 +- .github/workflows/test_laplacian_smoothing.yml | 2 +- .github/workflows/test_monge_ampere.yml | 2 +- .github/workflows/test_spring.yml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml index 39a7bb4..b3d5b94 100644 --- a/.github/workflows/test_core.yml +++ b/.github/workflows/test_core.yml @@ -1,4 +1,4 @@ -name: 'Spring-based tests' +name: 'Core tests' on: # Run tests whenever commits modifying relevant files are pushed to an open PR @@ -23,7 +23,7 @@ jobs: name: 'Test suite' runs-on: ubuntu-latest container: - image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + image: ghcr.io/mesh-adaptation/firedrake-parmmg:latest options: --user root env: TESTS: 'test/test_math.py test/test_monitor.py test/test_tangling.py' diff --git a/.github/workflows/test_demos.yml b/.github/workflows/test_demos.yml index 56306b3..5c5ca77 100644 --- a/.github/workflows/test_demos.yml +++ b/.github/workflows/test_demos.yml @@ -18,7 +18,7 @@ jobs: name: 'Test suite' runs-on: ubuntu-latest container: - image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + image: ghcr.io/mesh-adaptation/firedrake-parmmg:latest options: --user root env: # Allow executing mpiexec as root diff --git a/.github/workflows/test_laplacian_smoothing.yml b/.github/workflows/test_laplacian_smoothing.yml index 8948b92..1158e3c 100644 --- a/.github/workflows/test_laplacian_smoothing.yml +++ b/.github/workflows/test_laplacian_smoothing.yml @@ -20,7 +20,7 @@ jobs: name: 'Test suite' runs-on: ubuntu-latest container: - image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + image: ghcr.io/mesh-adaptation/firedrake-parmmg:latest options: --user root env: TESTS: 'test/test_forced_movement.py test/test_laplacian_smoothing.py' diff --git a/.github/workflows/test_monge_ampere.yml b/.github/workflows/test_monge_ampere.yml index eff27bd..06b9ab0 100644 --- a/.github/workflows/test_monge_ampere.yml +++ b/.github/workflows/test_monge_ampere.yml @@ -19,7 +19,7 @@ jobs: name: 'Test suite' runs-on: ubuntu-latest container: - image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + image: ghcr.io/mesh-adaptation/firedrake-parmmg:latest options: --user root env: TESTS: 'test/test_monge_ampere.py' diff --git a/.github/workflows/test_spring.yml b/.github/workflows/test_spring.yml index b924836..6991b04 100644 --- a/.github/workflows/test_spring.yml +++ b/.github/workflows/test_spring.yml @@ -20,7 +20,7 @@ jobs: name: 'Test suite' runs-on: ubuntu-latest container: - image: ghcr.io/mesh-adaptation/${{ inputs.docker-image }}:latest + image: ghcr.io/mesh-adaptation/firedrake-parmmg:latest options: --user root env: TESTS: 'test/test_forced_movement.py test/test_spring.py' From 86d23c42693ce341d0a9a711943f10ba2f0f0764 Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Tue, 1 Apr 2025 08:41:46 +0100 Subject: [PATCH 7/7] Loop over test files --- .github/workflows/test_core.yml | 16 ++++++++++------ .github/workflows/test_laplacian_smoothing.yml | 16 ++++++++++------ .github/workflows/test_monge_ampere.yml | 16 ++++++++++------ .github/workflows/test_spring.yml | 16 ++++++++++------ 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml index b3d5b94..b7ab869 100644 --- a/.github/workflows/test_core.yml +++ b/.github/workflows/test_core.yml @@ -46,12 +46,16 @@ jobs: - name: 'Run serial tests' run: | python3 $(which firedrake-clean) - python3 -m pytest -v -k "parallel[1] or not parallel" "${TESTS}" + for TEST in ${TESTS}; do + python3 -m pytest -v -k "parallel[1] or not parallel" "${TEST}" + done - name: 'Run parallel tests (nprocs = 2)' run: | - if pytest --collect-only -m parallel[2] "${TESTS}" | grep -q 'no tests collected'; then - echo "No parallel[2] tests found." - else - mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TESTS}" - fi + for TEST in ${TESTS}; do + if pytest --collect-only -m parallel[2] "${TEST}" | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TEST}" + fi + done diff --git a/.github/workflows/test_laplacian_smoothing.yml b/.github/workflows/test_laplacian_smoothing.yml index 1158e3c..ffe45d7 100644 --- a/.github/workflows/test_laplacian_smoothing.yml +++ b/.github/workflows/test_laplacian_smoothing.yml @@ -43,12 +43,16 @@ jobs: - name: 'Run serial tests' run: | python3 $(which firedrake-clean) - python3 -m pytest -v -k "parallel[1] or not parallel" "${TESTS}" + for TEST in ${TESTS}; do + python3 -m pytest -v -k "parallel[1] or not parallel" "${TEST}" + done - name: 'Run parallel tests (nprocs = 2)' run: | - if pytest --collect-only -m parallel[2] "${TESTS}" | grep -q 'no tests collected'; then - echo "No parallel[2] tests found." - else - mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TESTS}" - fi + for TEST in ${TESTS}; do + if pytest --collect-only -m parallel[2] "${TEST}" | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TEST}" + fi + done diff --git a/.github/workflows/test_monge_ampere.yml b/.github/workflows/test_monge_ampere.yml index 06b9ab0..09113f8 100644 --- a/.github/workflows/test_monge_ampere.yml +++ b/.github/workflows/test_monge_ampere.yml @@ -42,12 +42,16 @@ jobs: - name: 'Run serial tests' run: | python3 $(which firedrake-clean) - python3 -m pytest -v -k "parallel[1] or not parallel" "${TESTS}" + for TEST in ${TESTS}; do + python3 -m pytest -v -k "parallel[1] or not parallel" "${TEST}" + done - name: 'Run parallel tests (nprocs = 2)' run: | - if pytest --collect-only -m parallel[2] "${TESTS}" | grep -q 'no tests collected'; then - echo "No parallel[2] tests found." - else - mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TESTS}" - fi + for TEST in ${TESTS}; do + if pytest --collect-only -m parallel[2] "${TEST}" | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TEST}" + fi + done diff --git a/.github/workflows/test_spring.yml b/.github/workflows/test_spring.yml index 6991b04..902c355 100644 --- a/.github/workflows/test_spring.yml +++ b/.github/workflows/test_spring.yml @@ -43,12 +43,16 @@ jobs: - name: 'Run serial tests' run: | python3 $(which firedrake-clean) - python3 -m pytest -v -k "parallel[1] or not parallel" "${TESTS}" + for TEST in ${TESTS}; do + python3 -m pytest -v -k "parallel[1] or not parallel" "${TEST}" + done - name: 'Run parallel tests (nprocs = 2)' run: | - if pytest --collect-only -m parallel[2] "${TESTS}" | grep -q 'no tests collected'; then - echo "No parallel[2] tests found." - else - mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TESTS}" - fi + for TEST in ${TESTS}; do + if pytest --collect-only -m parallel[2] "${TEST}" | grep -q 'no tests collected'; then + echo "No parallel[2] tests found." + else + mpiexec -n 2 python3 -m pytest -v -m parallel[2] "${TEST}" + fi + done