Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
codecovv
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshHare committed Sep 22, 2024
1 parent 5ea14ae commit 4974dca
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,18 @@ jobs:
- name: Build
run: dotnet build --no-restore

# Run tests and generate coverage report in Cobertura format
- name: Run tests and generate coverage report
# Step 5: Run tests and collect code coverage
- name: Test and calculate coverage
run: |
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --results-directory ./TestResults
dotnet test --no-build --verbosity normal \
/p:CollectCoverage=true /p:CoverletOutputFormat=opencover \
/p:CoverletOutput=./TestResults/coverage.opencover.xml
# Install ReportGenerator
- name: Install ReportGenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool

# Add .NET tools to PATH using environment file
- name: Add .NET tools to PATH
run: echo "${HOME}/.dotnet/tools" >> $GITHUB_PATH

# Convert coverage report to Codecov format
- name: Convert coverage to Codecov format
run: |
reportgenerator "-reports:./TestResults/**/coverage.cobertura.xml" "-targetdir:./coverage" "-reporttypes:Cobertura"
# Upload coverage to Codecov
# Step 6: Upload the code coverage report to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/Cobertura.xml
token: ${{ secrets.CODECOV_TOKEN }} # Add the Codecov token in the GitHub secrets
files: ./TestResults/coverage.opencover.xml # Ensure the correct path for the coverage file
flags: unittests
fail_ci_if_error: true

0 comments on commit 4974dca

Please sign in to comment.