Repository navigation
671 lines (649 loc) · 28.5 KB
/
Copy pathtest-cedarling.yml
File metadata and controls
671 lines (649 loc) · 28.5 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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
name: "Test: Cedarling"
on:
pull_request:
branches:
- main
paths:
- "jans-cedarling/**"
push:
branches:
- main
paths:
- "jans-cedarling/**"
workflow_dispatch:
permissions:
contents: read
jobs:
rust_tests:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
components: clippy
- name: Ensure clippy is installed
run: rustup component add --toolchain stable clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: jans-cedarling
- name: Run Tests (without default features)
working-directory: jans-cedarling/cedarling
run: cargo test --locked --no-default-features
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Tests
working-directory: jans-cedarling
run: cargo test --locked --workspace
- name: Run Clippy on native target
working-directory: jans-cedarling
run: cargo +stable clippy --workspace --all-targets -- -D warnings
cargo_audit:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Get week stamp for advisory DB cache key
id: date
run: echo "week=$(date +%Y-%U)" >> $GITHUB_OUTPUT
- name: Cache advisory database
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ~/.cargo/advisory-db
# Refresh weekly; advisory-db- fallback reuses the most recent weekly snapshot.
key: advisory-db-${{ steps.date.outputs.week }}
restore-keys: advisory-db-
- name: Install cargo-audit
uses: taiki-e/install-action@9bcaee1dcae34154180f412e2fa69355a7cda9f6 # v2.82.6
with:
tool: cargo-audit
- name: Run cargo-audit
working-directory: jans-cedarling
# rustsec/audit-check uses the GitHub API to fetch the advisory DB and hits
# rate limits on PRs. Running cargo-audit directly with a cached advisory DB
# avoids the API calls entirely.
# RUSTSEC-2023-0071: `rsa` Marvin timing sidechannel affects RSA decryption.
# Cedarling only uses `jsonwebtoken` for signature verification; the
# decryption path is not reachable. No upstream fix available.
run: cargo audit --ignore RUSTSEC-2023-0071
cargo_deny:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Install cargo-deny
uses: taiki-e/install-action@9bcaee1dcae34154180f412e2fa69355a7cda9f6 # v2.82.6
with:
tool: cargo-deny@0.19.2
- name: Run cargo-deny
working-directory: jans-cedarling
# deny.toml also sets graph.all-features; the flag is kept to match the
# previous cargo-deny-action invocation.
run: cargo deny --all-features check
rust_benchmarks:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: jans-cedarling
- name: Run benchmarks
working-directory: jans-cedarling
run: cargo bench --workspace
- name: Run script to analyze benchmarks
working-directory: jans-cedarling
run: |
set -o pipefail
python3 scripts/check_benchmarks.py | tee rust_bench_output.txt
- name: Append Rust benchmark summary
working-directory: jans-cedarling
run: |
python3 scripts/parse_binding_benchmarks.py --format rust rust_bench_output.txt >> $GITHUB_STEP_SUMMARY
- name: Run Rust canonical benchmark harness
working-directory: jans-cedarling/cedarling
run: |
set -o pipefail
cargo run --release --example bench_jsonl | tee bench_output.jsonl
python3 ../scripts/parse_binding_benchmarks.py --format jsonl bench_output.jsonl >> $GITHUB_STEP_SUMMARY
- name: Upload Rust bench JSONL
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: bench-jsonl-rust
path: jans-cedarling/cedarling/bench_output.jsonl
retention-days: 7
wasm_tests:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install chromium
run: sudo apt-get update && sudo apt-get install chromium-chromedriver
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
components: clippy
targets: wasm32-unknown-unknown
- name: Ensure clippy is installed
run: rustup component add --toolchain stable clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: jans-cedarling
- name: Install specific wasm-pack version (v0.14.0)
run: |
archive="${RUNNER_TEMP}/wasm-pack-v0.14.0-x86_64-unknown-linux-musl.tar.gz"
curl --fail --location --silent --show-error --output "$archive" https://github.com/wasm-bindgen/wasm-pack/releases/download/v0.14.0/wasm-pack-v0.14.0-x86_64-unknown-linux-musl.tar.gz
printf '%s %s\n' '278a8d668085821f4d1a637bd864f1713f872b0ae3a118c77562a308c0abfe8d' "$archive" | sha256sum --check --strict
sudo tar xzf "$archive" -C /usr/local/bin --strip-components=1
wasm-pack --version
- name: Run WASM tests using chrome
working-directory: jans-cedarling/bindings/cedarling_wasm
run: wasm-pack test --headless --chrome
- name: Run WASM tests using firefox
working-directory: jans-cedarling/bindings/cedarling_wasm
run: |
# Work around Snap Firefox confinement on ubuntu-latest:
# Snap Firefox cannot access /tmp profiles, so redirect TMPDIR under $HOME
export TMPDIR="${HOME}/tmp"
mkdir -p "$TMPDIR"
wasm-pack test --headless --firefox
- name: Build WASM for Node.js (benchmarks)
working-directory: jans-cedarling/bindings/cedarling_wasm
run: wasm-pack build --target nodejs --release
- name: Run WASM binding benchmarks
working-directory: jans-cedarling/bindings/cedarling_wasm
run: |
node benchmarks/benchmark.mjs | tee bench_output.jsonl
python3 ../../scripts/parse_binding_benchmarks.py --format jsonl bench_output.jsonl >> $GITHUB_STEP_SUMMARY
- name: Upload WASM bench JSONL
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: bench-jsonl-wasm
path: jans-cedarling/bindings/cedarling_wasm/bench_output.jsonl
retention-days: 7
- name: Run Clippy on WASM target
working-directory: jans-cedarling
run: cargo +stable clippy -p cedarling_wasm --target wasm32-unknown-unknown -- -D warnings
cedarling_wasm_test:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
node-version: ['22.x', '24.x', '26.x']
include:
- node-version: '22.x'
publication: true
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: jans-cedarling
- name: Install wasm-pack
run: |
archive="${RUNNER_TEMP}/wasm-pack-v0.14.0-x86_64-unknown-linux-musl.tar.gz"
curl --fail --location --silent --show-error --output "$archive" https://github.com/wasm-bindgen/wasm-pack/releases/download/v0.14.0/wasm-pack-v0.14.0-x86_64-unknown-linux-musl.tar.gz
printf '%s %s\n' '278a8d668085821f4d1a637bd864f1713f872b0ae3a118c77562a308c0abfe8d' "$archive" | sha256sum --check --strict
sudo tar xzf "$archive" -C /usr/local/bin --strip-components=1
wasm-pack --version
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: |
jans-cedarling/bindings/cedarling_wasm/js/package-lock.json
jans-cedarling/bindings/cedarling_wasm/js/examples/package-lock.json
- name: Install npm used for Cedarling WebAssembly package publication
if: matrix.publication
run: npm install --global npm@12.0.2
- name: Build WASM for Cedarling WebAssembly JavaScript package
working-directory: jans-cedarling/bindings/cedarling_wasm
run: wasm-pack build --release --locked --target web --scope janssenproject
- name: Install Cedarling WebAssembly JavaScript dependencies
working-directory: jans-cedarling/bindings/cedarling_wasm/js
run: npm ci --ignore-scripts
- name: Install Cedarling WebAssembly JavaScript browsers
working-directory: jans-cedarling/bindings/cedarling_wasm/js
run: npx playwright install --with-deps chromium firefox webkit
- name: Run Cedarling WebAssembly JavaScript checks
working-directory: jans-cedarling/bindings/cedarling_wasm/js
run: npm run check
- name: Qualify publishable Cedarling WebAssembly JavaScript archive
if: matrix.publication
working-directory: jans-cedarling/bindings/cedarling_wasm/js
run: |
output="${RUNNER_TEMP}/cedarling-wasm-publish"
node scripts/stage-packages.mjs --version 0.0.0-ci --publishable --output "${output}"
npm publish "${output}/janssenproject-cedarling_wasm-0.0.0-ci.tgz" --dry-run --access=public --tag ci
- name: Install Cedarling WebAssembly JavaScript example dependencies
if: matrix.node-version == '22.x'
working-directory: jans-cedarling/bindings/cedarling_wasm/js/examples
run: npm ci --ignore-scripts
- name: Run Cedarling WebAssembly JavaScript examples
if: matrix.node-version == '22.x'
working-directory: jans-cedarling/bindings/cedarling_wasm/js/examples
run: npm run check
python_tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip || echo "Failed to upgrade pip"
python3 -m pip install tox
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Test with pytest
working-directory: jans-cedarling/bindings/cedarling_python
run: tox
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884
name: Install uv
with:
version: "0.11.3"
- name: Test sidecar
working-directory: jans-cedarling/flask-sidecar
run: |
uv tool install tox --with tox-uv-bare
tox
- name: Run Python binding benchmarks
if: matrix.python-version == '3.11'
working-directory: jans-cedarling/bindings/cedarling_python
run: |
tox -e benchmark | tee bench_output.jsonl
python3 ../../scripts/parse_binding_benchmarks.py --format jsonl bench_output.jsonl >> $GITHUB_STEP_SUMMARY
- name: Upload Python bench JSONL
if: matrix.python-version == '3.11'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: bench-jsonl-python
path: jans-cedarling/bindings/cedarling_python/bench_output.jsonl
retention-days: 7
golang_tests:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: jans-cedarling
- name: Install Golang dependencies
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
# minor-only spec so setup-go tracks the latest patch; 1.24 is past
# Go's two-major support window and receives no security fixes
go-version: '1.26'
cache-dependency-path: jans-cedarling/bindings/cedarling_go/go.sum
- name: Build Rust artifacts
working-directory: jans-cedarling/bindings/cedarling_go
run: |
cargo build -r --locked -p cedarling_go
cp "../../target/release/libcedarling_go.so" "."
- name: Install Go dependencies
working-directory: jans-cedarling/bindings/cedarling_go
run: go mod download && go mod tidy -v && git --no-pager diff --exit-code go.mod go.sum || (echo 'go.mod or go.sum changed; run go mod tidy and commit' && exit 1)
- name: Run golang tests
working-directory: jans-cedarling/bindings/cedarling_go
run: |
export LD_LIBRARY_PATH="$(pwd):${LD_LIBRARY_PATH}"
go test .
- name: Run Go binding benchmarks
working-directory: jans-cedarling/bindings/cedarling_go
run: |
export LD_LIBRARY_PATH="$(pwd):${LD_LIBRARY_PATH}"
go run ./benchmarks/ | tee bench_output.jsonl
python3 ../../scripts/parse_binding_benchmarks.py --format jsonl bench_output.jsonl >> $GITHUB_STEP_SUMMARY
- name: Upload Go bench JSONL
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: bench-jsonl-go
path: jans-cedarling/bindings/cedarling_go/bench_output.jsonl
retention-days: 7
c_tests:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: jans-cedarling
- name: Build Rust C library
working-directory: jans-cedarling/bindings/cedarling_c
run: |
cargo build --release --locked -p cedarling_c
test -f target/include/cedarling_c.h || (echo "header missing" && exit 1)
- name: Build and run C tests
working-directory: jans-cedarling/bindings/cedarling_c
run: |
export LD_LIBRARY_PATH="../../target/release:${LD_LIBRARY_PATH}"
cd tests
make
./test_cedarling
- name: Run C binding benchmarks
working-directory: jans-cedarling/bindings/cedarling_c
run: |
export LD_LIBRARY_PATH="../../target/release:${LD_LIBRARY_PATH}"
cd benchmarks && make
./benchmark_cedarling | tee bench_output.jsonl
python3 ../../../scripts/parse_binding_benchmarks.py --format jsonl bench_output.jsonl >> $GITHUB_STEP_SUMMARY
- name: Upload C bench JSONL
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: bench-jsonl-c
path: jans-cedarling/bindings/cedarling_c/benchmarks/bench_output.jsonl
retention-days: 7
jans_trace_java_tests:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: jans-cedarling
# The lowest Java version the binding supports, so the tests run where Lock runs.
- name: Set up JDK 11
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: temurin
java-version: "11"
cache: maven
cache-dependency-path: jans-cedarling/bindings/jans-trace-java/pom.xml
- name: Build native library and Kotlin bindings
working-directory: jans-cedarling/bindings/jans-trace-java
run: make
- name: Build jar and run Java tests
working-directory: jans-cedarling/bindings/jans-trace-java
run: mvn -B -ntp clean verify
uniffi_benchmarks:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Protoc
uses: arduino/setup-protoc@3ea1d70ac22caff0b66ed6cb37d5b7aadebd4623
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # stable
with:
toolchain: stable
- name: Set up Java
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9
with:
distribution: temurin
java-version: "17"
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: jans-cedarling
- name: Build UniFFI Java artifacts
working-directory: jans-cedarling/bindings/cedarling_uniffi
run: make java
- name: Run UniFFI Java benchmarks
working-directory: jans-cedarling/bindings/cedarling_uniffi/javaApp
run: |
export LD_LIBRARY_PATH="${GITHUB_WORKSPACE}/target/release:${LD_LIBRARY_PATH}"
mvn -q compile exec:java -Dexec.mainClass=org.example.Benchmark | tee bench_output.jsonl
python3 "${GITHUB_WORKSPACE}/jans-cedarling/scripts/parse_binding_benchmarks.py" --format jsonl bench_output.jsonl >> $GITHUB_STEP_SUMMARY
- name: Upload UniFFI Java bench JSONL
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: bench-jsonl-java
path: jans-cedarling/bindings/cedarling_uniffi/javaApp/bench_output.jsonl
retention-days: 7
cross_binding_bench_summary:
runs-on: ubuntu-latest
needs:
- rust_benchmarks
- wasm_tests
- python_tests
- golang_tests
- c_tests
- uniffi_benchmarks
if: always()
# Serialize publish runs so concurrent main pushes don't race the
# force-push / PR creation; never cancel an in-flight publish.
concurrency:
group: cedarling-bench-docs
cancel-in-progress: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Download all bench JSONL artifacts
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
path: bench-artifacts
pattern: bench-jsonl-*
merge-multiple: false
- name: Render cross-binding pivot
run: |
files=$(find bench-artifacts -name '*.jsonl' -print 2>/dev/null || true)
if [ -z "$files" ]; then
echo "No bench JSONL artifacts present; skipping cross-binding summary." >> $GITHUB_STEP_SUMMARY
echo "NO_BENCH_FILES=1" >> $GITHUB_ENV
exit 0
fi
# find yields newline-separated paths; use the heredoc delimiter form
# so the multiline value survives the step-to-step handoff.
{
echo 'BENCH_FILES<<EOF'
echo "$files"
echo 'EOF'
} >> "$GITHUB_ENV"
echo "## Cross-Platform Cedarling Benchmark Summary" >> $GITHUB_STEP_SUMMARY
python3 jans-cedarling/scripts/parse_binding_benchmarks.py --format jsonl $files >> $GITHUB_STEP_SUMMARY
- name: Regenerate benchmarks doc page
if: env.NO_BENCH_FILES != '1'
run: |
doc=docs/cedarling/reference/benchmarks.md
manifest=jans-cedarling/bindings/benchmarks/fixtures/scenarios.json
warmup=$(python3 -c "import json;print(json.load(open('$manifest'))['iteration_policy']['warmup_iters'])")
measure=$(python3 -c "import json;print(json.load(open('$manifest'))['iteration_policy']['measure_iters'])")
run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}"
{
echo "# Cedarling Benchmarks"
echo
echo "<!-- Auto-generated by the \"Test: Cedarling\" workflow"
echo " (cross_binding_bench_summary job). Do not edit by hand;"
echo " changes are overwritten on the next publish run. -->"
echo
echo "Cross-platform authorization benchmarks for the Cedarling bindings,"
echo "regenerated on pushes to \`main\` that change \`jans-cedarling/**\`,"
echo "or on a manual \`workflow_dispatch\` run against \`main\`."
echo
echo "_Last updated: $(date -u '+%Y-%m-%d %H:%M UTC') (commit ${GITHUB_SHA:0:7})._"
echo
echo "## Provenance"
echo
echo "- Each binding is measured on its own GitHub-hosted \`ubuntu-latest\` runner."
echo " Runners are provisioned fresh per binding, so cross-binding comparisons are"
echo " **unpaired** and subject to per-runner variance; read cross-binding ratios as"
echo " directional rather than exact, especially for closely-matched bindings."
echo "- Warm-up iterations per scenario: **$warmup**; measured (sample count) per scenario: **$measure**."
echo "- Exact host, OS, and compiler/runtime versions for this run are recorded"
echo " in the immutable workflow logs: [$run_url]($run_url)."
echo "- Scenario definitions and fixtures: \`jans-cedarling/bindings/benchmarks/fixtures/scenarios.json\`."
echo
python3 jans-cedarling/scripts/parse_binding_benchmarks.py --format jsonl $BENCH_FILES
} > "$doc"
- name: Import GPG key for signed commits
# Branch protection requires verified (GPG-signed) commits, so the bot
# commit must be signed with the mo-auto key. Same gate as the publish step.
if: >-
env.NO_BENCH_FILES != '1' &&
(github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
github.ref == 'refs/heads/main' &&
needs.rust_benchmarks.result == 'success' &&
needs.wasm_tests.result == 'success' &&
needs.python_tests.result == 'success' &&
needs.golang_tests.result == 'success' &&
needs.c_tests.result == 'success' &&
needs.uniffi_benchmarks.result == 'success'
id: import_gpg
uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0
with:
gpg_private_key: ${{ secrets.MOAUTO_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MOAUTO_GPG_PRIVATE_KEY_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Open PR with updated benchmarks doc page
# Only publish when every binding job succeeded, so a failed/partial run
# can't overwrite the doc with incomplete results.
if: >-
env.NO_BENCH_FILES != '1' &&
(github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
github.ref == 'refs/heads/main' &&
needs.rust_benchmarks.result == 'success' &&
needs.wasm_tests.result == 'success' &&
needs.python_tests.result == 'success' &&
needs.golang_tests.result == 'success' &&
needs.c_tests.result == 'success' &&
needs.uniffi_benchmarks.result == 'success'
env:
GH_TOKEN: ${{ secrets.MOAUTO_WORKFLOW_TOKEN }}
run: |
doc=docs/cedarling/reference/benchmarks.md
if git diff --quiet -- "$doc"; then
echo "No benchmark changes to commit."
exit 0
fi
branch=cn-jans-update-cedarling-benchmarks
git config user.name "mo-auto"
git config user.email "54212639+mo-auto@users.noreply.github.com"
# signingkey + commit.gpgsign are set globally by the import GPG step.
git remote set-url origin \
"https://mo-auto:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout -b "$branch"
git add "$doc"
# -s adds the DCO Signed-off-by trailer; commit.gpgsign adds the GPG signature.
git commit -s -S -m "docs(cedarling): update benchmark summary"
# Branch is regenerated from main each run; overwrite any stale tip.
git push --force --set-upstream origin "$branch"
open_prs=$(gh pr list --head "$branch" --state open --json number --jq 'length')
if [ "$open_prs" -gt 0 ]; then
echo "Open PR already exists for ${branch}; skipping creation."
else
gh pr create --base main --head "$branch" \
--title "docs(cedarling): update benchmark summary" \
--body "Auto-generated Cedarling cross-platform benchmark summary."
fi