From 38ee1fc76c63e7ad8072b34a3b667aaae9f5c97b Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Tue, 3 Dec 2024 22:10:30 +0100 Subject: [PATCH] QA: Configure pytest and add coverage tracking using Codecov.io --- .github/workflows/tests.yml | 11 +++++++++++ .gitignore | 2 ++ Makefile | 2 +- pyproject.toml | 16 +++++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dce19c6..276af8b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,3 +38,14 @@ jobs: - name: Run linters and software tests run: poe check + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: ./coverage.xml + flags: unittests + env_vars: OS,PYTHON + name: codecov-umbrella + fail_ci_if_error: true diff --git a/.gitignore b/.gitignore index 1a31bf1..239656f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ .DS_Store gecko.log *.orig +.coverage +coverage.xml diff --git a/Makefile b/Makefile index 04dd2b1..3b388ce 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ setup-virtualenv: # Test # ---- test: setup-virtualenv - $(pytest) -vvv tests + $(pytest) format-js: brew install prettier diff --git a/pyproject.toml b/pyproject.toml index 1487e5a..d621138 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,6 +80,7 @@ optional-dependencies.release = [ optional-dependencies.test = [ "freezegun>=1,<2", "pytest>=6,<9", + "pytest-cov<7", ] urls.Homepage = "https://github.com/grafana-toolbox/grafanimate" urls.Issues = "https://github.com/grafana-toolbox/grafanimate/issues" @@ -100,7 +101,7 @@ lint.select = [ # pyupgrade # "UP", # flake8-commas - "COM", + # "COM", # Pycodestyle "E", # eradicate @@ -163,6 +164,19 @@ lint.per-file-ignores."tests/*" = [ profile = "black" src_paths = [ "grafanimate", "tests" ] +[tool.pytest.ini_options] +addopts = "-rA --verbosity=3 --cov --cov-report=term-missing --cov-report=xml" +minversion = "2.0" +log_level = "DEBUG" +log_cli_level = "DEBUG" +log_format = "%(asctime)-15s [%(name)-36s] %(levelname)-8s: %(message)s" +testpaths = [ + "grafanimate", + "tests", +] +xfail_strict = true +markers = [ +] [tool.poe.tasks] check = [