Publish Benchmarks #635
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Benchmarks | |
on: | |
workflow_run: | |
workflows: ["Benchmark"] | |
types: | |
- completed | |
jobs: | |
publish_benchmarks: | |
runs-on: ubuntu-latest | |
environment: benchmark | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Download artifact from another workflow | |
run: | | |
download_artifact() { | |
run_id="${{ github.event.workflow_run.id }}" | |
artifact_name="$1-benchmark-results" | |
echo "Fetching artifact '${artifact_name}' from run ${run_id}" | |
artifact_id=$(gh api \ | |
repos/${{ github.repository }}/actions/runs/$run_id/artifacts \ | |
--jq ".artifacts[] | select(.name == \"${artifact_name}\") | .id") | |
if [ -z "$artifact_id" ]; then | |
echo "Artifact '$artifact_name' not found" | |
exit 1 | |
fi | |
gh api /repos/${{ github.repository }}/actions/artifacts/$artifact_id/zip > results.zip | |
unzip results.zip | |
mv results.json "$1.json" | |
} | |
download_artifact "General" | |
download_artifact "Misc" | |
jq -s 'add' General.json Misc.json > results.json | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Find PR Number | |
if: github.event.workflow_run.event == 'pull_request' | |
id: find_pr | |
run: | | |
PR=$(gh pr list --repo ${{ github.repository }} --head ${{ github.event.workflow_run.head_branch}} --json number -q '.[0].number') | |
echo "pr_number=$PR" >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Comment benchmark results to PR | |
if: github.event.workflow_run.event == 'pull_request' | |
uses: hermit-os/github-action-benchmark@main | |
with: | |
tool: "hermit-bench" | |
output-file-path: results.json | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
benchmark-data-dir-path: . | |
gh-repository: github.com/hermit-os/hermit-bench | |
comment-always: true | |
ref: ${{ github.event.workflow_run.head_sha }} | |
pr-number: ${{ steps.find_pr.outputs.pr_number }} | |
- name: Publish benchmark results to hermit-bench | |
if: github.event.workflow_run.event == 'push' | |
uses: hermit-os/github-action-benchmark@main | |
with: | |
tool: "hermit-bench" | |
output-file-path: results.json | |
github-token: ${{ secrets.HERMIT_BENCH_GITHUB_TOKEN }} | |
benchmark-data-dir-path: . | |
gh-repository: github.com/hermit-os/hermit-bench | |
auto-push: true | |
ref: ${{ github.event.workflow_run.head_sha }} |