Skip to content

codecovv

codecovv #5

Workflow file for this run

name: Codecov Coverage
on:
push:
branches:
- main
- codecov-workflows
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
# Checkout code
- name: Checkout code
uses: actions/checkout@v2
# Setup .NET environment
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x # Use the version your project requires
# Restore dependencies
- name: Restore dependencies
run: dotnet restore
# Build the project
- name: Build
run: dotnet build --no-restore
# Step 5: Run tests and collect code coverage
- name: Test and calculate coverage
run: |
dotnet test --no-build --verbosity normal \
/p:CollectCoverage=true /p:CoverletOutputFormat=opencover \
/p:CoverletOutput=./TestResults/coverage.opencover.xml
# Step 6: Upload the code coverage report to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
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