Skip to content

Commit 815d4bc

Browse files
simplyme0823simplyme0823
andauthored
ci: add CodSpeed benchmark coverage (#669)
Co-authored-by: simplyme0823 <xiangjiamin.0823@bytedance.com>
1 parent 433a49a commit 815d4bc

23 files changed

Lines changed: 1089 additions & 5 deletions
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Benchmark CLI
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
benchmark-cli:
8+
name: Run CLI benchmarks
9+
runs-on: ubuntu-22.04
10+
permissions:
11+
contents: read
12+
id-token: write
13+
env:
14+
GOMAXPROCS: 8
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
18+
with:
19+
submodules: true
20+
fetch-depth: 1
21+
22+
- name: Setup Go
23+
uses: ./.github/actions/setup-go
24+
with:
25+
go-version: '1.26.0'
26+
cache-name: benchmark-cli
27+
28+
- name: Setup Node.js
29+
uses: ./.github/actions/setup-node
30+
31+
- name: Build JS package
32+
run: pnpm --filter @rslint/core run build
33+
34+
- name: Run CLI benchmarks
35+
uses: CodSpeedHQ/action@d872884a306dd4853acf0f584f4b706cf0cc72a2
36+
timeout-minutes: 30
37+
env:
38+
RAYON_NUM_THREADS: 1
39+
CODSPEED_EXPERIMENTAL_FAIR_SCHED: true
40+
GH_MATRIX: '${{ toJson(matrix) }}'
41+
GH_STRATEGY: '${{ toJson(strategy) }}'
42+
with:
43+
mode: walltime
44+
run: pnpm run bench:cli
45+
runner-version: 4.13.0
46+
go-runner-version: 1.1.0

.github/workflows/benchmark-go.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Benchmark Go
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
benchmark-go:
8+
name: Run Go benchmarks
9+
runs-on: ubuntu-22.04
10+
permissions:
11+
contents: read
12+
id-token: write
13+
env:
14+
GOMAXPROCS: 8
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
18+
with:
19+
submodules: true
20+
fetch-depth: 1
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
24+
with:
25+
go-version: '1.26.0'
26+
cache: false
27+
28+
- name: Run benchmarks
29+
uses: CodSpeedHQ/action@d872884a306dd4853acf0f584f4b706cf0cc72a2
30+
with:
31+
mode: walltime
32+
run: go test -bench=. -benchtime=5s ./tests/bench-go/
33+
go-runner-version: 1.1.0

.github/workflows/benchmarks.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Benchmarks
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
benchmark-go:
15+
permissions:
16+
contents: read
17+
id-token: write
18+
uses: ./.github/workflows/benchmark-go.yml
19+
20+
benchmark-cli:
21+
permissions:
22+
contents: read
23+
id-token: write
24+
uses: ./.github/workflows/benchmark-cli.yml

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,21 @@ jobs:
319319
320320
- name: Run tests
321321
run: cargo test --verbose
322+
323+
benchmark-go:
324+
if: ${{ startsWith(github.ref_name, 'chore/release-') || startsWith(github.head_ref, 'chore/release-') }}
325+
permissions:
326+
contents: read
327+
id-token: write
328+
uses: ./.github/workflows/benchmark-go.yml
329+
330+
benchmark-cli:
331+
if: ${{ startsWith(github.ref_name, 'chore/release-') || startsWith(github.head_ref, 'chore/release-') }}
332+
permissions:
333+
contents: read
334+
id-token: write
335+
uses: ./.github/workflows/benchmark-cli.yml
336+
322337
done:
323338
needs:
324339
- test-go

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ npm/tsgo/*/local
156156
## vscode settings
157157
.vscode/settings.json
158158

159+
159160
# go cache
160161
packages/rslint/pkg/
161162

162163
# rust
163164
target/
164165

165166
# generated rule manifest
166-
website/generated/
167+
website/generated/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<a href="https://npmjs.com/package/@rslint/core?activeTab=readme"><img src="https://img.shields.io/npm/v/@rslint/core?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" /></a>
1010
<a href="https://npmcharts.com/compare/@rslint/core?minimal=true"><img src="https://img.shields.io/npm/dm/@rslint/core.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
1111
<a href="https://github.com/web-infra-dev/rslint/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" /></a>
12+
<a href="https://codspeed.io/web-infra-dev/rslint?utm_source=badge"><img src="https://img.shields.io/endpoint?url=https://codspeed.io/badge.json" alt="CodSpeed"/></a>
1213
</p>
1314

1415
> [!NOTE]

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"build": "pnpm -r --filter=!@typescript/api --filter=!@typescript/ast --filter=@rslint/test-tools... --filter=rslint... build",
1717
"build:npm": "zx scripts/build-npm.mjs",
1818
"build:website": "pnpm --filter @rslint/core run build:js && pnpm --filter=!@typescript/api --filter=!@typescript/ast --filter=!@rslint/core --filter @rslint/website... -r build",
19+
"bench:cli": "pnpm --filter rslint-bench-cli run bench",
20+
"bench:go": "go test -bench=. -benchtime=5s ./tests/bench-go/",
1921
"check-spell": "pnpx cspell lint --no-progress --show-context",
2022
"version": "zx scripts/version.mjs",
2123
"release": "pnpm publish -r --no-git-checks",

packages/rslint/tests/api.test.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ describe('lint api', async (t) => {
3939
});
4040
expect(diags).toMatchSnapshot();
4141
});
42+
43+
test('explicit files filter limits lint scope', async () => {
44+
const config = path.resolve(import.meta.dirname, '../fixtures/rslint.json');
45+
const targetFile = path.resolve(cwd, 'src/index.ts');
46+
const diags = await lint({
47+
config,
48+
files: [targetFile],
49+
ruleOptions: {
50+
'@typescript-eslint/no-unsafe-member-access': 'error',
51+
},
52+
workingDirectory: cwd,
53+
});
54+
55+
expect(diags.fileCount).toBe(1);
56+
expect(diags.diagnostics.length).toBeGreaterThan(0);
57+
expect(new Set(diags.diagnostics.map((diag) => diag.filePath))).toEqual(
58+
new Set(['src/index.ts']),
59+
);
60+
});
4261
});
4362

4463
describe('applyFixes api', async (t) => {

0 commit comments

Comments
 (0)