Skip to content

Better modularisation #162

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
61 changes: 61 additions & 0 deletions .github/workflows/test_core.yml
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +49 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please clarify why you're looping over individual tests, instead of just running them all at once with python3 -m pytest -v -k "parallel[1] or not parallel" ${TESTS}? Same elsewhere.


- 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
10 changes: 10 additions & 0 deletions .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions .github/workflows/test_demos.yml
Original file line number Diff line number Diff line change
@@ -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
58 changes: 58 additions & 0 deletions .github/workflows/test_laplacian_smoothing.yml
Original file line number Diff line number Diff line change
@@ -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
57 changes: 57 additions & 0 deletions .github/workflows/test_monge_ampere.yml
Original file line number Diff line number Diff line change
@@ -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
58 changes: 58 additions & 0 deletions .github/workflows/test_spring.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 0 additions & 28 deletions .github/workflows/test_suite.yml

This file was deleted.

4 changes: 3 additions & 1 deletion test/test_forced_movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion test/test_laplacian_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from firedrake.utility_meshes import UnitSquareMesh

from movement import LaplacianSmoother
from movement.laplacian_smoothing import LaplacianSmoother


class TestExceptions(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/test_spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading