-
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (88 loc) · 3.41 KB
/
Copy pathcode-coverage.yml
File metadata and controls
103 lines (88 loc) · 3.41 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Code Coverage
# Disabled on push/PR: duplicates Linux CI test run (~6 min) and mostly repeats pass/fail
# without blocking merges. Run manually via workflow_dispatch when you want a coverage
# report, Code Quality upload, or PR comment refresh.
on:
workflow_dispatch:
concurrency:
group: code-coverage-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
code-quality: write
pull-requests: write
jobs:
dotnet:
name: .NET coverage
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
cache: true
cache-dependency-path: |
**/packages.lock.json
NuGet.config
- name: Restore dependencies
run: dotnet restore Trackdub.slnx -m:1
- name: Build solution filter
run: dotnet build Trackdub.slnx -c Release --framework net10.0 --no-restore -m:1
- name: Run tests with coverage
run: |
dotnet test Trackdub.slnx -c Release --framework net10.0 --no-build -m:1 \
--collect:"XPlat Code Coverage" \
--results-directory ./coverage \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
- name: Cache ReportGenerator dotnet tool
uses: actions/cache@v6
with:
path: ~/.dotnet/tools
key: dotnet-tool-reportgenerator-5.4.4
- name: Merge Cobertura reports
run: |
dotnet tool update -g dotnet-reportgenerator-globaltool --version 5.4.4 || dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.4.4
reportgenerator \
"-reports:./coverage/**/coverage.cobertura.xml" \
"-targetdir:./coverage-report" \
"-reporttypes:Cobertura;MarkdownSummaryGithub"
- name: Upload coverage to GitHub Code Quality
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: actions/upload-code-coverage@v1
with:
file: ./coverage-report/Cobertura.xml
language: CSharp
label: code-coverage/dotnet
- name: Publish coverage summary
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
with:
filename: coverage-report/Cobertura.xml
badge: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
- name: Comment coverage on pull request
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3
with:
header: code-coverage
recreate: true
path: code-coverage-results.md
- name: Write job summary
run: cat coverage-report/SummaryGithub.md >> "$GITHUB_STEP_SUMMARY"
- name: Upload merged coverage artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: dotnet-coverage
path: |
coverage-report/Cobertura.xml
coverage-report/SummaryGithub.md
if-no-files-found: ignore