Skip to content

Commit 59f3bb4

Browse files
committed
feat: add macOS-only vitest benchmark and CI job
Add benches/macos.bench.ts guarded with describe.skipIf(!darwin) so it only runs on macOS, and wire the walltime-macos-test CI job to execute it via a direct `node vitest.mjs bench --run macos` invocation.
1 parent 6ad82ca commit 59f3bb4

3 files changed

Lines changed: 44 additions & 27 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,3 @@ jobs:
8787
env:
8888
CODSPEED_SKIP_UPLOAD: true
8989
CODSPEED_DEBUG: true
90-
91-
walltime-macos-test:
92-
runs-on: macos-latest
93-
steps:
94-
- uses: "actions/checkout@v4"
95-
with:
96-
fetch-depth: 0
97-
submodules: true
98-
- uses: pnpm/action-setup@v2
99-
- uses: actions/setup-node@v3
100-
with:
101-
cache: pnpm
102-
node-version-file: .nvmrc
103-
- name: Restore turbo cache
104-
uses: ./.github/actions/turbo-cache
105-
- run: pnpm install --frozen-lockfile --prefer-offline
106-
- run: pnpm turbo run build
107-
108-
- name: Run benchmarks
109-
uses: CodSpeedHQ/action@main
110-
env:
111-
CODSPEED_SKIP_UPLOAD: "true"
112-
# Samply fails to profile pnpm targets for now
113-
CODSPEED_PROFILER_ENABLED: "false"
114-
with:
115-
run: pnpm turbo run bench --filter=@codspeed/vitest-plugin
116-
mode: walltime

.github/workflows/codspeed.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,34 @@ jobs:
9191
pnpm --workspace-concurrency 1 -r bench-tinybench
9292
pnpm --workspace-concurrency 1 -r bench-vitest
9393
94+
codspeed-walltime-macos:
95+
runs-on: macos-latest
96+
steps:
97+
- uses: "actions/checkout@v4"
98+
with:
99+
fetch-depth: 0
100+
submodules: true
101+
- uses: pnpm/action-setup@v2
102+
- uses: actions/setup-node@v3
103+
with:
104+
cache: pnpm
105+
node-version-file: .nvmrc
106+
- name: Restore turbo cache
107+
uses: ./.github/actions/turbo-cache
108+
- run: pnpm install --frozen-lockfile --prefer-offline
109+
- run: pnpm turbo run build
110+
111+
- name: Run macOS-only benchmarks
112+
uses: CodSpeedHQ/action@main
113+
with:
114+
working-directory: packages/vitest-plugin
115+
# Only run the macOS-only bench file: the rest of the suite already
116+
# runs on the linux walltime job, and uploading the same benchmark
117+
# twice for one commit is not supported.
118+
run: pnpm turbo run bench --env-mode=loose --filter=@codspeed/vitest-plugin -- macos
119+
mode: walltime
120+
runner-version: branch:sip-resign-exec-redirect
121+
94122
electron-e2e:
95123
name: Run electron inbox e2e
96124
runs-on: codspeed-macro
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { bench, describe } from "vitest";
2+
3+
const isMacOS = process.platform === "darwin";
4+
5+
function fibo(n: number): number {
6+
if (n < 2) return 1;
7+
return fibo(n - 1) + fibo(n - 2);
8+
}
9+
10+
// macOS-only benchmark: skipped on every other platform, so it only runs on
11+
// the `codspeed-walltime-macos` CI job (see .github/workflows/codspeed.yml).
12+
describe.skipIf(!isMacOS)("macos only", () => {
13+
bench("fibo darwin", () => {
14+
fibo(30);
15+
});
16+
});

0 commit comments

Comments
 (0)