From f7f7963ee855057593843706c5c6ad5da56ba71a Mon Sep 17 00:00:00 2001 From: Joe Wallwork <22053413+jwallwork23@users.noreply.github.com> Date: Sat, 23 Nov 2024 17:23:48 +0000 Subject: [PATCH] Use the UM2N Docker image (#59) Closes #57. Linked PR: https://github.com/mesh-adaptation/mesh-adaptation-docs/pull/59. This PR sets up UM2N's CI to use the newly added bespoke Docker image. It also makes use of the reusable test workflow from the docs repo. --- .github/workflows/test_suite.yml | 76 ++++++------------- Makefile | 31 ++++++++ README.md | 7 +- {tests => test}/dataset_integrity_check.ipynb | 0 {tests => test}/test_import.py | 0 {tests => test}/test_unstructured_mesh.py | 0 6 files changed, 57 insertions(+), 57 deletions(-) create mode 100644 Makefile rename {tests => test}/dataset_integrity_check.ipynb (100%) rename {tests => test}/test_import.py (100%) rename {tests => test}/test_unstructured_mesh.py (100%) diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.yml index b6198e4..d4a38a4 100644 --- a/.github/workflows/test_suite.yml +++ b/.github/workflows/test_suite.yml @@ -1,63 +1,31 @@ -name: Install and test UM2N +name: 'Run UM2N Test Suite' on: + # Run test suite whenever main is updated push: branches: - main + # Run test suite whenever commits are pushed to an open PR pull_request: -jobs: - test-warpmesh: - name: Test UM2N - runs-on: ubuntu-latest - container: - image: firedrakeproject/firedrake:latest - options: --user root - steps: - - uses: actions/checkout@v3 - - - name: Cleanup - if: ${{ always() }} - run: | - cd .. - rm -rf build - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Lint check - if: ${{ always() }} - run: | - . /home/firedrake/firedrake/bin/activate - python3 -m pip install ruff - ruff check - - - name: Install Movement - run: | - . /home/firedrake/firedrake/bin/activate - git clone https://github.com/mesh-adaptation/movement.git - cd movement - python3 -m pip install -e . + # Run test suite every Sunday at 1AM + schedule: + - cron: '0 1 * * 0' - - name: Install PyTorch - run: | - . /home/firedrake/firedrake/bin/activate - python3 -m pip install torch --index-url https://download.pytorch.org/whl/cpu - - - name: Install PyTorch3d - run: | - . /home/firedrake/firedrake/bin/activate - python3 -m pip install 'git+https://github.com/facebookresearch/pytorch3d.git' - - - name: Install UM2N - run: | - . /home/firedrake/firedrake/bin/activate - python3 -m pip install -e . - - - name: Run UM2N test suite - run: | - . /home/firedrake/firedrake/bin/activate - python3 -m pytest tests/test* -v +jobs: + test_suite: + uses: mesh-adaptation/mesh-adaptation-docs/.github/workflows/reusable_test_suite.yml@main + with: + install-command: 'python -m pip uninstall -y UM2N && python -m pip install -e .' + test-command: | + export GITHUB_ACTIONS_TEST_RUN=1 + python $(which firedrake-clean) + python -m coverage erase + python -m coverage run -a --source=UM2N -m pytest -v --durations=20 test + python -m coverage report + changed-files-patterns: | + **/*.py + **/*.msh + **/*.geo + docker-image: firedrake-um2n diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a66b960 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +all: install + +.PHONY: install test + +install: + @echo "Installing UM2N..." + @python3 -m pip install -e . + @echo "Done." + @echo "Setting up pre-commit..." + @pre-commit install + @echo "Done." + +lint: + @echo "Checking lint..." + @ruff check + @echo "PASS" + +test: lint + @echo "Running all tests..." + @python3 -m pytest -v --durations=20 test + @echo "Done." + +coverage: + @echo "Generating coverage report..." + @python3 -m coverage erase + @python3 -m coverage run --source=UM2N -m pytest -v test + @python3 -m coverage html + @echo "Done." + +tree: + @tree -d . diff --git a/README.md b/README.md index e299171..19c3cec 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,9 @@ The documentation is generated by Sphinx. To build the documentation, under the ├── docs (Documentation) │ ├── conf.py │ └── index.rst +├── play +│ ├── play_conv_feat.py +│ └── play_dataset.py ├── script (Utility scripts) │ ├── make_dataset.sh (Script for making datasets of different sizes) │ ├── build_helmholtz_dataset.py (Build helmholtz dataset) @@ -159,9 +162,7 @@ The documentation is generated by Sphinx. To build the documentation, under the │ ├── plot.py │ ├── train_model.py │ └── ... -├── tests -│ ├── play_conv_feat.py -│ ├── play_dataset.py +├── test │ ├── test_import.py │ └── ... ├── install.sh (Installation script for UM2N and its dependencies) diff --git a/tests/dataset_integrity_check.ipynb b/test/dataset_integrity_check.ipynb similarity index 100% rename from tests/dataset_integrity_check.ipynb rename to test/dataset_integrity_check.ipynb diff --git a/tests/test_import.py b/test/test_import.py similarity index 100% rename from tests/test_import.py rename to test/test_import.py diff --git a/tests/test_unstructured_mesh.py b/test/test_unstructured_mesh.py similarity index 100% rename from tests/test_unstructured_mesh.py rename to test/test_unstructured_mesh.py