Add real dolfinx integration tests and GitHub Actions CI#4
Merged
Conversation
- Replace 360-line mock conftest with ~50-line fixture file - Add tests/integration/ with real dolfinx/ufl/petsc4py tests: - FEA registration (input, state, output, BC) using actual Function objects - End-to-end Poisson solve verified against known bounds - Manufactured-solution convergence test confirming O(h2) rate - Add tests/unit/ with lightweight mock-based registration tests that run without a FEM installation - Add .github/workflows/tests.yml: unit job runs on ubuntu-latest, integration job runs inside dolfinx/dolfinx:v0.9.0 container
There was a problem hiding this comment.
Pull request overview
This PR adds a new testing split to the tests/ suite, keeping lightweight unit tests that can run without a FEM stack while introducing real DOLFINx-based integration tests and a GitHub Actions workflow to run both in CI.
Changes:
- Added real DOLFINx integration tests for FEA registration and end-to-end Poisson solves (including a convergence-rate check).
- Added a minimal
tests/conftest.pyfor shared fixtures and removed reliance on large hand-rolled mocks. - Added a GitHub Actions workflow with separate
unitandintegrationjobs (integration runs in adolfinx/dolfinxcontainer).
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/conftest.py |
Adds shared mock fixtures intended to support unit tests without importing dolfinx/PETSc. |
tests/unit/test_fea_registration.py |
Adds unit tests for AbstractFEA registration methods using import-time stubbing. |
tests/integration/test_fea_dolfinx.py |
Adds integration tests using real dolfinx for registration, solve behavior, and utils helpers. |
tests/integration/test_poisson_convergence.py |
Adds manufactured-solution convergence test for Poisson with expected ~O(h²) rate. |
.github/workflows/tests.yml |
Adds CI workflow running unit tests on ubuntu and integration tests in dolfinx container. |
tests/unit/__init__.py |
Marks unit test package. |
tests/integration/__init__.py |
Marks integration test package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
+20
| # Build minimal stubs so the module-level imports in fea_dolfinx don't fail | ||
| for mod in ["dolfinx", "dolfinx.io", "dolfinx.fem", "dolfinx.fem.petsc", | ||
| "dolfinx.mesh", "dolfinx.nls", "dolfinx.nls.petsc", | ||
| "dolfinx.cpp", "dolfinx.cpp.mesh", "dolfinx.la", | ||
| "ufl", "petsc4py", "petsc4py.PETSc", | ||
| "mpi4py", "mpi4py.MPI", "matplotlib", "matplotlib.pyplot", | ||
| "scipy", "scipy.spatial", "scipy.sparse"]: | ||
| if mod not in sys.modules: | ||
| sys.modules[mod] = types.ModuleType(mod) |
Comment on lines
+27
to
+30
| - name: Install femo | ||
| run: pip install -e ".[dev]" --no-deps | ||
| - name: Run integration tests | ||
| run: pytest tests/integration/ -v --tb=short |
- Pin container image to dolfinx/dolfinx:v0.5.1 (Docker Hub) - Install pytest, scipy, matplotlib before femo (not in container) - Remove [dev] extras (undefined in setup.py) - Wrap Constant value with ScalarType (required in v0.5.1) - Remove unused Expression import
- Add pip install -e . --no-deps to unit job (femo was never installed, causing ModuleNotFoundError on every test) - Complete stub setup in test_fea_registration.py: wire parent.child references on stub modules and populate all attributes accessed via from-import in fea_dolfinx.py and utils_dolfinx.py: dolfinx.io.XDMFFile, dolfinx.fem.petsc.*, dolfinx.nls.petsc.NewtonSolver, dolfinx.cpp.mesh.CellType, missing ufl/dolfinx.fem symbols, scipy.sparse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
conftest.py(from PR Add unit tests for FEMO core modules #3) with a ~50-line fixture file — no hand-rolled stubstests/integration/with tests using real dolfinx/ufl/petsc4py:add_input,add_state,add_output,add_strong_bc) exercised on actualFunctionand mesh objectsFEA.solve) verified against known physical boundstests/unit/for lightweight registration tests that run without a FEM install.github/workflows/tests.ymlwith two CI jobs:unit— runs on ubuntu-latest, no FEM depsintegration— runs insidedolfinx/dolfinx:v0.9.0containerTest plan