-
-
Notifications
You must be signed in to change notification settings - Fork 19
125 lines (103 loc) · 3.89 KB
/
Copy pathcoverage.yml
File metadata and controls
125 lines (103 loc) · 3.89 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Coverage
on:
workflow_run:
workflows:
- build-and-test
types:
- completed
branches:
- main
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: coverage-pages
cancel-in-progress: true
jobs:
coverage:
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 1
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
10.0.x
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.slnx') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore FixedMathSharp.slnx --property:Configuration=Release
- name: Build solution
run: dotnet build FixedMathSharp.slnx --configuration Release --no-restore
- name: Run tests with coverage
run: dotnet test tests/FixedMathSharp.Tests/FixedMathSharp.Tests.csproj --configuration Release --no-build --collect:"XPlat Code Coverage" --settings tests/FixedMathSharp.Tests/coverlet.runsettings --results-directory artifacts/coverage
- name: Restore local tools
run: dotnet tool restore
- name: Build API documentation
run: |
test -f src/FixedMathSharp/bin/Release/net8.0/FixedMathSharp.dll
test -f src/FixedMathSharp/bin/Release/net8.0/FixedMathSharp.xml
dotnet tool run docfx docs/api/docfx.json
test -f docs/api/obj/_site/index.html
test -f docs/api/obj/_site/api/FixedMathSharp.html
test -f docs/api/obj/_site/assets/icon_128x128.png
grep -q "github.com/mrdav30/FixedMathSharp" docs/api/obj/_site/public/main.js
grep -q "FixedMathSharp-Unity" docs/api/obj/_site/api/FixedMathSharp.html
- name: Install ReportGenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Add ReportGenerator to PATH
run: echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
- name: Generate coverage report
run: |
reportgenerator \
"-reports:artifacts/coverage/**/coverage.cobertura.xml" \
"-targetdir:artifacts/coverage-report" \
"-reporttypes:Html;MarkdownSummaryGithub;Badges;JsonSummary" \
"-filefilters:-**/MemoryPack.Generator/**;-**/*.g.cs;-**/obj/**"
- name: Add coverage summary to job
run: cat artifacts/coverage-report/SummaryGithub.md >> "$GITHUB_STEP_SUMMARY"
- name: Assemble Pages site
run: |
mkdir -p artifacts/pages/coverage
cp -a docs/api/obj/_site/. artifacts/pages/
cp -a artifacts/coverage-report/. artifacts/pages/coverage/
test -f artifacts/pages/index.html
test -f artifacts/pages/api/FixedMathSharp.html
test -f artifacts/pages/coverage/Summary.json
- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: artifacts/coverage-report
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: artifacts/pages
deploy:
needs: coverage
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Configure Pages
uses: actions/configure-pages@v6
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5