Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python project code coverage badge with coveralls / github actions

I'm trying to add a code coverage % badge to my repos README.md

I'm currently using Github actions to automate my pytest testing. I had that working on its own, but ive been struggling trying to get the coverage % badge. I am using coveralls for the badge generation, and based on it looks like coveralls is expecting an lcov.info file. But when I look at the reporting options for pytest-cov I don't see an output option for that.

I've tried generating other types such as xml and configuring to look for this but it still looks for the lcov.info in the coverage folder. below is my current pythonapp.yml file. the current step that fails is the coveralls with it looking for ./coverage/lcov.info

Any assistance on what im doing wrong or how to fix would be greatly appreciated.

name: tests

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.7
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Lint with flake8
      run: |
        pip install flake8
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
    - name: Test with pytest
      run: |
        pip install pytest pytest-cov
        python -m pytest --cov=./myapp --cov-report xml
    - name: Coveralls
      uses: coverallsapp/github-action@master
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        path--to-lcov: coverage.xml
like image 986
matthewmturner Avatar asked Nov 07 '22 08:11

matthewmturner


1 Answers

Looks to me like you have an extra hyphen in the name of the argument for "path-to-lcov"

According to the docs here: https://github.com/marketplace/actions/coveralls-github-action

Try changing "path--to-lcov" to "path-to-lcov"

like image 110
Ava Avatar answered Nov 15 '22 13:11

Ava