-
Notifications
You must be signed in to change notification settings - Fork 0
427 lines (358 loc) · 13.8 KB
/
Copy pathci.yml
File metadata and controls
427 lines (358 loc) · 13.8 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
name: CI
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
docs:
name: Documentation
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -D warnings
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build rustdoc
run: cargo doc --workspace --all-features --no-deps --locked
mdbook:
name: mdBook
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: taiki-e/install-action@mdbook
- name: Build mdBook
run: mdbook build
- name: Configure GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/configure-pages@v5
- name: Upload GitHub Pages artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/upload-pages-artifact@v4
with:
path: target/mdbook
deploy-pages:
name: Deploy GitHub Pages
runs-on: ubuntu-latest
needs: mdbook
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy artifact
id: deployment
uses: actions/deploy-pages@v4
docs-hygiene:
name: Documentation hygiene
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Check package README targets
shell: bash
run: |
missing=0
while IFS= read -r manifest; do
dir=${manifest%/Cargo.toml}
package_name=$(sed -n 's/^name = "\([^"]*\)"/\1/p' "$manifest" | head -1)
[ -z "$package_name" ] && continue
readme=$(sed -n 's/^readme = "\([^"]*\)"/\1/p' "$manifest" | head -1)
if [ -z "$readme" ]; then
if [ ! -f "$dir/README.md" ]; then
printf '%s: package has no README.md and no readme target\n' "$manifest"
missing=1
fi
continue
fi
if [ ! -e "$dir/$readme" ]; then
printf '%s: readme target does not exist: %s\n' "$manifest" "$readme"
missing=1
fi
done < <(find . \( -path './.git' -o -path './target' -o -path './node_modules' -o -path '*/node_modules' \) -prune -o -name Cargo.toml -print | sort)
exit "$missing"
- name: Check local Markdown links
shell: bash
run: |
broken=0
while IFS=$'\t' read -r file raw; do
dir=${file%/*}
[ "$dir" = "$file" ] && dir=.
link=${raw%%[[:space:]]*}
link=${link#<}
link=${link%>}
link=${link%%#*}
case "$link" in
''|'#'*|http://*|https://*|mailto:*|file:*|javascript:*)
continue
;;
esac
target="$dir/$link"
if [ ! -e "$target" ]; then
printf '%s: broken local Markdown link: %s\n' "$file" "$raw"
broken=1
fi
done < <(
find . \( -path './.git' -o -path './target' -o -path './node_modules' -o -path '*/node_modules' \) -prune -o -name '*.md' -type f -print0 |
xargs -0 perl -ne 'while (/\[[^\]]+\]\(([^)]+)\)/g) { print "$ARGV\t$1\n" }'
)
exit "$broken"
supply-chain:
name: Supply chain policy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-deny
- uses: Swatinem/rust-cache@v2
- run: cargo deny check
test:
name: Test (workspace)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Build tests
run: cargo nextest run --workspace --all-targets --all-features --locked --no-run
- name: Run tests (nextest, no retries)
run: cargo nextest run --workspace --all-targets --all-features --locked --profile ci
- name: Run doctests
run: cargo test --doc --workspace --all-features --locked
- name: Upload JUnit report
if: always()
uses: actions/upload-artifact@v7.0.1
with:
name: junit-tests
path: target/nextest/ci/junit.xml
if-no-files-found: ignore
retention-days: 14
feature-matrix:
name: Feature matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Check macro crates without defaults
run: cargo check -p ras-rest-macro -p ras-jsonrpc-macro -p ras-jsonrpc-bidirectional-macro -p ras-file-macro --no-default-features --locked
- name: Check REST macro server-only
run: cargo check -p ras-rest-macro --no-default-features --features server --locked
- name: Check REST macro client-only
run: cargo check -p ras-rest-macro --no-default-features --features client --locked
- name: Check JSON-RPC macro server-only
run: cargo check -p ras-jsonrpc-macro --no-default-features --features server --locked
- name: Check JSON-RPC macro client-only
run: cargo check -p ras-jsonrpc-macro --no-default-features --features client --locked
- name: Check bidirectional macro server-only
run: cargo check -p ras-jsonrpc-bidirectional-macro --no-default-features --features server --locked
- name: Check bidirectional macro client-only
run: cargo check -p ras-jsonrpc-bidirectional-macro --no-default-features --features client --locked
- name: Check bidirectional native client
run: cargo check -p ras-jsonrpc-bidirectional-client --no-default-features --features native --locked
- name: Check bidirectional WASM client
run: cargo check -p ras-jsonrpc-bidirectional-client --no-default-features --features wasm --target wasm32-unknown-unknown --locked
- name: Check example API crates without defaults
run: cargo check -p basic-jsonrpc-api -p rest-api -p file-service-api -p bidirectional-chat-api -p oauth2-demo-api --no-default-features --locked
- name: Check example API crates server-only
run: cargo check -p basic-jsonrpc-api -p rest-api -p file-service-api -p bidirectional-chat-api -p oauth2-demo-api --no-default-features --features basic-jsonrpc-api/server,rest-api/server,file-service-api/server,bidirectional-chat-api/server,oauth2-demo-api/server --locked
- name: Check example API crates client-only
run: cargo check -p basic-jsonrpc-api -p rest-api -p file-service-api -p bidirectional-chat-api -p oauth2-demo-api --no-default-features --features basic-jsonrpc-api/client,rest-api/client,file-service-api/client,bidirectional-chat-api/client,oauth2-demo-api/client --locked
- name: Check inline file-service example server feature
run: cargo check -p file-service-example --no-default-features --features server --locked
playwright:
name: Playwright E2E
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
- name: Setup Node
uses: actions/setup-node@v6.4.0
with:
node-version: 22.13
cache: npm
cache-dependency-path: tests/playwright/package-lock.json
- name: Install Playwright package
working-directory: tests/playwright
run: npm ci
- name: Install Playwright browsers
working-directory: tests/playwright
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
working-directory: tests/playwright
run: npm test
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v7.0.1
with:
name: playwright-report
path: tests/playwright/playwright-report
if-no-files-found: ignore
retention-days: 7
- name: Upload Playwright test results
if: failure()
uses: actions/upload-artifact@v7.0.1
with:
name: playwright-test-results
path: tests/playwright/test-results
if-no-files-found: ignore
retention-days: 7
generated-client-specs:
name: Generated client specs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Generate OpenAPI specs
run: cargo check -p file-service-backend -p rest-backend --locked
- name: Verify generated OpenAPI specs
run: |
test -s examples/file-service-wasm/file-service-backend/target/openapi/documentservice.json
test -s examples/rest-wasm-example/rest-backend/target/openapi/userservice.json
wasm-ui-example:
name: WASM UI example
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Check browser API clients
run: >
cargo check
-p basic-jsonrpc-api
-p rest-api
-p file-service-api
--target wasm32-unknown-unknown
--no-default-features
--features basic-jsonrpc-api/client,rest-api/client,file-service-api/client
--locked
- name: Setup Node
uses: actions/setup-node@v6.4.0
with:
node-version: 22.13
cache: npm
cache-dependency-path: examples/wasm-ui-demo/package-lock.json
- name: Build WASM UI example
working-directory: examples/wasm-ui-demo
run: |
npm ci
npm run build
- name: Install Playwright package
working-directory: tests/playwright
run: npm ci
- name: Install Playwright browsers
working-directory: tests/playwright
run: npx playwright install --with-deps chromium
- name: Run WASM UI browser tests
working-directory: tests/playwright
run: npm test -- --config wasm-ui.config.ts
- name: Upload WASM UI test results
if: failure()
uses: actions/upload-artifact@v7.0.1
with:
name: wasm-ui-test-results
path: tests/playwright/test-results
if-no-files-found: ignore
retention-days: 7
coverage:
name: Coverage report
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov,nextest
- uses: Swatinem/rust-cache@v2
- name: Coverage for this ref
run: |
cargo llvm-cov nextest --workspace --all-targets --all-features --locked \
--lcov --output-path lcov.info
cargo llvm-cov report --json --output-path coverage-head.json
cargo llvm-cov report --summary-only | tee coverage-head.txt
- name: Coverage for base (PR only)
if: github.event_name == 'pull_request'
run: |
base=$(git merge-base "origin/${{ github.base_ref }}" HEAD)
git stash --include-untracked -q || true
git checkout -q "$base"
cargo llvm-cov nextest --workspace --all-targets --all-features --locked \
--json --output-path coverage-base.json || echo '{}' > coverage-base.json
git checkout -q -
git stash pop -q || true
- name: Build coverage summary
id: summary
shell: bash
run: |
python3 .github/scripts/coverage_summary.py \
coverage-head.json \
"${{ github.event_name == 'pull_request' && 'coverage-base.json' || '' }}" \
> coverage-summary.md
cat coverage-summary.md >> "$GITHUB_STEP_SUMMARY"
- name: Comment on PR
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ github.event.pull_request.number }}
run: |
marker='<!-- ras-coverage-report -->'
body="$(printf '%s\n' "$marker"; cat coverage-summary.md)"
existing=$(gh api "repos/${{ github.repository }}/issues/$PR/comments" \
--jq ".[] | select(.body | startswith(\"$marker\")) | .id" | head -1)
if [ -n "$existing" ]; then
gh api -X PATCH "repos/${{ github.repository }}/issues/comments/$existing" -f body="$body" >/dev/null
else
gh pr comment "$PR" --body "$body"
fi
- name: Upload coverage artifact
uses: actions/upload-artifact@v7.0.1
with:
name: coverage-lcov
path: |
lcov.info
coverage-head.json
coverage-summary.md
retention-days: 30