Description
I have a mono-repo with a c# backend. I use Coverlet to generate a report. I’ve tried the following formats; json, lcov, opencover, cobertura. All result in 0% coverage when sent to Codecov. It does however show the graph of all files.
Repository
Commit SHAs
a53cebf39b43d60368042d8a2a99936661925bd9
Codecov YAML
codecov:
require_ci_to_pass: yes
branch: dev
coverage:
precision: 2
round: down
range: "70...100"
parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no
comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: no
Additional Information
He is the GitHub action I use to generate and send the report to Codecov.
name: API (.NET Core)
on:
push:
branches: [master, dev]
pull_request:
branches: [master, dev]
jobs:
build:
runs-on: ubuntu-latest
env:
working-directory: ./backend
codeCov-token: ${{ secrets.CodeCov }}
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Install dependencies
run: dotnet restore
working-directory: ${{env.working-directory}}
- name: Install coverlet for code coverage
run: dotnet tool install -g coverlet.console
working-directory: ${{env.working-directory}}
- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: ${{env.working-directory}}
- name: Test
run: dotnet test --no-restore --verbosity normal
working-directory: ${{env.working-directory}}
- name: Generate code coverage
run: coverlet ./tests/unit/api/bin/Release/netcoreapp3.1/Pims.Api.Test.dll --target "dotnet" --targetargs "test ./ --no-build" -o "./tests/TestResults/api-coverage.json" --exclude "[*.Test]*" --exclude "[*]*Model" --exclude-by-attribute "CompilerGenerated" -f json
working-directory: ${{env.working-directory}}
- name: Merge code coverage
run: coverlet ./tests/unit/dal/bin/Release/netcoreapp3.1/Pims.Dal.Test.dll --target "dotnet" --targetargs "test ./ --no-build" -o "./tests/TestResults/" --exclude "[*.Test]*" --exclude "[*]*Model" --exclude-by-attribute "CompilerGenerated" --merge-with "./tests/TestResults/api-coverage.json" -f lcov
working-directory: ${{env.working-directory}}
- name: Codecov
uses: codecov/codecov-action@v1.0.7
with:
# User defined upload name. Visible in Codecov UI
name: PIMS
# Repository upload token - get it from codecov.io. Required only for private repositories
token: ${{env.codeCov-token}}
# Path to coverage file to upload
file: ${{env.working-directory}}/tests/TestResults/coverage.info
# Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)
flags: unittests
# Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)
env_vars: C#
# Specify whether or not CI build should fail if Codecov runs into an error during upload
fail_ci_if_error: true