-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (209 loc) · 7.55 KB
/
Copy pathpr.yml
File metadata and controls
253 lines (209 loc) · 7.55 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
name: PR Checks
on:
pull_request:
branches: [main]
jobs:
lint-and-test-ts:
name: TypeScript Lint & Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/Nap.VsCode
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: src/Nap.VsCode/package-lock.json
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.fsproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Install dependencies
run: npm ci
- name: Format check
run: npm run format:check
- name: Lint
run: npm run lint
- name: Build CLI, compile extension & tests
run: npm run pretest
- name: Unit tests with coverage
run: npm run test:unit
- name: E2E tests
run: xvfb-run --auto-servernum npm test
- name: Extract TypeScript coverage percentage
id: ts-coverage
run: |
COVERAGE=$(npx c8 report --reporter text 2>/dev/null | grep 'All files' | awk '{print $4}' || echo "0")
echo "coverage=$COVERAGE" >> "$GITHUB_OUTPUT"
- name: Check TypeScript coverage threshold
run: |
ACTUAL="${{ steps.ts-coverage.outputs.coverage }}"
THRESHOLD="${{ vars.TS_COVERAGE_THRESHOLD }}"
echo "TypeScript coverage: ${ACTUAL}% (threshold: ${THRESHOLD}%)"
if [ -z "$THRESHOLD" ] || [ "$THRESHOLD" = "0" ]; then
echo "No threshold set — skipping"
exit 0
fi
if (( $(echo "$ACTUAL < $THRESHOLD" | bc -l) )); then
echo "::error::TypeScript coverage ${ACTUAL}% is below threshold ${THRESHOLD}%"
exit 1
fi
- name: Upload TypeScript coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: typescript-coverage
path: src/Nap.VsCode/coverage/
test-fsharp:
name: F# Build & Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.fsproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Install ReportGenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Install dotnet-script
run: dotnet tool install -g dotnet-script
- name: Restore tools
run: dotnet tool restore
- name: Format check (Fantomas)
run: dotnet fantomas --check src/
- name: Restore
run: dotnet restore
- name: Build (warnings are errors)
run: dotnet build --no-restore --nologo -warnaserror
- name: Test with coverage
run: bash scripts/test-fsharp.sh
- name: Extract Nap.Core coverage percentage
id: napcore-coverage
run: |
COVERAGE=$(grep -oP 'Line coverage: \K[0-9.]+' coverage/fsharp/report/Summary.txt || echo "0")
echo "coverage=$COVERAGE" >> "$GITHUB_OUTPUT"
- name: Check Nap.Core coverage threshold
run: |
ACTUAL="${{ steps.napcore-coverage.outputs.coverage }}"
THRESHOLD="${{ vars.FSHARP_COVERAGE_THRESHOLD }}"
echo "Nap.Core coverage: ${ACTUAL}% (threshold: ${THRESHOLD}%)"
if [ -z "$THRESHOLD" ] || [ "$THRESHOLD" = "0" ]; then
echo "No threshold set — skipping"
exit 0
fi
if (( $(echo "$ACTUAL < $THRESHOLD" | bc -l) )); then
echo "::error::Nap.Core coverage ${ACTUAL}% is below threshold ${THRESHOLD}%"
exit 1
fi
- name: Extract DotHttp coverage percentage
id: dothttp-coverage
run: |
COVERAGE=$(grep -oP 'Line coverage: \K[0-9.]+' coverage/dothttp/report/Summary.txt || echo "0")
echo "coverage=$COVERAGE" >> "$GITHUB_OUTPUT"
- name: Check DotHttp coverage threshold
run: |
ACTUAL="${{ steps.dothttp-coverage.outputs.coverage }}"
THRESHOLD="${{ vars.DOTHTTP_COVERAGE_THRESHOLD }}"
echo "DotHttp coverage: ${ACTUAL}% (threshold: ${THRESHOLD}%)"
if [ -z "$THRESHOLD" ] || [ "$THRESHOLD" = "0" ]; then
echo "No threshold set — skipping"
exit 0
fi
if (( $(echo "$ACTUAL < $THRESHOLD" | bc -l) )); then
echo "::error::DotHttp coverage ${ACTUAL}% is below threshold ${THRESHOLD}%"
exit 1
fi
- name: Upload F# coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: fsharp-coverage
path: coverage/fsharp/report/
- name: Upload DotHttp coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: dothttp-coverage
path: coverage/dothttp/report/
test-rust:
name: Rust Build & Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/Nap.Zed
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache Cargo registry and build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
src/Nap.Zed/target
key: ${{ runner.os }}-cargo-${{ hashFiles('src/Nap.Zed/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Format check
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Test with coverage
run: cargo tarpaulin --out xml html --output-dir ../../coverage/rust/report --skip-clean
- name: Extract Rust coverage percentage
id: rust-coverage
run: |
COVERAGE=$(grep -oP 'line-rate="\K[0-9.]+' ../../coverage/rust/report/cobertura.xml 2>/dev/null || echo "0")
COVERAGE_PCT=$(echo "$COVERAGE * 100" | bc -l | xargs printf "%.2f")
echo "coverage=$COVERAGE_PCT" >> "$GITHUB_OUTPUT"
- name: Check Rust coverage threshold
run: |
ACTUAL="${{ steps.rust-coverage.outputs.coverage }}"
THRESHOLD="${{ vars.RUST_COVERAGE_THRESHOLD }}"
echo "Rust coverage: ${ACTUAL}% (threshold: ${THRESHOLD}%)"
if [ -z "$THRESHOLD" ] || [ "$THRESHOLD" = "0" ]; then
echo "No threshold set — skipping"
exit 0
fi
if (( $(echo "$ACTUAL < $THRESHOLD" | bc -l) )); then
echo "::error::Rust coverage ${ACTUAL}% is below threshold ${THRESHOLD}%"
exit 1
fi
- name: Upload Rust coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: rust-coverage
path: coverage/rust/report/
build-website:
name: Website Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: website
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: website/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build
run: npx eleventy