Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用GitHub操作收集代码覆盖率_Github_Github Actions - Fatal编程技术网

使用GitHub操作收集代码覆盖率

使用GitHub操作收集代码覆盖率,github,github-actions,Github,Github Actions,我有一个Azure管道构建步骤,如下所示: - task: PublishCodeCoverageResults@1 displayName: 'collect code coverage' inputs: codeCoverageTool: 'cobertura' summaryFileLocation: $(Build.SourcesDirectory)\Coverage\coverage.cobertura.xml

我有一个Azure管道构建步骤,如下所示:

    - task: PublishCodeCoverageResults@1
      displayName: 'collect code coverage'
      inputs:
        codeCoverageTool: 'cobertura'
        summaryFileLocation: $(Build.SourcesDirectory)\Coverage\coverage.cobertura.xml
        failIfCoverageEmpty: false
      
    - task: mspremier.BuildQualityChecks.QualityChecks-task.BuildQualityChecks@6
      displayName: 'check build quality'
      inputs:
        checkCoverage: true
        coverageFailOption: fixed
        coverageType: lines
        coverageThreshold: 1

如何将这些转换为GitHub操作?

您可以使用codecov之类的代码覆盖率仪表板来收集代码覆盖率。在Azure DevOps中,代码覆盖率视图位于Azure Pipelines视图中,但GitHub不提供这样的视图。CodeCov,工作服来帮忙。其他可以在中找到

示例用法如下所示:

- name: Test with pytest
  run: |
    pytest  --instafail --cov=./src --cov-report xml --cov-branch tests/unittests
- name: Codecov
  uses: codecov/codecov-action@v1.0.13
  with:
    token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
    file: ./coverage.xml # optional
    flags: unittests # optional
    name: codecov # optional
    fail_ci_if_error: false # optional (default = false)