|
| 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