Skip to content

feat(cu-benchmark): reusable CU benchmark report action#17

Open
dev-jodee wants to merge 1 commit into
solana-developers:mainfrom
dev-jodee:feat/cu-benchmark-action
Open

feat(cu-benchmark): reusable CU benchmark report action#17
dev-jodee wants to merge 1 commit into
solana-developers:mainfrom
dev-jodee:feat/cu-benchmark-action

Conversation

@dev-jodee
Copy link
Copy Markdown
Contributor

What

A composite action that turns a freshly generated compute-unit (CU) report from a Solana program's tests into a PR comment with per-instruction Avg CU deltas vs main, and can optionally keep a committed baseline in sync.

Useful for any program repo that wants visible CU regressions on every PR without extra tooling.

Behavior

  1. Auto-locate cu_report.md in the checkout (fails loud on 0 or >1; report-path overrides). Baseline = its sibling cu_baseline.md.
  2. Read the baseline from main; diff the fresh report against it.
  3. Upsert a PR comment with a Δ Avg vs main column (🔺/🔻//🆕/🗑), deduped by a hidden marker.
  4. Opt-in: on same-repo PRs, fetch+switch to the head branch, commit the refreshed baseline, push. Loop-safe (pushes via GITHUB_TOKEN don't re-trigger workflows). Fork PRs skip.

base=main; head ref / PR number / token are derived from the github context in-step — not inputs.

Inputs

input required default notes
report-path no "" (auto-discover) override only when a repo emits several cu_report.md
commit-baseline no false opt-in auto-refresh; needs contents: write + a same-repo check

Permission profiles

Comment-only (default) — needs only pull-requests: write. Deltas work against a committed baseline; with no baseline, every instruction shows 🆕.

Auto-refresh baseline (opt-in) — add contents: write and set commit-baseline to the same-repo check.

Example caller workflow

name: Benchmark
on: pull_request
permissions:
  contents: write        # only if commit-baseline enabled
  pull-requests: write
jobs:
  compute-units:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v6
        with: { fetch-depth: 0 }
      - uses: ./.github/actions/setup        # your toolchain setup
      - run: just test-and-benchmark          # produces cu_report.md
      - uses: solana-developers/github-actions/cu-benchmark@vX
        with:
          commit-baseline: ${{ github.event.pull_request.head.repo.full_name == github.repository }}

Verification

Diff/render tested against tabled-style tables (increase, decrease, unchanged, new, removed, empty baseline, mismatched columns). Auto-discovery tested for 0 / 1 / multiple matches + override. Portable bash (no bash-4 mapfile).

Notes

  • base is hardcoded to main: stacked / release-branch PRs diff vs main, not the parent branch.
  • Parses the report's markdown table by column header; a future cu_report.json companion could make diffing format-agnostic.

@dev-jodee dev-jodee force-pushed the feat/cu-benchmark-action branch 2 times, most recently from 830cd55 to 5b09a0d Compare June 8, 2026 14:51
Composite action that diffs a freshly generated compute-unit report
against a committed baseline, posts an upsert PR comment with per-
instruction Avg deltas vs main, and optionally refreshes the baseline.

- comment-only by default (needs pull-requests: write); commit-baseline
  is opt-in and needs contents: write (gated to same-repo PRs, forks skip)
- inputs: report-path, baseline-path, commit-baseline
- base=main, head/pr/token derived from the github context in-step
- header-indexed markdown parse, robust to column changes
@dev-jodee dev-jodee force-pushed the feat/cu-benchmark-action branch from 5b09a0d to c25d348 Compare June 8, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants