Skip to content

Add real dolfinx integration tests and GitHub Actions CI#4

Merged
RuruX merged 3 commits into
mainfrom
add-dolfinx-ci-tests
Jun 19, 2026
Merged

Add real dolfinx integration tests and GitHub Actions CI#4
RuruX merged 3 commits into
mainfrom
add-dolfinx-ci-tests

Conversation

@RuruX

@RuruX RuruX commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the 360-line mock conftest.py (from PR Add unit tests for FEMO core modules #3) with a ~50-line fixture file — no hand-rolled stubs
  • Adds tests/integration/ with tests using real dolfinx/ufl/petsc4py:
    • FEA registration (add_input, add_state, add_output, add_strong_bc) exercised on actual Function and mesh objects
    • End-to-end Poisson solve (FEA.solve) verified against known physical bounds
    • Manufactured-solution convergence test confirming O(h²) L2 error rate — the canonical FEM correctness check
  • Keeps tests/unit/ for lightweight registration tests that run without a FEM install
  • Adds .github/workflows/tests.yml with two CI jobs:
    • unit — runs on ubuntu-latest, no FEM deps
    • integration — runs inside dolfinx/dolfinx:v0.9.0 container

Test plan

  • Unit CI job passes without dolfinx installed
  • Integration CI job passes inside dolfinx container
  • Convergence rate ≥ 1.8 for P1 Lagrange on unit square (expected ~2.0)
  • Boundary dofs verified to be zero after solve

- 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
Copilot AI review requested due to automatic review settings June 19, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.py for shared fixtures and removed reliance on large hand-rolled mocks.
  • Added a GitHub Actions workflow with separate unit and integration jobs (integration runs in a dolfinx/dolfinx container).

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 thread tests/unit/test_fea_registration.py Outdated
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
RuruX added 2 commits June 19, 2026 15:00
- 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
@RuruX RuruX merged commit cd419a5 into main Jun 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants