Skip to content

Commit

Permalink
Fix coveralls reporting (#399)
Browse files Browse the repository at this point in the history
Fixes unit test coverage upload to coveralls.io

Results:
https://coveralls.io/github/jorisroovers/gitlint
  • Loading branch information
jorisroovers committed Feb 28, 2023
1 parent d463132 commit 09a6f0b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,31 @@ jobs:
run: hatch run dev:gitlint --debug
continue-on-error: ${{ github.event_name == 'pull_request' }} # Don't enforce gitlint in PRs

# Coveralls integration doesn't properly work at this point, also see below
# - name: Coveralls
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
# run: coveralls

# Patch the commit-msg hook to make it work in GH CI
# Specifically, within the commit-msg hook, wrap the invocation of gitlint with `script`

# Coveralls GH Action currently doesn't support current non-LCOV reporting format
# For now, still using Travis for unit test coverage reporting
# https://github.com/coverallsapp/github-action/issues/30
# - name: Coveralls
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Code Coverage (coveralls)
uses: coverallsapp/github-action@master
with:
path-to-lcov: ".coverage.lcov"
github-token: ${{ secrets.GITHUB_TOKEN }}
git-commit: ${{ github.event.pull_request.head.sha }}
flag-name: gitlint-${{ matrix.os }}-${{ matrix.python-version }}
parallel: true

upload_coveralls:
needs: checks
runs-on: ubuntu-latest
steps:
- name: Upload coverage to coveralls
uses: coverallsapp/github-action@master
with:
path-to-lcov: ".coverage.lcov"
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

check: # This job does nothing and is only used for the branch protection
if: always() # Ref: https://github.com/marketplace/actions/alls-green#why

needs:
- upload_coveralls
- checks

runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# gitlint: [jorisroovers.github.io/gitlint](http://jorisroovers.github.io/gitlint/) #

[![Tests](https://github.com/jorisroovers/gitlint/workflows/Tests%20and%20Checks/badge.svg)](https://github.com/jorisroovers/gitlint/actions?query=workflow%3A%22Tests+and+Checks%22)
[![Coverage Status](https://coveralls.io/repos/github/jorisroovers/gitlint/badge.svg?branch=fix-coveralls)](https://coveralls.io/github/jorisroovers/gitlint?branch=fix-coveralls)
[![PyPi Package](https://img.shields.io/pypi/v/gitlint.png)](https://pypi.python.org/pypi/gitlint)
![Supported Python Versions](https://img.shields.io/pypi/pyversions/gitlint.svg)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dependencies = [

[tool.hatch.envs.test.scripts]
unit-tests = [
"pytest --cov=gitlint-core -rw -s {args:gitlint-core}", #
"pytest --cov=gitlint-core --cov-report=term --cov-report=lcov:.coverage.lcov -rw -s {args:gitlint-core}",
]
u = "unit-tests"
unit-tests-no-cov = "pytest -rw -s {args:gitlint-core}"
Expand Down

0 comments on commit 09a6f0b

Please sign in to comment.