From c6c6102de9190b49eb3e2f2dcbe34cd2c2dc8cdc Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Wed, 12 Aug 2026 22:36:10 +0300 Subject: [PATCH 1/2] ci: measure test coverage and add Codecov badge --- .github/workflows/coverage.yml | 36 ++++++++++++++++++++++++++++++++++ .gitignore | 6 ++++++ README.md | 1 + 3 files changed, 43 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..fb4b15a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,36 @@ +name: Coverage + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + # 3.10 is the real floor, see test.yml + python-version: "3.10" + - name: Install dependencies + run: | + pip install -r requirements.txt + pip install pytest pytest-cov + - name: Run tests with coverage + run: | + pytest --cov=main --cov-report=xml --cov-report=term-missing main_test.py + - name: Upload coverage to Codecov + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 + with: + files: ./coverage.xml + flags: unittests + name: codecov-umbrella + # Hard-fail on push to main so a broken upload is visible; on PRs the + # report is informational and a flaky upload should not block review. + fail_ci_if_error: ${{ github.event_name == 'push' }} diff --git a/.gitignore b/.gitignore index ab3375b..f840b9c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,9 @@ venv/ .venv/ __pycache__/ result.txt + +# pytest-cov +.coverage +.coverage.* +coverage.xml +htmlcov/ diff --git a/README.md b/README.md index 1e4ddd9..66522a9 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![GitHub marketplace](https://img.shields.io/badge/Marketplace-commit--check--action-blue)](https://github.com/marketplace/actions/commit-check-action) [![commit-check](https://img.shields.io/badge/commit--check-enabled-brightgreen?logo=Git&logoColor=white&color=%232c9ccd)](https://github.com/commit-check/commit-check) [![slsa-badge](https://slsa.dev/images/gh-badge-level3.svg?color=blue)](https://github.com/commit-check/commit-check-action/blob/a2873ca0482dd505c93fb51861c953e82fd0a186/action.yml#L59-L69) +[![codecov](https://codecov.io/gh/commit-check/commit-check-action/branch/main/graph/badge.svg?token=G3R0LFO0YF)](https://codecov.io/gh/commit-check/commit-check-action) A GitHub Action for checking commit message formatting, branch naming, committer name, email, commit signoff, and more. From 97c01ec6bc92c19c3d583c85c95d43f45e0cdce3 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Wed, 12 Aug 2026 22:42:15 +0300 Subject: [PATCH 2/2] chore: Change Codecov badge token Updated Codecov badge token in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66522a9..687ad5d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub marketplace](https://img.shields.io/badge/Marketplace-commit--check--action-blue)](https://github.com/marketplace/actions/commit-check-action) [![commit-check](https://img.shields.io/badge/commit--check-enabled-brightgreen?logo=Git&logoColor=white&color=%232c9ccd)](https://github.com/commit-check/commit-check) [![slsa-badge](https://slsa.dev/images/gh-badge-level3.svg?color=blue)](https://github.com/commit-check/commit-check-action/blob/a2873ca0482dd505c93fb51861c953e82fd0a186/action.yml#L59-L69) -[![codecov](https://codecov.io/gh/commit-check/commit-check-action/branch/main/graph/badge.svg?token=G3R0LFO0YF)](https://codecov.io/gh/commit-check/commit-check-action) +[![codecov](https://codecov.io/gh/commit-check/commit-check-action/graph/badge.svg?token=QHUDSMJGS7)](https://codecov.io/gh/commit-check/commit-check-action) A GitHub Action for checking commit message formatting, branch naming, committer name, email, commit signoff, and more.