diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 522666870a..f30b98bb4f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -47,9 +47,13 @@ jobs: channels: conda-forge - name: Install Nebari run: | - pip install .[dev] + pip install -e .[dev] conda install --quiet --yes conda-build - name: Test Nebari run: | pytest --version - pytest --ignore=tests/tests_deployment --ignore=tests/tests_e2e/playwright --ignore=tests/tests_integration + pytest --cov=src --cov-report=xml --cov-config=pyproject.toml tests/tests_unit + + - name: Report Coverage + run: | + coverage report -m diff --git a/pyproject.toml b/pyproject.toml index eebff10895..e9ba07b5a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,6 +87,8 @@ dev = [ "pytest", "pytest-timeout", "pytest-playwright", + "pytest-cov", + "coverage[toml]", "grayskull", "build", "jinja2", @@ -115,3 +117,26 @@ extend-exclude = [ "home", "__pycache__" ] + +[tool.coverage.run] +branch = true + +[tool.coverage.report] +# Regexes for lines to exclude from consideration +exclude_also = [ + # Don't complain about missing debug-only code: + "def __repr__", + "if self\\.debug", + + # Don't complain if tests don't hit defensive assertion code: + "raise AssertionError", + "raise NotImplementedError", + + # Don't complain if non-runnable code isn't run: + "if 0:", + "if __name__ == .__main__.:", + + # Don't complain about abstract methods, they aren't run: + "@(abc\\.)?abstractmethod", + ] +ignore_errors = false diff --git a/src/_nebari/provider/cloud/commons.py b/src/_nebari/provider/cloud/commons.py index a12dbec8bf..566b2029a4 100644 --- a/src/_nebari/provider/cloud/commons.py +++ b/src/_nebari/provider/cloud/commons.py @@ -7,7 +7,7 @@ def filter_by_highest_supported_k8s_version(k8s_versions_list): filtered_k8s_versions_list = [] for k8s_version in k8s_versions_list: version = tuple( - filter(None, re.search("(\d+)\.(\d+)(?:\.(\d+))?", k8s_version).groups()) + filter(None, re.search(r"(\d+)\.(\d+)(?:\.(\d+))?", k8s_version).groups()) ) if version <= HIGHEST_SUPPORTED_K8S_VERSION: filtered_k8s_versions_list.append(k8s_version)