diff --git a/.github/workflows/test_core.yml b/.github/workflows/test_core.yml new file mode 100644 index 0000000..b7ab869 --- /dev/null +++ b/.github/workflows/test_core.yml @@ -0,0 +1,61 @@ +name: 'Core 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/firedrake-parmmg: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) + for TEST in ${TESTS}; do + python3 -m pytest -v -k "parallel[1] or not parallel" "${TEST}" + done + + - name: 'Run parallel tests (nprocs = 2)' + run: | + 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_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..5c5ca77 --- /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/firedrake-parmmg: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..ffe45d7 --- /dev/null +++ b/.github/workflows/test_laplacian_smoothing.yml @@ -0,0 +1,58 @@ +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/firedrake-parmmg: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) + for TEST in ${TESTS}; do + python3 -m pytest -v -k "parallel[1] or not parallel" "${TEST}" + done + + - name: 'Run parallel tests (nprocs = 2)' + run: | + 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 new file mode 100644 index 0000000..09113f8 --- /dev/null +++ b/.github/workflows/test_monge_ampere.yml @@ -0,0 +1,57 @@ +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/firedrake-parmmg: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) + for TEST in ${TESTS}; do + python3 -m pytest -v -k "parallel[1] or not parallel" "${TEST}" + done + + - name: 'Run parallel tests (nprocs = 2)' + run: | + 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 new file mode 100644 index 0000000..902c355 --- /dev/null +++ b/.github/workflows/test_spring.yml @@ -0,0 +1,58 @@ +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/firedrake-parmmg: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) + for TEST in ${TESTS}; do + python3 -m pytest -v -k "parallel[1] or not parallel" "${TEST}" + done + + - name: 'Run parallel tests (nprocs = 2)' + run: | + 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_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 diff --git a/test/test_forced_movement.py b/test/test_forced_movement.py index a24e9dc..26a47ef 100644 --- a/test/test_forced_movement.py +++ b/test/test_forced_movement.py @@ -8,9 +8,11 @@ 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 +# TODO: Hoist test base classes to a separate module class BaseClasses: """ Base classes for testing mesh movement under forcings. 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): 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):