Report Benchmark Results workflow (lit/lit)
The Report Benchmark Results workflow from lit/lit, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Report Benchmark Results workflow from the lit/lit repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Report Benchmark Results
on:
workflow_run:
workflows: [Benchmarks]
branches: ['**']
types:
- completed
- requested
permissions:
contents: read
jobs:
# Optional job to update existing comments with a "benchmarks are running" text
report_running:
name: Report benchmarks are in-progress
runs-on: ubuntu-latest
permissions:
issues: write # needed to write comments on PRs
pull-requests: write # needed to write comments on PRs
# Only add the "benchmarks are running" text when the workflow_run starts
if: ${{ github.event.action == 'requested' }}
steps:
- name: Report Tachometer Running
uses: andrewiggins/tachometer-reporter-action@v2
with:
# Set initialize true so this action just creates the comment and adds
# the "benchmarks are running" text
initialize: true
report_results:
name: Report benchmark results
runs-on: ubuntu-latest
permissions:
issues: write # needed to write comments on PRs
pull-requests: write # needed to write comments on PRs
# Only run this job if the event action was "completed" and the triggering
# workflow_run was successful
if: ${{ github.event.action == 'completed' && github.event.workflow_run.conclusion == 'success' }}
steps:
# Download the artifact from the triggering workflow that contains the
# Tachometer results to report
- uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow.id }}
run_id: ${{ github.event.workflow_run.id }}
name: results
path: results
# Create/update the comment with the latest results
- name: Report Tachometer Results
uses: andrewiggins/tachometer-reporter-action@main
with:
path: results/*.json
pr-bench-name: this-change
base-bench-name: tip-of-tree
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Report Benchmark Results on: workflow_run: workflows: [Benchmarks] branches: ['**'] types: - completed - requested permissions: contents: read jobs: # Optional job to update existing comments with a "benchmarks are running" text report_running: timeout-minutes: 30 name: Report benchmarks are in-progress runs-on: latchkey-small permissions: issues: write # needed to write comments on PRs pull-requests: write # needed to write comments on PRs # Only add the "benchmarks are running" text when the workflow_run starts if: ${{ github.event.action == 'requested' }} steps: - name: Report Tachometer Running uses: andrewiggins/tachometer-reporter-action@v2 with: # Set initialize true so this action just creates the comment and adds # the "benchmarks are running" text initialize: true report_results: timeout-minutes: 30 name: Report benchmark results runs-on: latchkey-small permissions: issues: write # needed to write comments on PRs pull-requests: write # needed to write comments on PRs # Only run this job if the event action was "completed" and the triggering # workflow_run was successful if: ${{ github.event.action == 'completed' && github.event.workflow_run.conclusion == 'success' }} steps: # Download the artifact from the triggering workflow that contains the # Tachometer results to report - uses: dawidd6/action-download-artifact@v2 with: workflow: ${{ github.event.workflow.id }} run_id: ${{ github.event.workflow_run.id }} name: results path: results # Create/update the comment with the latest results - name: Report Tachometer Results uses: andrewiggins/tachometer-reporter-action@main with: path: results/*.json pr-bench-name: this-change base-bench-name: tip-of-tree
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.