Skip to content

Commit 396bcd9

Browse files
committed
Integrate hyperlight-ci into CI workflows and Just recipes
- Add cargo alias (`cargo ci`) for convenient hyperlight-ci invocation - Update dep_benchmarks workflow to use `cargo ci bench` and generate a markdown report via `cargo ci bench-report`, posting results as a PR comment per hypervisor/cpu matrix entry - Add benchmarks job to ValidatePullRequest workflow with hypervisor and cpu matrix, gated behind docs-only and build-guests checks - Grant pull-requests: write permission for PR comment posting - Simplify Justfile bench recipes to delegate to `cargo ci bench` - Update benchmarking docs to reflect the new workflow Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent 12f437c commit 396bcd9

5 files changed

Lines changed: 78 additions & 5 deletions

File tree

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[alias] # command aliases
2+
ci = ["run", "--quiet", "--package=hyperlight-ci", "--"]

.github/hyperlight-bot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Configuration for the hyperlight-gh-bot GitHub App.
2+
# See: https://github.com/jprendes/hyperlight-gh-bot
3+
4+
# Name of the artifact containing the comment body.
5+
artifact_name: "pr-comment"
6+
7+
# Regex matched against the job name to filter which jobs trigger the bot.
8+
job_filter: "post-benchmark-comment"

.github/workflows/ValidatePullRequest.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,61 @@ jobs:
140140
docs_only: ${{ needs.docs-pr.outputs.docs-only }}
141141
secrets: inherit
142142

143+
# Run benchmarks and post results as PR comment
144+
benchmarks:
145+
needs:
146+
- docs-pr
147+
- build-guests
148+
# Required because update-guest-locks is skipped on non-dependabot PRs,
149+
# and a skipped dependency transitively skips all downstream jobs.
150+
# See: https://github.com/actions/runner/issues/2205
151+
if: ${{ !cancelled() && !failure() }}
152+
strategy:
153+
fail-fast: false
154+
matrix:
155+
hypervisor: ['hyperv-ws2025', mshv3, kvm]
156+
cpu: [amd, intel]
157+
uses: ./.github/workflows/dep_benchmarks.yml
158+
secrets: inherit
159+
with:
160+
docs_only: ${{ needs.docs-pr.outputs.docs-only }}
161+
hypervisor: ${{ matrix.hypervisor }}
162+
cpu: ${{ matrix.cpu }}
163+
164+
# Combine benchmark reports into a single artifact for the hyperlight-gh-bot
165+
# to post as a PR comment. Only runs for PRs (not merge groups) with code changes.
166+
benchmark-comment:
167+
name: post-benchmark-comment
168+
needs:
169+
- docs-pr
170+
- benchmarks
171+
if: ${{ !cancelled() && !failure() && needs.docs-pr.outputs.docs-only == 'false' && github.event_name == 'pull_request' }}
172+
runs-on: ubuntu-latest
173+
steps:
174+
- name: Download benchmark reports
175+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
176+
with:
177+
pattern: benchmark-report_*
178+
path: reports/
179+
180+
- name: Combine benchmark reports
181+
run: |
182+
echo '## Benchmark Results' > pr-comment.md
183+
echo '' >> pr-comment.md
184+
for f in reports/benchmark-report_*/benchmark.md; do
185+
[ -f "$f" ] || continue
186+
cat "$f" >> pr-comment.md
187+
echo '' >> pr-comment.md
188+
done
189+
190+
- name: Upload PR comment artifact
191+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
192+
with:
193+
name: pr-comment
194+
path: pr-comment.md
195+
if-no-files-found: warn
196+
retention-days: 1
197+
143198
spelling:
144199
name: spell check with typos
145200
runs-on: ubuntu-latest
@@ -167,6 +222,7 @@ jobs:
167222
- build-test
168223
- run-examples
169224
- fuzzing
225+
- benchmarks
170226
- spelling
171227
- license-headers
172228
if: always()

.github/workflows/dep_benchmarks.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ on:
5656
required: false
5757
type: number
5858
default: 5
59-
6059
env:
6160
CARGO_TERM_COLOR: always
6261
RUST_BACKTRACE: full
@@ -135,6 +134,16 @@ jobs:
135134
- name: Run benchmarks
136135
run: just bench-ci main
137136

137+
- name: Create benchmarks report
138+
run: cargo ci bench-report --collapsible '${{ inputs.hypervisor }} / ${{ inputs.cpu }} (${{ runner.os }})' > target/criterion/benchmark.md
139+
140+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
141+
with:
142+
name: benchmark-report_${{ runner.os }}_${{ inputs.hypervisor }}_${{ inputs.cpu }}
143+
path: target/criterion/benchmark.md
144+
if-no-files-found: error
145+
retention-days: 1
146+
138147
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
139148
with:
140149
name: benchmarks_${{ runner.os }}_${{ inputs.hypervisor }}_${{ inputs.cpu }}

Justfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,10 @@ bench-download os hypervisor cpu tag="":
398398

399399
# Warning: compares to and then OVERWRITES the given baseline
400400
bench-ci baseline features="":
401-
@# Benchmarks are always run with release builds for meaningful results
402-
cargo bench --profile=release {{ if features =="" {''} else { "--features " + features } }} -- --verbose --save-baseline {{ baseline }}
401+
cargo ci bench {{ if features == "" {''} else { "--features " + features } }} --verbose --save-baseline {{ baseline }}
403402

404403
bench features="":
405-
@# Benchmarks are always run with release builds for meaningful results
406-
cargo bench --profile=release {{ if features =="" {''} else { "--features " + features } }} -- --verbose
404+
cargo ci bench {{ if features == "" {''} else { "--features " + features } }} --verbose
407405

408406
###############
409407
### FUZZING ###

0 commit comments

Comments
 (0)