Files
pnpm/.github/workflows/pacquet-micro-benchmark.yml
Zoltan Kochan d2b64b6689 ci(pacquet): fix all zizmor code-scanning findings (#11641)
* ci(pacquet): fix all zizmor code-scanning findings

Resolves the 90 alerts opened by zizmor against the imported pacquet-*
workflows and shared composite actions:

- unpinned-uses: pin every third-party action to a SHA + version comment
  (matching SHAs already used elsewhere in the repo where applicable;
  taiki-e/install-action collapsed onto v2.78.0 with explicit `tool:` input).
- artipacked: add `persist-credentials: false` to every actions/checkout.
- template-injection: pass `inputs.*` and `steps.*.outputs.*` through `env:`
  in binstall/rustup composite actions and pacquet-release-to-npm.yml.
- excessive-permissions: add top-level `permissions: contents: read` to
  pacquet-release-to-npm.yml; move issues/pull-requests writes from the
  workflow level to the benchmark-compare job in pacquet-micro-benchmark.yml.
- dangerous-triggers: keep workflow_run in pacquet-integrated-benchmark-
  comment.yml but suppress with a documented zizmor: ignore — the trigger
  is the recommended pattern for posting comments back to fork PRs.
- superfluous-actions: keep softprops/action-gh-release with a zizmor:
  ignore (matches release.yml).

Verified by running `zizmor .github` locally with no remaining findings.

* ci(pacquet): point SHA pins at the patch-version tag

Swatinem/rust-cache and montudor/action-zip were pinned to the SHA the
major-version alias (`v2`, `v1`) resolves to, but the version comments
claimed `v2.9.1` / `v1.0.0`. zizmor's online `ref-version-mismatch`
audit flagged the inconsistency. Repoint at the SHAs the patch-version
tags actually annotate so the pin and the comment agree.
2026-05-14 19:33:30 +02:00

131 lines
4.1 KiB
YAML

name: Pacquet Micro-Benchmark
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
paths:
- 'pacquet/**/*.rs'
- 'pacquet/**/Cargo.toml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- 'pacquet/tasks/micro-benchmark/fixtures/**'
- '.github/actions/rustup/**'
- '.github/actions/binstall/**'
- '.github/workflows/pacquet-micro-benchmark.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions:
contents: read
jobs:
benchmark:
strategy:
matrix:
os: [ubuntu-latest] # `macos-latest` is too unstable to be useful for benchmark, the variance is always huge.
name: Run benchmark on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Main Branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: main # Checkout main first because the cache is warm
persist-credentials: false
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
shared-key: micro-benchmark
- name: Compile
run: cargo build --release --bin=micro-benchmark
- name: Sleep for CPU cooldown
shell: bash
run: sleep 15s
- name: Run Bench on Main Branch
run: cargo run --bin=micro-benchmark --release -- --save-baseline main
- name: Checkout PR Branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
clean: false
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: Compile
run: cargo build --release --bin=micro-benchmark
- name: Sleep for CPU cooldown
shell: bash
run: sleep 15s
- name: Run Bench on PR Branch
run: cargo run --bin=micro-benchmark --release -- --save-baseline pr
- name: Upload benchmark results
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: benchmark-results-${{ matrix.os }}
path: ./target/criterion
benchmark-compare:
runs-on: ubuntu-latest
name: Compare Benchmarks
needs:
- benchmark
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Install critcmp
uses: taiki-e/install-action@e1c4cd42111751368541a7cb5db3522bd1f846a4 # v2.78.0
with:
tool: critcmp
- name: Linux | Download PR benchmark results
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: benchmark-results-ubuntu-latest
path: ./target/criterion
- name: Linux | Compare benchmark results
shell: bash
run: |
echo "## Micro-Benchmark Results" >> summary.md
echo "### Linux" >> summary.md
echo "\`\`\`" >> summary.md
critcmp main pr >> summary.md
echo "\`\`\`" >> summary.md
echo "" >> summary.md
- name: Linux | Cleanup benchmark results
run: rm -rf ./target/criterion
- name: Find Comment
# Check if the event is not triggered by a fork
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Micro-Benchmark Results
- name: Create or update comment
# Check if the event is not triggered by a fork
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
comment-id: ${{ steps.fc.outputs.comment-id }}
body-file: summary.md