From f9ede8b7e76d27b773910badd89e1ec2cab3601d Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 10 Jun 2021 22:15:56 -0400 Subject: [PATCH] tests: adding runner for ROOT [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++++++--- environment.yml | 9 +++++++++ noxfile.py | 15 +++++++++++++-- tests/test_root.py | 7 +++++++ 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 environment.yml create mode 100644 tests/test_root.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab274a9..c36ded1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,7 @@ jobs: checks: name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }} + needs: [pre-commit] strategy: fail-fast: false matrix: @@ -36,7 +37,6 @@ jobs: - python-version: pypy-3.7 runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 @@ -47,16 +47,41 @@ jobs: - name: Install package run: python -m pip install .[test] - - name: Test package + - name: Test run: python -m pytest -ra + root: + name: ROOT test + runs-on: ubuntu-latest + needs: [pre-commit] + defaults: + run: + shell: bash -l {0} + + steps: + - uses: actions/checkout@v2 + + - uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-variant: Mambaforge + use-mamba: true + environment-file: environment.yml + + - name: Install package + run: pip install . + + - name: Test root + run: pytest -ra tests/test_root.py + + dist: name: Distribution build runs-on: ubuntu-latest + needs: [pre-commit] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Build sdist and wheel run: pipx run build diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..6ebbe21 --- /dev/null +++ b/environment.yml @@ -0,0 +1,9 @@ +name: uhi +channels: + - conda-forge +dependencies: + - pip + - pytest + - root + - pytest + - boost-histogram diff --git a/noxfile.py b/noxfile.py index 1b6651b..4c82bef 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,7 +17,7 @@ def lint(session): Run the linter. """ session.install("pre-commit") - session.run("pre-commit", "run", "--all-files") + session.run("pre-commit", "run", "--all-files", *session.posargs) @nox.session(python=ALL_PYTHONS) @@ -26,7 +26,7 @@ def tests(session): Run the unit and regular tests. """ session.install(".[test]") - session.run("pytest") + session.run("pytest", *session.posargs) @nox.session @@ -63,3 +63,14 @@ def build(session): session.install("build") session.run("python", "-m", "build") + + +@nox.session(venv_backend="conda") +def root_tests(session): + """ + Test against ROOT. + """ + + session.conda_install("--channel=conda-forge", "ROOT", "pytest", "boost-histogram") + session.install(".") + session.run("pytest", "tests/test_root.py") diff --git a/tests/test_root.py b/tests/test_root.py new file mode 100644 index 0000000..66e6c79 --- /dev/null +++ b/tests/test_root.py @@ -0,0 +1,7 @@ +import pytest + +ROOT = pytest.importorskip("ROOT") + + +def test_root_imported() -> None: + assert ROOT.TString("hi") == "hi"