forked from ical-org/ical.net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub workflow for code coverage calculation (ical-org#624)
* Add GitHub workflow for code coverage calculation At the moment the workflow is "on demand". Should become part of the test workflow, if everything works fine. Final workflow code is commented out. * Enable trigger for pull request and push to main * Add code coverage configuration file for Codecov
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Code Coverage | ||
# This job runs unit tests and generates a code coverage report. | ||
# The report is stored as artifact, and uploaded to Codecov. | ||
|
||
on: | ||
# workflow_dispatch: {} # temporarily enable the workflow for manual runs | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
coverage: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: | | ||
8.0.x | ||
- name: Restore dependencies --verbosity quiet | ||
run: dotnet restore | ||
- name: Add AltCover package to test project | ||
run: dotnet add ./Ical.Net.Tests/Ical.Net.Tests.csproj package AltCover | ||
|
||
- name: Build | ||
run: dotnet build --no-restore --configuration Release -p:nowarn=1591 | ||
- name: Test | ||
run: dotnet test --no-build --configuration Release --verbosity quiet /p:AltCover=true /p:AltCoverXmlReport="coverage.xml" /p:AltCoverStrongNameKey="../IcalNetStrongnameKey.snk" /p:AltCoverAssemblyExcludeFilter="Ical.Net.Tests|NUnit3.TestAdapter|AltCover" /p:AltCoverAttributeFilter="ExcludeFromCodeCoverage" /p:AltCoverLineCover="false" | ||
|
||
- name: Store coverage report as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-report | ||
path: ./Ical.Net.Tests/coverage.*.xml # store all coverage reports | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
# files: automatically finds all in ./Ical.Net.Tests/ | ||
name: coverage | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
coverage: | ||
precision: 0 # no decimals | ||
round: nearest # round up/down | ||
range: "80...100" | ||
|
||
status: | ||
project: # show status on project level | ||
default: | ||
target: 80 # Set the target coverage percentage | ||
patch: # show status on patch level | ||
default: | ||
target: 80 # minimum coverage for successful commit | ||
|
||
comment: | ||
layout: "reach, diff, flags, files" | ||
behavior: default | ||
require_changes: true # Only comment if there are changes in coverage |