Skip to content

Commit 3b0328c

Browse files
fengmk2claude
andauthored
test: enable CodSpeed GitHub Action for performance benchmarking (#625)
Add CodSpeed integration with vitest bench to enable continuous performance monitoring on PRs and pushes to master. - Add @codspeed/vitest-plugin dependency - Configure codspeed plugin in vite.config.ts - Create .github/workflows/codspeed.yml workflow - Add benchmark file with HttpClient and utility function benchmarks - Add `bench` npm script for local benchmark execution 🤖 Generated with [Claude Code](https://claude.com/claude-code) > enable CodSpeed GitHub Action follow the guide https://github.com/CodSpeedHQ/action/blob/main/README.md#nodejs-with-codspeed-node-typescript-and-vitest , we are using vitest bench to do that. Create a plan to achieve this with your ultrathink <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Added performance benchmarking infrastructure and CI workflow to run benchmarks automatically. * Brought in a benchmarking plugin and test suites covering core utilities and HTTP client scenarios. * Updated project scripts (including a bench command) and linting setup for consistent pre-commit checks. * Added pre-commit hook and lint-staged configuration; adjusted lint rules to ignore test fixtures. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent b390eb9 commit 3b0328c

File tree

10 files changed

+1665
-697
lines changed

10 files changed

+1665
-697
lines changed

.github/workflows/codspeed.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CodSpeed
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
benchmarks:
12+
name: Run benchmarks
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
id-token: write
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
20+
21+
- name: Install pnpm
22+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
26+
with:
27+
node-version: '22'
28+
cache: 'pnpm'
29+
30+
- name: Install dependencies
31+
run: pnpm install --frozen-lockfile
32+
33+
- name: Run benchmarks
34+
uses: CodSpeedHQ/action@v4
35+
with:
36+
mode: simulation
37+
run: pnpm vitest bench --run

.github/workflows/nodejs-16.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
node-version: 16
2222
- run: npm install
23-
- run: npm run ci
23+
- run: npm run ci:node16
2424
- run: npm run prepublishOnly
2525
- run: node -v
2626
- run: npm run test-node16

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.oxlintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,6 @@
123123
"id-length": "allow",
124124
"arrow-body-style": "allow",
125125
"prefer-destructuring": "allow"
126-
}
126+
},
127+
"ignorePatterns": ["test/fixtures/ts*"]
127128
}

package.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"url": "git://github.com/node-modules/urllib.git"
2424
},
2525
"scripts": {
26-
"lint": "oxlint src test",
26+
"lint": "oxlint src test --type-aware --type-check",
2727
"fmt": "oxfmt",
2828
"typecheck": "tsc --noEmit && tsgo --noEmit",
2929
"fmtcheck": "oxfmt --check .",
@@ -40,12 +40,15 @@
4040
"test-tsc:cjs:es2021": "cd test/fixtures/ts-cjs-es2021 && rm -rf node_modules && npm link ../../.. && npm run build",
4141
"test-tsc:esm": "cd test/fixtures/ts-esm && rm -rf node_modules && npm link ../../.. && npm run build",
4242
"test": "npm run lint -- --fix && vitest run",
43+
"bench": "vitest bench",
4344
"test-keepalive": "cross-env TEST_KEEPALIVE_COUNT=50 vitest run --test-timeout 180000 keep-alive-header.test.ts",
4445
"test-node16": "node examples/httpclient.cjs && node examples/search_github.cjs && node examples/timing.cjs",
45-
"cov": "cross-env NODE_OPTIONS=\"--require ./test/patch-for-node16-18.cjs\" vitest run --coverage",
46+
"cov": "vitest run --coverage",
4647
"ci": "npm run cov && npm run prepublishOnly && npm pack && attw --pack",
48+
"ci:node16": "cross-env NODE_OPTIONS=\"--require ./test/patch-for-node16-18.cjs\" vitest run && npm run prepublishOnly && npm pack && attw --pack",
4749
"clean": "rm -rf dist && tsc -b --clean",
48-
"prepublishOnly": "npm run build"
50+
"prepublishOnly": "npm run build",
51+
"prepare": "husky"
4952
},
5053
"dependencies": {
5154
"form-data": "^4.0.1",
@@ -58,6 +61,7 @@
5861
},
5962
"devDependencies": {
6063
"@arethetypeswrong/cli": "^0.18.0",
64+
"@codspeed/vitest-plugin": "^5.0.1",
6165
"@eggjs/oxlint-config": "^1.0.0",
6266
"@eggjs/tsconfig": "^2.0.0",
6367
"@tsconfig/node18": "^18.2.1",
@@ -74,9 +78,12 @@
7478
"@vitest/coverage-v8": "^3.0.2",
7579
"busboy": "^1.6.0",
7680
"cross-env": "^10.0.0",
81+
"husky": "^9.1.7",
7782
"iconv-lite": "^0.6.3",
83+
"lint-staged": "^16.2.7",
7884
"oxfmt": "^0.17.0",
7985
"oxlint": "^1.11.0",
86+
"oxlint-tsgolint": "^0.10.0",
8087
"proxy": "^1.0.2",
8188
"selfsigned": "^3.0.0",
8289
"string.prototype.towellformed": "^1.0.2",
@@ -117,5 +124,11 @@
117124
"types": "./dist/commonjs/index.d.ts",
118125
"main": "./dist/commonjs/index.js",
119126
"module": "./dist/esm/index.js",
120-
"packageManager": "[email protected]"
127+
"packageManager": "[email protected]",
128+
"lint-staged": {
129+
"*": [
130+
"npm run lint -- --fix",
131+
"oxfmt"
132+
]
133+
}
121134
}

0 commit comments

Comments
 (0)