1212 suite :
1313 description : Benchmark suite
1414 required : true
15- default : full
15+ default : quick
1616 type : choice
1717 options :
18- - full
18+ - quick
1919 - web
20+ - full
2021
2122permissions :
2223 contents : read
2829 if : |
2930 (github.event_name == 'issue_comment' &&
3031 github.event.issue.pull_request &&
31- startsWith( github.event.comment.body, '/bench' ) &&
32+ contains(fromJSON('["/bench","/bench quick","/bench web","/bench full"]'), github.event.comment.body) &&
3233 contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
3334 ) || (github.event_name == 'workflow_dispatch')
3435 runs-on : ubuntu-22.04
@@ -54,10 +55,21 @@ jobs:
5455 throw new Error('Unable to determine pull request number');
5556 }
5657
58+ const commentSuites = {
59+ '/bench': 'quick',
60+ '/bench quick': 'quick',
61+ '/bench web': 'web',
62+ '/bench full': 'full',
63+ };
64+ const commentBody = context.payload.comment?.body?.trim().toLowerCase();
5765 const suite = context.eventName === 'workflow_dispatch'
58- ? context.payload.inputs?.suite ?? 'full'
59- : 'full';
60- const benchmarkScripts = { full: 'benchmark', web: 'benchmark:web' };
66+ ? context.payload.inputs?.suite ?? 'quick'
67+ : commentSuites[commentBody];
68+ const benchmarkScripts = {
69+ quick: 'benchmark:quick',
70+ full: 'benchmark',
71+ web: 'benchmark:web',
72+ };
6173 if (!Object.hasOwn(benchmarkScripts, suite)) {
6274 throw new Error(`Unsupported benchmark suite: ${suite}`);
6375 }
@@ -124,7 +136,6 @@ jobs:
124136 with :
125137 ref : ${{ steps.pr.outputs.base_sha }}
126138 path : bench-base
127- fetch-depth : 0
128139 submodules : recursive
129140
130141 - name : Checkout head
@@ -133,9 +144,16 @@ jobs:
133144 with :
134145 ref : ${{ steps.pr.outputs.head_sha }}
135146 path : bench-head
136- fetch-depth : 0
137147 submodules : recursive
138148
149+ - name : Checkout benchmark tools
150+ if : steps.pr.outputs.same_repo == 'true' && steps.pr.outputs.suite == 'quick'
151+ uses : actions/checkout@v4
152+ with :
153+ ref : ${{ github.workflow_sha }}
154+ path : bench-tools
155+ sparse-checkout : scripts
156+
139157 - name : Use Node.js 20.x
140158 if : steps.pr.outputs.same_repo == 'true'
141159 uses : actions/setup-node@v4
@@ -151,8 +169,6 @@ jobs:
151169 - name : Install Rust toolchain
152170 if : steps.pr.outputs.same_repo == 'true'
153171 uses : dtolnay/rust-toolchain@stable
154- with :
155- components : rustfmt, clippy
156172
157173 - name : Add wasm targets
158174 if : steps.pr.outputs.same_repo == 'true'
@@ -219,8 +235,16 @@ jobs:
219235 run : |
220236 set -o pipefail
221237 status=0
222- env -u CI pnpm run "$BENCHMARK_SCRIPT" 2>&1 | tee benchmark.log || status=$?
223- pnpm run benchmark:aggregate || status=$?
238+ if [ "$BENCHMARK_SCRIPT" = "benchmark:quick" ]; then
239+ env -u CI TREECRDT_BENCH_ROOT="$PWD" \
240+ node "$GITHUB_WORKSPACE/bench-tools/scripts/run-quick-bench.mjs" \
241+ 2>&1 | tee benchmark.log || status=$?
242+ else
243+ env -u CI pnpm run "$BENCHMARK_SCRIPT" 2>&1 | tee benchmark.log || status=$?
244+ fi
245+ if [ ! -f benchmarks/summary.json ]; then
246+ pnpm run benchmark:aggregate || status=$?
247+ fi
224248 exit "$status"
225249
226250 - name : Run benchmarks (head)
@@ -234,8 +258,16 @@ jobs:
234258 run : |
235259 set -o pipefail
236260 status=0
237- env -u CI pnpm run "$BENCHMARK_SCRIPT" 2>&1 | tee benchmark.log || status=$?
238- pnpm run benchmark:aggregate || status=$?
261+ if [ "$BENCHMARK_SCRIPT" = "benchmark:quick" ]; then
262+ env -u CI TREECRDT_BENCH_ROOT="$PWD" \
263+ node "$GITHUB_WORKSPACE/bench-tools/scripts/run-quick-bench.mjs" \
264+ 2>&1 | tee benchmark.log || status=$?
265+ else
266+ env -u CI pnpm run "$BENCHMARK_SCRIPT" 2>&1 | tee benchmark.log || status=$?
267+ fi
268+ if [ ! -f benchmarks/summary.json ]; then
269+ pnpm run benchmark:aggregate || status=$?
270+ fi
239271 exit "$status"
240272
241273 - name : Upload benchmark artifacts
@@ -342,8 +374,9 @@ jobs:
342374 const baseOutcome = '${{ steps.benchmark_base.outcome }}';
343375 const headOutcome = '${{ steps.benchmark_head.outcome }}';
344376 const benchmarkFailed = [baseOutcome, headOutcome].includes('failure');
345- const triggerLabel =
346- context.eventName === 'workflow_dispatch' ? '`workflow_dispatch`' : '`/bench`';
377+ const triggerLabel = context.eventName === 'workflow_dispatch'
378+ ? '`workflow_dispatch`'
379+ : `\`${context.payload.comment.body.trim()}\``;
347380
348381 const parts = [
349382 marker,
0 commit comments