Python 项目代码覆盖率徽章与工作服/github 操作

mat*_*ner 8 github pytest coveralls pytest-cov github-actions

我正在尝试将代码覆盖率 % 徽章添加到我的存储库 README.md 中

我目前正在使用 Github actions 来自动化我的 pytest 测试。我自己就完成了这个工作,但我一直在努力获得覆盖率%徽章。我正在使用工作服来生成徽章,并且基于它,工作服看起来需要一个 lcov.info 文件。但是当我查看pytest-cov 的报告选项时,我没有看到相应的输出选项。

我尝试生成其他类型(例如 xml)并配置以查找此类型,但它仍然在覆盖文件夹中查找 lcov.info。下面是我当前的 pythonapp.yml 文件。当前失败的步骤是寻找工作服./coverage/lcov.info

任何有关我做错了什么或如何修复的帮助将不胜感激。

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
Run Code Online (Sandbox Code Playgroud)

小智 5

在我看来,“path-to-lcov”的参数名称中有一个额外的连字符

根据此处的文档:https ://github.com/marketplace/actions/coveralls-github-action

尝试将“path--to-lcov”更改为“path-to-lcov”