Skip to content

Commit

Permalink
CI Github with 3.12 + better noxfile + coverage xml
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Jan 16, 2024
1 parent 3499280 commit 50d5f0a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 37 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: apt install
Expand All @@ -23,10 +23,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pdm nox
pip install pdm nox coverage
- name: Test with nox
run: |
nox -s test_without_pythran test_with_pythran
nox -s "test(with_pythran=0, with_cython=0)" "test(with_pythran=1, with_cython=0)" "test(with_pythran=0, with_cython=1)"
coverage combine
coverage report
coverage xml
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
18 changes: 13 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,31 @@ step_without_pythran:
- job: "image:build"
optional: true
script:
- nox -s test_without_pythran
- nox -s "test(with_pythran=0, with_cython=0)"

step_pythran_then_cython:
step_with_pythran:
stage: test
needs:
- job: "image:build"
optional: true
script:
- nox -s test_with_pythran test_with_cython
- nox -s "test(with_pythran=1, with_cython=0)"

step_pythran_cython:
step_with_cython:
stage: test
needs:
- job: "image:build"
optional: true
script:
- nox -s test_with_pythran_cython
- nox -s "test(with_pythran=0, with_cython=1)"

step_with_pythran_cython:
stage: test
needs:
- job: "image:build"
optional: true
script:
- nox -s "test(with_pythran=1, with_cython=1)"


pages:
Expand Down
74 changes: 46 additions & 28 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,66 @@
import os
import sys
from packaging import version
from pathlib import Path

import nox

os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})


def _test(session):
session.run("make", "tests_ipynb", external=True)
session.run("make", "tests_coverage", external=True)


def _install_base(session):
@nox.parametrize("with_cython", [0, 1])
@nox.parametrize("with_pythran", [0, 1])
@nox.session
def test(session, with_pythran, with_cython):
command = "pdm sync -G base_test"
session.run_always(*command.split(), external=True)

py_version = session.python if session.python is not None else sys.version.split(maxsplit=1)[0]
py_version = (
session.python
if session.python is not None
else sys.version.split(maxsplit=1)[0]
)
if version.parse(py_version) < version.parse("3.12"):
session.install("numba")

if with_pythran:
session.install("pythran")
if with_cython:
session.install("cython")

@nox.session
def test_without_pythran(session):
_install_base(session)
_test(session)


@nox.session
def test_with_pythran(session):
_install_base(session)
session.install("pythran")
_test(session)
if version.parse(py_version) < version.parse("3.12"):
for backend in ("python", "pythran"):
print(f"TRANSONIC_BACKEND={backend}")
session.run(
"pytest",
"--nbval-lax",
"data_tests/ipynb",
env={"TRANSONIC_BACKEND": backend},
)

path_coverage = Path(".coverage")
path_coverage.mkdir(exist_ok=True)

@nox.session
def test_with_cython(session):
_install_base(session)
session.install("cython")
_test(session)
code_dependencies = 10 * with_pythran + with_cython

for backend in ("python", "pythran", "numba", "cython"):
print(f"TRANSONIC_BACKEND={backend}")
session.run(
"pytest",
"--cov",
"--cov-config=pyproject.toml",
"tests",
env={
"COVERAGE_FILE": f".coverage/coverage{code_dependencies}.{backend}",
"TRANSONIC_BACKEND": backend,
},
)

@nox.session
def test_with_pythran_cython(session):
_install_base(session)
session.install("pythran", "cython")
_test(session)
command = "mpirun -np 2 coverage run --rcfile=pyproject.toml -m mpi4py -m pytest tests"
session.run(
*command.split(),
external=True,
env={
"TRANSONIC_BACKEND": "pythran",
},
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ target-version = ['py38']
[tool.coverage.run]
branch = true

source = ["src/transonic", "src/transonic_cl", "./tests"]
source = ["./src/transonic", "./src/transonic_cl", "./tests"]
data_file = ".coverage/coverage"
omit = [
"*/try_*.py",
Expand Down

0 comments on commit 50d5f0a

Please sign in to comment.