From a25d1b08c0a1dfc7e87afd49bf75930de84d4c09 Mon Sep 17 00:00:00 2001 From: Jamie Bull Date: Thu, 24 Nov 2022 19:24:42 +0000 Subject: [PATCH] Coverage --- .github/workflows/actions-ci.yml | 5 ++++- .gitignore | 3 +++ tests/conftest.py | 7 +++++++ tests/test_tutorial.py | 7 ++++--- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/actions-ci.yml b/.github/workflows/actions-ci.yml index 7911d49f..a22fb046 100644 --- a/.github/workflows/actions-ci.yml +++ b/.github/workflows/actions-ci.yml @@ -33,9 +33,12 @@ jobs: black --check --verbose -l 88 geomeppy tests docs - name: Test with pytest run: | - pytest --fixtures -v --cov-config .coveragerc --cov=geomeppy tests --cov-report=xml + pytest -v --cov-config .coveragerc --cov=geomeppy tests --cov-report=xml - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v3 + with: + files: ./coverage.xml + fail_ci_if_error: true - name: Build and publish to test pypi if: github.ref == 'refs/heads/develop' uses: JRubics/poetry-publish@v1.13 diff --git a/.gitignore b/.gitignore index 67a0ad10..86777aeb 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,6 @@ dist .mypy_cache venv + +coverage +coverage.xml diff --git a/tests/conftest.py b/tests/conftest.py index 8a0f39f6..8321ef60 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """A module containing pytest fixtures that are used in multiple places in the test suite.""" +import os import pytest from eppy.iddcurrent import iddcurrent @@ -6,6 +7,12 @@ from geomeppy.idf import IDF + +def on_ci(): + """Helper to check if we're running on a CI platform.""" + return os.environ.get("CI", "") != "0" + + base_idf_txt = """ Version, 8.5; Building, Building 1, , , , , , , ; diff --git a/tests/test_tutorial.py b/tests/test_tutorial.py index 0e845156..3fe6aecb 100644 --- a/tests/test_tutorial.py +++ b/tests/test_tutorial.py @@ -8,6 +8,7 @@ from geomeppy import IDF from geomeppy.extractor import copy_constructions +from tests.conftest import on_ci _, EPLUS_HOME = paths_from_version("9-1-0") @@ -37,7 +38,7 @@ def tmp_dir(): shutil.rmtree(p) -@pytest.mark.skipif(os.environ.get("CI"), reason="Running without EnergyPlus installed") +@pytest.mark.skipif(on_ci(), reason="Running without EnergyPlus installed") @pytest.mark.usefixtures("tmp_dir") def test_tutorial_1(): IDF.setiddname(f"{EPLUS_HOME}/Energy+.idd", testing=True) @@ -53,7 +54,7 @@ def test_tutorial_1(): idf.run(output_directory="tests/tutorial") -@pytest.mark.skipif(os.environ.get("CI"), reason="Running without EnergyPlus installed") +@pytest.mark.skipif(on_ci(), reason="Running without EnergyPlus installed") @pytest.mark.usefixtures("tmp_dir") def test_tutorial_2(): IDF.setiddname(f"{EPLUS_HOME}/Energy+.idd", testing=True) @@ -121,7 +122,7 @@ def test_tutorial_2(): print(row_format.format(*row)) -@pytest.mark.skipif(os.environ.get("CI"), reason="Running without EnergyPlus installed") +@pytest.mark.skipif(on_ci(), reason="Running without EnergyPlus installed") @pytest.mark.usefixtures("tmp_dir") def test_tutorial_3(): IDF.setiddname(f"{EPLUS_HOME}/Energy+.idd", testing=True)