-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (81 loc) · 2.74 KB
/
dotnet.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Building and testing .NET
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build projects
run: dotnet build --no-restore
test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests and collect code coverage (Cobertura)
run: dotnet test --results-directory "coverage" --collect:"Code Coverage;Format=cobertura"
- name: Install dotnet-coverage
run: dotnet tool update --global dotnet-coverage
- name: Merge coverage reports
run: dotnet-coverage merge coverage/**/*.cobertura.xml --output coverage/cobertura.xml --output-format cobertura
- name: Install ReportGenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Run ReportGenerator to generate Markdown summary
run: reportgenerator -reports:coverage/cobertura.xml -targetdir:coverage -reporttypes:"MarkdownSummaryGithub"
- name: Display Markdown summary
run: cat coverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: Upload coverage report artifact
uses: actions/upload-artifact@v4
with:
name: cobertura.xml
path: coverage/cobertura.xml
coverage-codecov:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download coverage report artifact
uses: actions/download-artifact@v4
with:
name: cobertura.xml
- name: Display structure of downloaded files
run: ls -R cobertura.xml
- name: Upload coverage report to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: cobertura.xml
use_oidc: false
verbose: true
coverage-codacy:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download coverage report artifact
uses: actions/download-artifact@v4
with:
name: cobertura.xml
- name: Display coverage report file
run: ls -lah cobertura.xml
- name: Upload coverage report to Codacy
uses: codacy/[email protected]
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: cobertura.xml