Benchmark workflow (prisma/prisma)
The Benchmark workflow from prisma/prisma, 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 Benchmark workflow from the prisma/prisma repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Benchmark
# Run on `push` only for main, if not it will trigger `push` & `pull_request` on PRs at the same time
on:
push:
branches:
- main
- '*.*.x'
paths-ignore:
# Any update here needs to be done for `pull_request` (see below) and all files
# (test.yml, benchmark.yml, release.yml, bundle-size.yml, ci-aux-files.yml)
- '*.md'
# - '*.bench.ts' -> should not be ignored in this workflow
- 'LICENSE'
- '.dockerignore'
- 'scripts/ci/publish.ts'
- '.github/CODEOWNERS'
- '.github/ISSUE_TEMPLATE/**'
- '.github/DISCUSSION_TEMPLATE/**'
- '.devcontainer/**'
- '.vscode/**'
- 'graphs/**'
- 'sandbox/**'
pull_request:
paths-ignore:
# Any update here needs to be done for `branches` (see above) and all files
# (test.yml, benchmark.yml, release.yml, bundle-size.yml, ci-aux-files.yml)
- '*.md'
# - '*.bench.ts' -> should not be ignored in this workflow
- 'LICENSE'
- '.dockerignore'
- 'scripts/ci/publish.ts'
- '.github/CODEOWNERS'
- '.github/ISSUE_TEMPLATE/**'
- '.github/DISCUSSION_TEMPLATE/**'
- '.devcontainer/**'
- '.vscode/**'
- 'graphs/**'
- 'sandbox/**'
workflow_dispatch:
env:
PRISMA_TELEMETRY_INFORMATION: 'prisma benchmark.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
# Only run on main repo (not on forks)
# This avoids notifications to be sent to `alert-comment-cc-users`, see below
if: github.repository == 'prisma/prisma'
steps:
- uses: actions/checkout@v6
- name: Install & build
uses: ./.github/actions/setup
with:
node-version: '20.19.0'
skip-tsc: false
- name: Run benchmarks
run: pnpm run bench
- name: Store benchmark result
if: ${{ github.ref == 'refs/heads/main' }}
uses: rhysd/github-action-benchmark@v1
with:
name: Benchmark.js Benchmark
tool: 'benchmarkjs'
output-file-path: output.txt
# Note: must use personal access token
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@millsp,@aqrln,@SevInf,@jkomyno'
- name: Run benchmarks for Codspeed
uses: CodSpeedHQ/action@v4
with:
mode: simulation
run: pnpm run bench-stdout-only
token: ${{ secrets.CODSPEED_TOKEN }}
env:
CODSPEED_BENCHMARK: true
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Benchmark # Run on `push` only for main, if not it will trigger `push` & `pull_request` on PRs at the same time on: push: branches: - main - '*.*.x' paths-ignore: # Any update here needs to be done for `pull_request` (see below) and all files # (test.yml, benchmark.yml, release.yml, bundle-size.yml, ci-aux-files.yml) - '*.md' # - '*.bench.ts' -> should not be ignored in this workflow - 'LICENSE' - '.dockerignore' - 'scripts/ci/publish.ts' - '.github/CODEOWNERS' - '.github/ISSUE_TEMPLATE/**' - '.github/DISCUSSION_TEMPLATE/**' - '.devcontainer/**' - '.vscode/**' - 'graphs/**' - 'sandbox/**' pull_request: paths-ignore: # Any update here needs to be done for `branches` (see above) and all files # (test.yml, benchmark.yml, release.yml, bundle-size.yml, ci-aux-files.yml) - '*.md' # - '*.bench.ts' -> should not be ignored in this workflow - 'LICENSE' - '.dockerignore' - 'scripts/ci/publish.ts' - '.github/CODEOWNERS' - '.github/ISSUE_TEMPLATE/**' - '.github/DISCUSSION_TEMPLATE/**' - '.devcontainer/**' - '.vscode/**' - 'graphs/**' - 'sandbox/**' workflow_dispatch: env: PRISMA_TELEMETRY_INFORMATION: 'prisma benchmark.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: benchmark: timeout-minutes: 30 name: Benchmark runs-on: latchkey-small # Only run on main repo (not on forks) # This avoids notifications to be sent to `alert-comment-cc-users`, see below if: github.repository == 'prisma/prisma' steps: - uses: actions/checkout@v6 - name: Install & build uses: ./.github/actions/setup with: node-version: '20.19.0' skip-tsc: false - name: Run benchmarks run: pnpm run bench - name: Store benchmark result if: ${{ github.ref == 'refs/heads/main' }} uses: rhysd/github-action-benchmark@v1 with: name: Benchmark.js Benchmark tool: 'benchmarkjs' output-file-path: output.txt # Note: must use personal access token github-token: ${{ secrets.GITHUB_TOKEN }} auto-push: true # Show alert with commit comment on detecting possible performance regression alert-threshold: '200%' comment-on-alert: true fail-on-alert: true alert-comment-cc-users: '@millsp,@aqrln,@SevInf,@jkomyno' - name: Run benchmarks for Codspeed uses: CodSpeedHQ/action@v4 with: mode: simulation run: pnpm run bench-stdout-only token: ${{ secrets.CODSPEED_TOKEN }} env: CODSPEED_BENCHMARK: true
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 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.