Skip to content

Report benchmark results #215

Report benchmark results

Report benchmark results #215

# Post any reports generated by benchmarks_run.yml .
# Separated for security:
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
name: benchmarks-report
run-name: Report benchmark results
on:
workflow_run:
workflows: [benchmarks-run]
types:
- completed
jobs:
download:
runs-on: ubuntu-latest
outputs:
reports_exist: ${{ steps.unzip.outputs.reports_exist }}
steps:
- name: Download artifact
id: download-artifact
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
uses: actions/github-script@v7
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "benchmark_reports"
})[0];
if (typeof matchArtifact != 'undefined') {
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/benchmark_reports.zip`, Buffer.from(download.data));
};
- name: Unzip artifact
id: unzip
run: |
if test -f "benchmark_reports.zip"; then
reports_exist=1
unzip benchmark_reports.zip -d benchmark_reports
else
reports_exist=0
fi
echo "reports_exist=$reports_exist" >> "$GITHUB_OUTPUT"
- name: Store artifact
uses: actions/upload-artifact@v4
with:
name: benchmark_reports
path: benchmark_reports
post_reports:
runs-on: ubuntu-latest
needs: download
if: needs.download.outputs.reports_exist == 1
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: benchmark_reports
path: .github/workflows/benchmark_reports
- name: Set up Python
# benchmarks/bm_runner.py only needs builtins to run.
uses: actions/setup-python@v5
- name: Post reports
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python benchmarks/bm_runner.py _gh_post