This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
80 lines (68 loc) · 2.84 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: 'PageUp Dotnet Core Code Coverage Action'
author: "PageUp"
description: "Execute code coverage analysis for .net core apps"
inputs:
failBuild:
description: 'Fail build on below low range coverage'
default: 'false'
required: false
percentLowRange:
description: 'The percentage level below which your coverage is "red"'
default: '50'
required: false
percentHighRange:
description: 'The percentage level above which your coverage is "green"'
default: '80'
required: false
includeFullReport:
description: 'Generate a full html codecoverage report as an artifact'
default: 'true'
required: false
runs:
using: "composite"
steps:
- run: dotnet tool install --global dotnet-coverage
shell: bash
- run: dotnet tool install --global dotnet-reportgenerator-globaltool
shell: bash
- run: curl https://raw.githubusercontent.com/PageUpPeopleOrg/pageup-code-coverage-action/main/coverage.settings -o coverage.settings
shell: bash
- run: find . -name "*.sln" -exec dotnet build {} --configuration Release \;
shell: bash
- run: find . -name "*.sln" -exec sh -c 'dotnet coverage collect "dotnet test "$1" --no-build --no-restore" --settings:coverage.settings --output ./Tests/CodeCoverage-$(basename "$1") --output-format cobertura' sh {} \;
shell: bash
- run: "[ $INCLUDE_FULL_REPORT == 'true' ] && reportgenerator -reports:./Tests/*cobertura.xml -targetdir:./tests/coveragereport -reporttypes:Html"
shell: bash
env:
INCLUDE_FULL_REPORT: ${{ inputs.includeFullReport }}
- name: Upload coverage report artifact
uses: actions/upload-artifact@v3
with:
name: CoverageReport
path: tests/coveragereport
retention-days: 30
- name: Generate Code Coverage PR report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: Tests/*cobertura.xml
badge: true
fail_below_min: ${{ inputs.failBuild }}
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: '${{ inputs.percentLowRange }} ${{ inputs.percentHighRange }}'
- run: "[ $INCLUDE_FULL_REPORT == 'true' ] && echo -e '\r\nSee full report under \'artifacts\' [here]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)' >> code-coverage-results.md"
shell: bash
env:
INCLUDE_FULL_REPORT: ${{ inputs.includeFullReport }}
- name: Write to Job Summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
shell: bash
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md