Skip to content

AndreMiras/coveralls-python-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

coveralls-python-action

push Coverage Status

GitHub Action for Python Coveralls.io

Screenshot

coveralls-python-action

Usage

First make sure your coverage.py is configured with relative_files = True. See the Coverage.py configuration section for examples. If this setting is missing you will likely get an error "not a git repository".

Then assuming you have a make test that runs coverage testing. The following workflow will upload it to coveralls.io.

name: push
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v5

    - name: Unit tests
      run: make test

    - name: Coveralls
      uses: AndreMiras/coveralls-python-action@develop
      with:
        parallel: true
        flag-name: Unit Test

  coveralls_finish:
    needs: test
    runs-on: ubuntu-latest
    steps:
    - name: Coveralls Finished
      uses: AndreMiras/coveralls-python-action@develop
      with:
        parallel-finished: true

Configuration

- uses: AndreMiras/coveralls-python-action@develop
  with:
    # The `GITHUB_TOKEN` or `COVERALLS_REPO_TOKEN`.
    # Default: ${{ github.token }}
    github-token: ''
    # Set to `true` if you are using parallel jobs, then use `parallel-finished: true` for the last action.
    # Default: false
    parallel: ''
    # Set to `true` for the last action when using `parallel: true`.
    # Default: false
    parallel-finished: ''
    # A name to identify the current job. This is useful in combination with `parallel: true`.
    # Default: null
    flag-name: ''
    # A sub-directory in which coverage was executed.
    # Default: '.'
    base-path: ''
    # Set to true to increase logger verbosity.
    # Default: false
    debug: ''

Coverage.py configuration

The relative_files = True setting can be handled via different files such as .coveragerc, tox.ini and more, all covered in the examples below. Also see the Coverage.py configuration reference for full details.

.coveragerc

Under the [run] section:

[run]
relative_files = True

setup.cfg or tox.ini

Under the [coverage:run] section:

[coverage:run]
relative_files = True

pyproject.toml

Under the [tool.coverage.run] section. It also requires coverage to be installed with the toml extra (pip install coverage[toml]):

[tool.coverage.run]
relative_files = true