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..687ad5d 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/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.