Repository navigation
169 lines (140 loc) · 5.82 KB
/
Copy pathcoverage.yml
File metadata and controls
169 lines (140 loc) · 5.82 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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: |
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/net10.0/FixedMathSharp.dll
test -f src/FixedMathSharp/bin/Release/net10.0/FixedMathSharp.xml
test -f src/FixedMathSharp.Chronicler/bin/Release/net10.0/FixedMathSharp.Chronicler.dll
test -f src/FixedMathSharp.Chronicler/bin/Release/net10.0/FixedMathSharp.Chronicler.xml
dotnet tool run docfx docs/api/docfx.json --warningsAsErrors
test -f docs/api/obj/_site/index.html
test -f docs/api/obj/_site/api/FixedMathSharp.html
test -f docs/api/obj/_site/api/FixedMathSharp.Chronicler.html
for guide in index getting-started fixed64-representation full-domain-wide-arithmetic coordinate-conventions bounds-and-geometry finite-shape-contacts diagnostics-formatting overview; do
test -f "docs/api/obj/_site/guides/${guide}.html"
done
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
python3 - <<'PY'
from html.parser import HTMLParser
from pathlib import Path
from urllib.parse import unquote, urlsplit
site = Path("docs/api/obj/_site").resolve()
broken = []
class Links(HTMLParser):
def __init__(self):
super().__init__()
self.hrefs = []
def handle_starttag(self, tag, attrs):
if tag == "a":
href = dict(attrs).get("href")
if href:
self.hrefs.append(href)
for page in site.rglob("*.html"):
parser = Links()
parser.feed(page.read_text(encoding="utf-8"))
for href in parser.hrefs:
parsed = urlsplit(href)
if parsed.scheme or parsed.netloc or not parsed.path:
continue
path = unquote(parsed.path)
target = site / path.lstrip("/") if path.startswith("/") else page.parent / path
target = target.resolve()
if target.is_dir():
target /= "index.html"
if not target.exists():
broken.append(f"{page.relative_to(site)} -> {href}")
if broken:
raise SystemExit("Broken local links:\n" + "\n".join(sorted(broken)))
PY
- 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