Skip to content

Commit

Permalink
Testing the built wheels with cibuildwheel (#4341)
Browse files Browse the repository at this point in the history
* Using cibuildwheel to run tests

Signed-off-by: Pradyot Ranjan <[email protected]>

* using cibw marker

Signed-off-by: Pradyot Ranjan <[email protected]>

* removing trailing whitespace

Signed-off-by: Pradyot Ranjan <[email protected]>

---------

Signed-off-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
  • Loading branch information
prady0t and prady0t authored Aug 22, 2024
1 parent 25a9936 commit fcab586
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ jobs:
CIBW_ARCHS: AMD64
CIBW_BEFORE_BUILD: python -m pip install setuptools wheel delvewheel # skip CasADi and CMake
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: python -c "import pybamm; print(pybamm.IDAKLUSolver())"

CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit
- name: Upload Windows wheels
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -118,9 +120,11 @@ jobs:
bash scripts/install_sundials.sh 6.0.3 6.5.0
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake casadi setuptools wheel
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
set -e -x
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit
- name: Upload wheels for Linux
uses: actions/[email protected]
Expand Down Expand Up @@ -249,9 +253,11 @@ jobs:
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} --require-target-macos-version 11.1
for file in {dest_dir}/*.whl; do mv "$file" "${file//macosx_11_1/macosx_11_0}"; done
fi
CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
set -e -x
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
python -m pytest -m cibw {project}/tests/unit
- name: Upload wheels for macOS (amd64, arm64)
uses: actions/[email protected]
Expand Down
7 changes: 7 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ def pytest_addoption(parser):
default=False,
help="run integration tests",
)
parser.addoption(
"--cibw",
action="store_true",
default=False,
help="test build wheels",
)


def pytest_configure(config):
config.addinivalue_line("markers", "scripts: mark test as an example script")
config.addinivalue_line("markers", "unit: mark test as a unit test")
config.addinivalue_line("markers", "integration: mark test as an integration test")
config.addinivalue_line("markers", "cibw: mark test as build wheel test")


def pytest_collection_modifyitems(items):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ required_plugins = [
"pytest-xdist",
"pytest-mock",
]
norecursedirs = 'pybind11*'
addopts = [
"-nauto",
"-vra",
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_solvers/test_idaklu_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
from contextlib import redirect_stdout
import io
import unittest

import pytest
import numpy as np

import pybamm
from tests import get_discretisation_for_testing


@pytest.mark.cibw
@unittest.skipIf(not pybamm.have_idaklu(), "idaklu solver is not installed")
class TestIDAKLUSolver(unittest.TestCase):
def test_ida_roberts_klu(self):
Expand Down

0 comments on commit fcab586

Please sign in to comment.