diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 606ba3c..94f5d09 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,8 +33,7 @@ jobs: runs-on: ubuntu-latest permissions: - contents: write - pull-requests: write + contents: read steps: - name: Checkout @@ -45,25 +44,13 @@ jobs: - name: Run pytest run: | - set -o pipefail - uv run nox -s test -- --junitxml pytest.xml | tee pytest-coverage.txt + uv run nox -s test -- --cov_report xml - - name: Pytest coverage comment - uses: MishaKav/pytest-coverage-comment@v1 + - name: Upload results to Codecov + uses: codecov/codecov-action@v5 with: - pytest-coverage-path: ./pytest-coverage.txt - junitxml-path: ./pytest.xml - - - name: Creating coverage folder - run: mkdir -p coverage - - - name: Coverage Badge - uses: tj-actions/coverage-badge-py@v2 - with: - output: coverage/coverage.svg - - - name: Publish coverage report to coverage-badge branch - uses: JamesIves/github-pages-deploy-action@v4 - with: - branch: coverage-badge - folder: coverage + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + flags: unittests + name: codecov-umbrella + fail_ci_if_error: true diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 8ec5de8..032c48a 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -42,7 +42,6 @@ "ipython", "isort", "jaxtyping", - "junitxml", "kevinrose", "kwargs", "levelname", @@ -108,6 +107,7 @@ "toolsai", "typer", "uline", + "unittests", "usecases", "usefixtures", "usermod", diff --git a/CLAUDE.md b/CLAUDE.md index 69de42a..af067fd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,7 +34,7 @@ uv run nox -s test uv run pytest tests/tools/test__logger.py # Run with JUnit XML output for CI -uv run nox -s test -- --junitxml=results.xml +uv run nox -s test -- --cov_report=xml # Run pytest directly (bypasses nox) uv run pytest diff --git a/README.md b/README.md index 519cc85..2d378b1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![Docker](https://github.com/a5chin/python-uv/actions/workflows/docker.yml/badge.svg)](https://github.com/a5chin/python-uv/actions/workflows/docker.yml) [![Format](https://github.com/a5chin/python-uv/actions/workflows/format.yml/badge.svg)](https://github.com/a5chin/python-uv/actions/workflows/format.yml) [![Lint](https://github.com/a5chin/python-uv/actions/workflows/lint.yml/badge.svg)](https://github.com/a5chin/python-uv/actions/workflows/lint.yml) -[![Test](https://github.com/a5chin/python-uv/actions/workflows/test.yml/badge.svg)](https://github.com/a5chin/python-uv/actions/workflows/test.yml) +[![codecov](https://codecov.io/github/a5chin/python-uv/graph/badge.svg?token=M9JIB8T6R4)](https://codecov.io/github/a5chin/python-uv) @@ -164,7 +164,7 @@ uv run nox -s lint -- --ruff uv run nox -s test # Run tests with JUnit XML output (for CI) -uv run nox -s test -- --junitxml=results.xml +uv run nox -s test -- --cov_report=xml ``` You can also run tools directly: @@ -338,17 +338,17 @@ Automated workflows ensure code quality and consistency. All workflows run on pu **Available workflows in `.github/workflows/`:** -| Workflow | Purpose | Tools Used | -|----------|---------|-----------| -| `docker.yml` | Validate Docker build | Docker | -| `devcontainer.yml` | Validate Dev Container configuration | devcontainer CLI | -| `format.yml` | Check code formatting | Ruff | -| `labeler.yml` | Add label in GitHub | GitHub | -| `lint.yml` | Run static analysis | Ruff, ty | -| `test.yml` | Run test suite with coverage | pytest, coverage | -| `gh-deploy.yml` | Deploy documentation to GitHub Pages | MkDocs | -| `pr-agent.yml` | Automated PR reviews | Qodo AI PR Agent | -| `publish-devcontainer.yml` | Publish Dev Container image | Docker, GHCR | +| Workflow | Purpose | Tools Used | +| -------------------------- | ------------------------------------ | ---------------- | +| `docker.yml` | Validate Docker build | Docker | +| `devcontainer.yml` | Validate Dev Container configuration | devcontainer CLI | +| `format.yml` | Check code formatting | Ruff | +| `labeler.yml` | Add label in GitHub | GitHub | +| `lint.yml` | Run static analysis | Ruff, ty | +| `test.yml` | Run test suite with coverage | pytest, coverage | +| `gh-deploy.yml` | Deploy documentation to GitHub Pages | MkDocs | +| `pr-agent.yml` | Automated PR reviews | Qodo AI PR Agent | +| `publish-devcontainer.yml` | Publish Dev Container image | Docker, GHCR | ## 🎨 VSCode Configuration diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 0000000..d9e0bd5 --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,29 @@ +codecov: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "50...75" + + status: + project: + default: + target: auto + threshold: 0% + if_ci_failed: error + patch: + default: + target: 75% + +comment: + layout: "reach, diff, flags, files, header, footer" + behavior: default + require_changes: false + require_head: false + require_base: false + +ignore: + - "tests/*" + - "noxfile.py" + - "**/__init__.py" diff --git a/docs/guides/index.md b/docs/guides/index.md index cafe22f..f250c53 100644 --- a/docs/guides/index.md +++ b/docs/guides/index.md @@ -39,7 +39,7 @@ uv run nox -s lint -- --ty # ty only uv run nox -s test # Run tests with JUnit XML output (for CI) -uv run nox -s test -- --junitxml=results.xml +uv run nox -s test -- --cov_report=xml ``` ### Why nox? diff --git a/noxfile.py b/noxfile.py index e0da3be..a16ef63 100644 --- a/noxfile.py +++ b/noxfile.py @@ -13,7 +13,7 @@ class CLIArgs( ): """CLIArgs is a class that extends BaseSettings to handle command line arguments.""" - junitxml: str = "" + cov_report: str = "" ruff: bool = False sqlfluff: bool = False ty: bool = False @@ -101,9 +101,9 @@ def test(session: nox.Session) -> None: """ args = CLIArgs.parse(session.posargs) - command = ["uv", "run", "pytest"] - if args.junitxml: - command.append(f"--junitxml={args.junitxml}") + command = ["uv", "run", "pytest", "--cov", "--cov-branch"] + if args.cov_report: + command.append(f"--cov-report={args.cov_report}") session.run(*command)