Skip to content

Commit

Permalink
nox test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Feb 5, 2024
1 parent 1b9771d commit 6f4ed15
Show file tree
Hide file tree
Showing 14 changed files with 348 additions and 543 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
ignore = E501,E225,E226,E303,E201,E202,E203,W503
7 changes: 7 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ jobs:
- name: Run sequential tests with nox
run: |
nox --session "tests(with_cov=True, with_mpi=False)"
mv .coverage/coverage.xml coverage_without_mpi.xml
- name: Run parallel tests with nox
run: |
nox --session "tests(with_cov=True, with_mpi=True)"
mv .coverage/coverage.xml coverage_with_mpi.xml
- name: Produce coverage xml
run: |
Expand All @@ -51,3 +53,8 @@ jobs:
- name: Upload coverage to codecov
if: ${{ success() }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
files: coverage_without_mpi.xml,coverage_with_mpi.xml
58 changes: 29 additions & 29 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
from pathlib import Path
from functools import partial
from shutil import rmtree

import nox

Expand Down Expand Up @@ -49,12 +50,13 @@ def tests(session, with_mpi, with_cov):
session.run_always(*command.split(), external=True)

session.install(
"-e",
".",
"--no-deps",
"--no-build-isolation",
"-v",
silent=False,
)
session.run("ls", "src/fluidfft/fft3d", silent=False, external=True)

session.install("plugins/fluidfft-builder")
session.install("-e", "plugins/fluidfft-fftw", "--no-build-isolation", "-v")
Expand All @@ -64,55 +66,53 @@ def tests(session, with_mpi, with_cov):
)
session.install("-e", "plugins/fluidfft-fftwmpi", "--no-build-isolation", "-v")

if with_cov:
path_coverage = Path.cwd() / ".coverage"
rmtree(path_coverage, ignore_errors=True)
path_coverage.mkdir(exist_ok=True)

def run_command(command, **kwargs):
if with_cov:
command += " --cov --cov-config=pyproject.toml --no-cov-on-fail --cov-report=term-missing --cov-append"
session.run(*command.split(), **kwargs)

if with_cov:
cov_path = Path.cwd() / ".coverage"
cov_path.mkdir(exist_ok=True)

command = "pytest -v -s tests"
if with_cov:
command += (
" --cov --cov-config=setup.cfg --no-cov-on-fail --cov-report=term-missing"
)

run_command(command, *session.posargs)
run_command(command, *session.posargs, env={"TRANSONIC_NO_REPLACE": "1"})

run_command("pytest -v plugins/fluidfft-fftw")

if with_mpi:
if with_cov:
command = "mpirun -np 2 --oversubscribe coverage run -p -m pytest -v -s --exitfirst tests"

else:
command = "mpirun -np 2 --oversubscribe pytest -v -s tests"
def test_plugin(package_name):
if with_cov:
command = "mpirun -np 2 --oversubscribe coverage run -p -m pytest -v -s --exitfirst"
else:
command = "mpirun -np 2 --oversubscribe pytest -v -s "

run_command(command, external=True)
command += f" plugins/{package_name}"
session.run(*command.split(), external=True)

run_command(
"mpirun -np 2 --oversubscribe pytest -v plugins/fluidfft-mpi_with_fftw",
external=True,
)
run_command(
"mpirun -np 2 --oversubscribe pytest -v plugins/fluidfft-fftwmpi",
external=True,
)
test_plugin("fluidfft-mpi_with_fftw")
test_plugin("fluidfft-fftwmpi")

if with_cov:
if with_mpi:
run_command("coverage combine")
run_command("coverage report")
session.run("coverage", "combine")
session.run("coverage", "report")
session.run("coverage", "xml")
session.run("coverage", "html")


@nox.session
def doc(session):
session.run_always("pdm", "sync", "--clean", "-G", "doc", "--no-self", external=True)
session.run_always("python", "-c", "from fluidfft_builder import create_fake_modules as c; c()")
session.install(
".", "--no-deps", "-C", "setup-args=-Dtransonic-backend=python"
session.run_always(
"pdm", "sync", "--clean", "-G", "doc", "--no-self", external=True
)
session.run_always(
"python", "-c", "from fluidfft_builder import create_fake_modules as c; c()"
)
session.install(".", "--no-deps", "-C", "setup-args=-Dtransonic-backend=python")
session.chdir("doc")
session.run("make", "cleanall", external=True)
session.run("make", external=True)
53 changes: 49 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6f4ed15

Please sign in to comment.