Debian Codegraph @

docs/testing.md

raw
1
2 # Testing Strategy
3
4 This document outlines how `io4dolfinx` is tested, covering both local development
5 testing and the Continuous Integration (CI) process on GitHub Actions.
6
7 ## Coverage reports:
8
9 You will find the updated coverage reports for the latest version on `main` tested against `stable` and `nightly` versions of dolfinx at the following links:
10 - [Coverage report for stable](https://scientificcomputing.github.io/io4dolfinx/code-coverage-report-stable/)
11 - [Coverage report for nightly](https://scientificcomputing.github.io/io4dolfinx/code-coverage-report-nightly/)
12
13 ## Local Testing
14
15 The library uses `pytest` for testing. To execute the tests locally, you first
16 need to install the library and its dependencies.
17
18 ### Installation for Testing
19
20 Install the library with the optional `test` dependencies to ensure you have
21 packages like `pytest`, `coverage`, and `ipyparallel`
22
23 ```bash
24 python3 -m pip install . --group test --no-build-isolation
25 python3 -m pip install -e . --no-build-isolation
26 ```
27
28 ### Running Tests
29
30 To execute all tests in the repository, run:
31 ```bash
32 python3 -m pytest .
33 ```
34 ### Generating Test Data
35
36 Some tests require specific datasets to verify compatibility with older software
37 versions.
38
39 #### Testing against data from legacy dolfin
40
41 Some tests check the capability of reading data created with the legacy version
42 of DOLFIN. To create this dataset, start a docker container with legacy DOLFIN,
43 for instance:
44
45 ```bash
46 docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/scientificcomputing/fenics:2024-02-19
47 ```
48
49 Then, inside this container, call:
50 ```bash
51 python3 ./tests/create_legacy_data.py --output-dir=legacy
52 ```
53
54 #### Testing against data from older versions of adios4dolfinx
55 Some tests check the capability to read data generated by `adios4dolfinx<0.7.2`.
56 To generate data for these tests use the following commands:
57
58 ```bash
59 docker run -ti -v $(pwd):/root/shared -w /root/shared --rm ghcr.io/fenics/dolfinx/dolfinx:v0.7.3
60 ```
61
62 Then, inside the container, call:
63
64 ```bash
65 python3 -m pip install adios4dolfinx==0.7.1
66 python3 ./tests/create_legacy_checkpoint.py --output-dir=legacy_checkpoint
67 ```
68
69 ---
70
71 ## Continuous Integration (GitHub Actions)
72
73 The repository relies on several GitHub Actions workflows to ensure code quality
74 and compatibility across different environments.
75
76 ### 1. Main Test Suite (`test_package.yml`)
77
78 This is the primary workflow triggered on pushes to `main`, pull requests, and
79 scheduled nightly runs. It runs on `ubuntu-24.04` using the official DOLFINx
80 docker container
81 .
82
83 **Workflow Steps:**
84 1. **Linting & Formatting:** Checks code style using `ruff` and type consistency
85 with `mypy`
86 .
87 2. **Data Generation:** * Creates legacy DOLFIN data using the `create_legacy_data.yml` workflow.
88 * Creates legacy `adios4dolfinx` checkpoints using `create_legacy_checkpoint.yml`.
89 3. **Test Execution:**
90 * Installs the package with MPI-enabled `h5py`.
91 * Runs the standard test suite with `coverage`.
92 * Runs parallel tests using `mpirun -n 4 ... mpi4py -m pytest`.
93 4. **Reporting:** Combines coverage reports and uploads them as artifacts.
94
95 ### 2. Compatibility Testing
96
97 To ensure broad support, specific workflows test against different configurations:
98
99 * **MPI & ADIOS2 Versions (`test_package_openmpi.yml`):**
100 * Tests against both `openmpi` and `mpich` implementations using the
101 `ghcr.io/fenics/test-env` containers.
102 * Verifies compatibility with different ADIOS2 versions (e.g., `v2.10.2`, `v2.11.0`)
103 .
104
105 * **Operating System (`test_redhat.yml`):**
106 * Runs the full test suite inside a RedHat-based container
107 (`docker.io/fenicsproject/test-env:current-redhat`) to guarantee functionality
108 on non-Debian systems
109 .
110
111 ### 3. Documentation (`build_docs.yml`)
112
113 Ensures the documentation builds correctly with `jupyter-book` on every push and
114 pull request, preventing documentation regressions.