From 10086913ba8fc9e0e6e58852ad7f55fd802afa05 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Mon, 28 Aug 2023 21:21:10 -0700 Subject: [PATCH 1/2] add coverage config, run cov for unit test --- .github/workflows/test.yaml | 8 ++++++-- pyproject.toml | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 522666870..f30b98bb4 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 eebff1089..e9ba07b5a 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 From 25806c44392bf7ef6b72bcc2ac33864c59482e96 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Thu, 31 Aug 2023 06:25:21 -0700 Subject: [PATCH 2/2] debug ci --- src/_nebari/provider/cloud/commons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_nebari/provider/cloud/commons.py b/src/_nebari/provider/cloud/commons.py index a12dbec8b..566b2029a 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)