Skip to content

Commit 260c073

Browse files
authored
Merge pull request #1812 from CarlWachter/feat/cb
bench: publish benchmark data in separate workflow
2 parents 00286ad + 33463a0 commit 260c073

File tree

2 files changed

+76
-16
lines changed

2 files changed

+76
-16
lines changed

.github/workflows/benchmark.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Benchmark
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
push:
66
branches:
77
- main
@@ -11,12 +11,7 @@ env:
1111

1212
jobs:
1313
benchmark:
14-
name: Run Benchmarks
1514
runs-on: [self-hosted]
16-
environment: ${{ github.event_name == 'push' && 'benchmark' || '' }}
17-
18-
permissions:
19-
pull-requests: write
2015

2116
strategy:
2217
matrix:
@@ -50,14 +45,8 @@ jobs:
5045
id: run-bench
5146
with:
5247
benchmark-file: ${{ matrix.benchmark-file }}
53-
- name: Store benchmark results
54-
uses: hermit-os/github-action-benchmark@main
48+
- name: Upload benchmark results
49+
uses: actions/upload-artifact@v4
5550
with:
56-
tool: "hermit-bench"
57-
output-file-path: ${{ steps.run-bench.outputs.result-file }}
58-
github-token: ${{ github.event_name == 'push' && secrets.HERMIT_BENCH_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
59-
benchmark-data-dir-path: .
60-
gh-repository: github.com/hermit-os/hermit-bench
61-
comment-always: true
62-
benchmark-matrix-name: ${{ matrix.benchmark-matrix-name }}
63-
auto-push: ${{ github.event_name == 'push' }}
51+
name: ${{ matrix.benchmark-matrix-name }}-benchmark-results
52+
path: ${{ steps.run-bench.outputs.result-file }}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Publish Benchmarks
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Benchmark"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
publish_benchmarks:
11+
runs-on: ubuntu-latest
12+
environment: benchmark
13+
14+
permissions:
15+
pull-requests: write
16+
17+
strategy:
18+
matrix:
19+
include:
20+
- benchmark-matrix-name: General
21+
- benchmark-matrix-name: Misc
22+
23+
env:
24+
GH_TOKEN: ${{ github.token }}
25+
26+
steps:
27+
- name: Download artifact from another workflow
28+
run: |
29+
run_id="${{ github.event.workflow_run.id }}"
30+
artifact_name="${{ matrix.benchmark-matrix-name }}-benchmark-results"
31+
32+
echo "Fetching artifact '${artifact_name}' from run ${run_id}"
33+
34+
# List artifacts and extract matching ID
35+
artifact_id=$(gh api \
36+
repos/${{ github.repository }}/actions/runs/$run_id/artifacts \
37+
--jq ".artifacts[] | select(.name == \"${artifact_name}\") | .id")
38+
39+
if [ -z "$artifact_id" ]; then
40+
echo "Artifact '$artifact_name' not found"
41+
exit 1
42+
fi
43+
44+
gh api /repos/${{ github.repository }}/actions/artifacts/$artifact_id/zip > results.zip
45+
46+
unzip results.zip
47+
- name: Comment benchmark results to PR
48+
if: github.event.workflow_run.event == 'pull_request'
49+
uses: hermit-os/github-action-benchmark@main
50+
with:
51+
tool: "hermit-bench"
52+
output-file-path: results.json
53+
github-token: ${{ secrets.GITHUB_TOKEN }}
54+
benchmark-data-dir-path: .
55+
gh-repository: github.com/hermit-os/hermit-bench
56+
comment-always: true
57+
benchmark-matrix-name: ${{ matrix.benchmark-matrix-name }}
58+
ref: ${{ github.event.workflow_run.head_sha }}
59+
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
60+
- name: Publish benchmark results to hermit-bench
61+
if: github.event.workflow_run.event == 'push'
62+
uses: hermit-os/github-action-benchmark@main
63+
with:
64+
tool: "hermit-bench"
65+
output-file-path: results.json
66+
github-token: ${{ secrets.HERMIT_BENCH_GITHUB_TOKEN }}
67+
benchmark-data-dir-path: .
68+
gh-repository: github.com/hermit-os/hermit-bench
69+
benchmark-matrix-name: ${{ matrix.benchmark-matrix-name }}
70+
auto-push: true
71+
ref: ${{ github.event.workflow_run.head_sha }}

0 commit comments

Comments
 (0)