From 0af82d5690ab1dc2576241af347759d1b1dd69da Mon Sep 17 00:00:00 2001 From: Jacob Bolda Date: Thu, 19 Nov 2026 22:59:07 -0600 Subject: [PATCH] control codspeed vs vitest in benchmark --- .github/workflows/benchmark.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 4058f46..97c10a8 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -4,6 +4,7 @@ on: push: branches: [main] pull_request: + types: [opened, synchronize, reopened, labeled] workflow_dispatch: env: @@ -11,8 +12,20 @@ env: jobs: benchmarks: - name: Run benchmarks (walltime, memory) - runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04 + name: Run benchmarks (${{ matrix.use-codspeed && 'CodSpeed' || 'Vitest' }}) + # use a matrix to compute whether to use CodSpeed as that can be directly tied to runs-on and the steps as one var + strategy: + matrix: + include: + - use-codspeed: >- + ${{ vars.CODSPEED_ENABLED == 'true' && ( + github.ref == 'refs/heads/main' || ( + github.event_name == 'pull_request' && + github.event.action == 'labeled' && + github.event.label.name == 'performance' + ) + ) }} + runs-on: ${{ matrix.use-codspeed && 'codspeed-macro-arm64-graviton-ubuntu-22-04' || 'ubuntu-latest' }} permissions: contents: read id-token: write @@ -23,7 +36,11 @@ jobs: - uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0 - run: pnpm install --frozen-lockfile - name: Run benchmarks with CodSpeed + if: ${{ matrix.use-codspeed }} uses: CodSpeedHQ/action@78102a468f96d8e0ccb92d0ec49425753fc42062 # v5 with: mode: walltime,memory run: pnpm bench + - name: Run benchmarks without CodSpeed + if: ${{ !matrix.use-codspeed }} + run: pnpm bench