Repository: kokorin/dbt-pumpkin (language: python)

Issue:
Measure code coverage
```sh
hatch test --cover
'coverage' is not recognized as an internal or external command,
operable program or batch file.
```


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 34b2cb1..ab9c123 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -5,10 +5,6 @@ on:
     types:
       - released
 env:
-  PIP_CACHE_DIR: .cache/pip
-  HATCH_CACHE_DIR: .cache/hatch
-  UV_CACHE_DIR: .cache/uv
-
   HATCH_INDEX_USER: __token__
   HATCH_INDEX_REPO: main
   HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
diff --git a/.gitignore b/.gitignore
index df7be7b..6e0842a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,5 +4,9 @@ __pycache__
 /.idea
 /dist
 
+#coverage reports
+/.coverage
+/coverage.xml
+
 #auto-generated
 /dbt_pumpkin/version.py
diff --git a/README.md b/README.md
index f1b29aa..f0ef87e 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
 # DBT-PUMPKIN
 
+[![codecov](https://codecov.io/github/kokorin/dbt-pumpkin/graph/badge.svg?token=EKGRIWEIMZ)](https://codecov.io/github/kokorin/dbt-pumpkin)
+
 `dbt-pumpkin` is a command-line tool which helps to manage [DBT](https://docs.getdbt.com/docs/introduction) projects.
 
 Inspired by [dbt-osmosis](https://z3z1ma.github.io/dbt-osmosis/)
diff --git a/pyproject.toml b/pyproject.toml
index e831363..a9bb379 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -26,7 +26,6 @@ source = "versioningit"
 
 [tool.hatch.build]
 exclude = [
-  "/.cache",
   "/.github",
   "/tests",
   "/.pre-commit-config.yaml",
@@ -49,12 +48,18 @@ EXPECTED_PYTHON_VERSION = "3.12"
 EXPECTED_DBT_VERSION = "1.8"
 
 [tool.hatch.envs.hatch-test]
-dependencies = [
-  "pytest",
+extra-dependencies = [
   "dbt-core~={matrix:dbt}.0",
   "dbt-duckdb~={matrix:dbt}.0"
 ]
 
+[tool.hatch.envs.hatch-test.scripts]
+# To change cov-report script we have to re-define all other scripts too
+run = "pytest{env:HATCH_TEST_ARGS:} {args}"  # default
+run-cov = "coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}"  # default
+cov-combine = "coverage combine"  # default
+cov-report = ["coverage report", "coverage xml"]  # xml added
+
 [tool.hatch.envs.hatch-test.env-vars]
 EXPECTED_PYTHON_VERSION = "{matrix:python}"
 EXPECTED_DBT_VERSION = "{matrix:dbt}"
@@ -67,16 +72,15 @@ dbt = ["1.5", "1.6", "1.7", "1.8"]
 python = ["3.12"]
 dbt = ["1.7", "1.8"]
 
+[tool.coverage.report]
+include = ["dbt_pumpkin/**"]
+
 [tool.versioningit]
 
 [tool.versioningit.vcs]
 method = "git"
 default-tag = "v0.0.0"
 
-[tool.ruff]
-# cache directory for GH actions
-extend-exclude = [".cache"]
-
 [tool.yamlfix]
 explicit_start = false
 whitelines = 1


Test patch:
diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml
index e2f176d..db3c324 100644
--- a/.github/workflows/test-release.yml
+++ b/.github/workflows/test-release.yml
@@ -6,10 +6,6 @@ on:
       - main
       - release/**
 env:
-  PIP_CACHE_DIR: .cache/pip
-  PRE_COMMIT_HOME: .cache/pre-commit
-  HATCH_CACHE_DIR: .cache/hatch
-
   HATCH_INDEX_USER: __token__
   HATCH_INDEX_REPO: test
   HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_TOKEN }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 29d4dc7..694caaf 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -10,11 +10,6 @@ on:
       - opened
       - reopened
       - synchronize
-env:
-  PIP_CACHE_DIR: .cache/pip
-  PRE_COMMIT_HOME: .cache/pre-commit
-  HATCH_CACHE_DIR: .cache/hatch
-  UV_CACHE_DIR: .cache/uv
 jobs:
   test:
     strategy:
@@ -39,3 +34,18 @@ jobs:
       - run: pre-commit run --from-ref origin/main --to-ref HEAD
       - run: hatch fmt --check
       - run: hatch test --all
+
+  coverage:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - uses: actions/setup-python@v5
+        with:
+          python-version: 3.12
+          cache: pip
+      - run: pip install hatch
+      - run: hatch test --cover
+      - uses: codecov/codecov-action@v4.5.0
+        with:
+          verbose: true
+          token: ${{ secrets.CODECOV_TOKEN }}