-
-
Notifications
You must be signed in to change notification settings - Fork 29
151 lines (135 loc) · 5.03 KB
/
codspeed.yml
File metadata and controls
151 lines (135 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: CodSpeed
on:
workflow_call:
inputs:
ref:
description: 'Git ref to benchmark.'
required: false
type: string
schedule:
# Run once a week on main to build a continuous baseline for CPU benchmark
- cron: '0 0 * * 0'
# Allow manual runs on any branch (CodSpeed backtest + on-demand profiling)
workflow_dispatch:
inputs:
ref:
description: 'Git ref to benchmark (branch, tag, or SHA). Defaults to the selected branch.'
required: false
type: string
concurrency:
group: codspeed-${{ github.event.pull_request.number || inputs.ref || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
permissions:
actions: read
contents: read
id-token: write
jobs:
# Skip the entire workflow when the current HEAD has already been benchmarked
# (e.g. a schedule run fires but no new commits landed since the last run).
check-skip:
name: Check duplicate run
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.check.outputs.should_skip }}
steps:
- name: Check for existing successful run
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |
# Always run when manually triggered
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "should_skip=false" >> "$GITHUB_OUTPUT"
exit 0
fi
# Query completed runs of this workflow for the current commit
count=$(gh api \
"repos/${{ github.repository }}/actions/workflows/codspeed.yml/runs?head_sha=${{ github.sha }}&status=success&per_page=1" \
--jq '.total_count')
if [ "$count" -gt 0 ]; then
echo "should_skip=true" >> "$GITHUB_OUTPUT"
echo "Skipping: commit ${{ github.sha }} already benchmarked."
else
echo "should_skip=false" >> "$GITHUB_OUTPUT"
fi
codspeed-cpu:
name: Run CPU benchmarks
needs: check-skip
# CPU walltime benchmark runs on codspeed-macro (expensive), only on schedule or manual trigger
if: |
needs.check-skip.outputs.should_skip != 'true' &&
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
# Walltime mode requires CodSpeed bare-metal runners for stable measurements.
# CPU simulation (Valgrind) is incompatible with child_process.fork — rstest's
# worker pool generates excessive system calls, making flame graphs unavailable.
runs-on: codspeed-macro
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.ref || '' }}
fetch-depth: 1
- name: Setup pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build Packages
run: pnpm build
- name: Run benchmarks
uses: CodSpeedHQ/action@3194d9a39c4d46684cb44bf7207fc56626aad8fd # v4.15.1
with:
mode: walltime
run: node benchmarks/suiteRun.mjs
codspeed-memory:
name: Run memory benchmark
needs: check-skip
# Memory benchmark builds baseline on push to main, runs on PRs for comparison
if: |
needs.check-skip.outputs.should_skip != 'true' &&
(github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.ref || '' }}
fetch-depth: 1
- name: Setup pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build Packages
run: pnpm build
- name: Run memory benchmark
uses: CodSpeedHQ/action@3194d9a39c4d46684cb44bf7207fc56626aad8fd # v4.15.1
with:
mode: memory
# Memory mode does not auto-inject V8 flags via introspection
# (unlike simulation mode), so we pass them explicitly.
run: >-
node
--interpreted-frames-native-stack
--allow-natives-syntax
--hash-seed=1
--random-seed=1
--no-opt
--predictable
--predictable-gc-schedule
--expose-gc
--no-concurrent-sweeping
--max-old-space-size=4096
benchmarks/memorySuiteRun.mjs