-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (79 loc) · 2.7 KB
/
ci.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
name: Build and Test
run-name: CI • ${{ github.run_number }} • ${{ github.event.head_commit.message }}
on:
push:
branches:
- main
paths-ignore:
- '.github/coveragereport/**'
- 'docs/**'
- '*.md'
pull_request:
branches:
- main
permissions:
contents: write
actions: read
checks: write
packages: write
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v4
- name: ⚙️ Setup dotnet 9.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear
- name: 🏗️ Restore dependencies
run: dotnet restore
- name: 🛠️ Build solution
run: dotnet build --no-restore -c:Release
- name: 🧪 Run tests
run: dotnet test --no-build -c:Release --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" || true
- name: 📋 Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: Test Report
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true
- name: 📭 Restore coverage history
uses: dawidd6/action-download-artifact@v3
with:
name: CoverageHistory
path: CoverageHistory
continue-on-error: true
- name: 📝 Generate Coverage report
uses: danielpalme/[email protected]
with:
reports: "**/coverage.cobertura.xml"
targetdir: .github/coveragereport
historydir: CoverageHistory
reporttypes: MarkdownSummaryGithub;MarkdownDeltaSummary;Badges
filefilters: -*.g.cs
tag: '${{ github.run_number }}_${{ github.run_id }}'
- name: 📨 Post code coverage results
run: |
cat .github/coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: 📬 Upload coverage history
uses: actions/upload-artifact@v4
with:
name: CoverageHistory
path: CoverageHistory
- name: 🪧 Commit and push Badges
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
run: |
cd .github/coveragereport
git add badge_*coverage.svg
if [[ `git status --porcelain badge_*coverage.svg` ]]; then
git config --global user.email "${{github.actor}}@users.noreply.github.com"
git config --global user.name "${{github.actor}}"
git commit -m "Autogenerated coverage badge" badge_*coverage.svg
git push
fi