Skip to content

Commit 45ee41f

Browse files
authored
feat: improve ci perf (#21)
* feat: split build job * feat: concurrent execute bench task * fix: bench suite only * fix: change runner * chore: remove Set Rspack Dir * fix: corepack proxy * feat: bench machine only 3 * feat: use move strage * feat: use more perf machine to build * fix: group test config * perf: build rspack * chore: show good to show * feat: support bench args * chore: print latest log * chore: rm get-runner-labels * chore: show hash * fix: pr and commit workflow * chore: refactor bench cli * feat: new bench_rspack_commit workflows * fix: ci use new cli * feat: new bench_rspack_pr * feat: new sheduled * fix: use benchmarkDirectory * chore: pretter
1 parent 4fdec78 commit 45ee41f

29 files changed

+719
-358
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: "Build Rspack"
2+
description: "Checkout, download rspack binding, and build rspack js"
3+
4+
inputs:
5+
repository:
6+
description: "The rspack repository to use"
7+
required: true
8+
default: "web-infra-dev/rspack"
9+
path:
10+
description: "Destination path to the rspack repository"
11+
required: true
12+
default: ".rspack"
13+
ref:
14+
description: "The branch, tag or SHA to checkout"
15+
required: true
16+
default: "main"
17+
node-version:
18+
description: "The version of Node.js to set up"
19+
required: true
20+
default: "18"
21+
22+
outputs:
23+
artifact-name:
24+
description: "The name of the uploaded artifact"
25+
26+
runs:
27+
using: composite
28+
steps:
29+
- shell: bash
30+
run: |
31+
npm install -g [email protected]
32+
echo "Corepack version: $(corepack --version)"
33+
corepack enable
34+
- shell: bash
35+
run: pnpm --version
36+
- shell: bash
37+
run: pnpm install --prefer-frozen-lockfile --prefer-offline
38+
- name: Build Rspack JS
39+
shell: bash
40+
run: >-
41+
node bin/cli.js build
42+
--repository ${{ inputs.repository }}
43+
--ref ${{ inputs.ref }}
44+
--binding false
45+
--js true
46+
- uses: actions/download-artifact@v4
47+
with:
48+
name: binding-linux-x64-gnu
49+
path: ${{ inputs.path }}/crates/node_binding
50+
- name: Show restored binding
51+
shell: bash
52+
run: ls -lah ${{ inputs.path }}/crates/node_binding/*.node

.github/actions/env/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ runs:
66
using: composite
77
steps:
88
- name: Setup node
9-
uses: actions/setup-node@v3
9+
uses: actions/setup-node@v4
1010
with:
1111
node-version: 20
1212
- name: Activate corepack
@@ -19,7 +19,7 @@ runs:
1919
corepack enable
2020
- name: Install dependencies with pnpm
2121
shell: bash
22-
run: pnpm install
22+
run: pnpm install --prefer-frozen-lockfile --prefer-offline
2323
- name: Set Rspack Dir
2424
shell: bash
2525
run: |
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Prepare Rspack Binding"
2+
description: "Checkout, build, and upload rspack native bindings"
3+
4+
inputs:
5+
repository:
6+
description: "The rspack repository to use"
7+
required: true
8+
default: "web-infra-dev/rspack"
9+
path:
10+
description: "Destination path to clone"
11+
required: true
12+
default: ".rspack"
13+
ref:
14+
description: "The branch, tag or SHA to checkout"
15+
required: true
16+
default: "main"
17+
node-version:
18+
description: "The version of Node.js to set up"
19+
required: true
20+
default: "18"
21+
22+
outputs:
23+
artifact-name:
24+
description: "The name of the uploaded artifact"
25+
26+
runs:
27+
using: composite
28+
steps:
29+
- name: Build Rspack
30+
shell: bash
31+
run: >-
32+
node bin/cli.js build
33+
--repository ${{ inputs.repository }}
34+
--ref ${{ inputs.ref }}
35+
--binding true
36+
--js false
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: binding-linux-x64-gnu
40+
path: ${{ inputs.path }}/crates/node_binding/*.node
41+
compression-level: 9

.github/workflows/bench_rspack_commit.yml

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,70 @@ on:
99
type: string
1010

1111
jobs:
12-
run-bench:
12+
prepare-binding:
13+
name: Prepare Rspack Binding
1314
runs-on: [self-hosted, benchmark]
14-
outputs:
15-
diff-result: ${{ steps.print-results.outputs.diff-result }}
1615
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1917
- name: Init env
2018
uses: ./.github/actions/env
21-
- name: Build rspack
22-
run: node bin/build-rspack.js origin ${{ inputs.commit_sha }}
19+
- uses: ./.github/actions/prepare-rspack-binding
20+
with:
21+
path: ${{ env.RSPACK_DIR }}
22+
23+
bench:
24+
runs-on: [self-hosted, benchmark]
25+
needs: prepare-binding
26+
timeout-minutes: 30
27+
strategy:
28+
matrix:
29+
shardIndex: [1, 2, 3]
30+
shardTotal: [3]
31+
fail-fast: false
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Init env
35+
uses: ./.github/actions/env
36+
- uses: ./.github/actions/build-rspack
37+
with:
38+
path: ${{ env.RSPACK_DIR }}
2339
- name: Run benchmark
24-
run: node bin/bench.js
40+
run: node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ smatrix.shardTotal }}
41+
- uses: actions/upload-artifact@v4
42+
with:
43+
name: benchmark-artifacts-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
44+
path: output
45+
46+
comment-compare-results:
47+
runs-on: ubuntu-latest
48+
needs: bench
49+
if: always()
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Init env
53+
uses: ./.github/actions/env
54+
- uses: actions/download-artifact@v4
55+
with:
56+
pattern: benchmark-artifacts-*
57+
path: output
58+
merge-multiple: true
2559
- id: print-results
2660
name: Print results
2761
run: |
28-
result=$(node bin/compare-bench.js latest current)
62+
result=$(node bin/cli.js compare --base latest --current current)
2963
echo "$result"
3064
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
3165
if [[ $result =~ "Threshold exceeded" ]]; then
3266
echo "Some benchmark cases exceed the threshold, please visit the previous step for more information"
3367
exit 1
3468
fi
35-
36-
create-comment:
37-
runs-on: ubuntu-latest
38-
needs: [run-bench]
39-
if: always()
40-
steps:
41-
- id: create-comment
42-
uses: actions/github-script@v6
69+
- uses: actions/github-script@v6
4370
with:
4471
github-token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }}
4572
result-encoding: string
4673
script: |
47-
const diffResult = `${{ needs.run-bench.outputs.diff-result }}`
48-
let result = "task ${{ needs.run-bench.result }}"
74+
const diffResult = `${{ steps.print-results.outputs.diff-result }}`
75+
let result = "task ${{ needs.bench.result }}"
4976
if (diffResult) {
5077
result = diffResult.replace(/@@/g, "\n");
5178
}

.github/workflows/bench_rspack_pr.yml

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,72 @@ jobs:
3131
})
3232
return comment.id
3333
34-
run-bench:
34+
prepare-binding:
35+
name: Prepare Rspack Binding
3536
runs-on: [self-hosted, benchmark]
36-
needs: create-comment
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Init env
40+
uses: ./.github/actions/env
41+
- uses: ./.github/actions/prepare-rspack-binding
42+
with:
43+
path: ${{ env.RSPACK_DIR }}
44+
45+
bench:
46+
runs-on: [self-hosted, benchmark]
47+
needs: [create-comment, prepare-binding]
48+
timeout-minutes: 30
49+
strategy:
50+
matrix:
51+
shardIndex: [1, 2, 3]
52+
shardTotal: [3]
53+
fail-fast: false
3754
outputs:
3855
diff-result: ${{ steps.print-results.outputs.diff-result }}
3956
steps:
40-
- name: Checkout
41-
uses: actions/checkout@v2
57+
- uses: actions/checkout@v4
4258
- name: Init env
4359
uses: ./.github/actions/env
44-
- name: Build rspack
45-
run: node bin/build-rspack.js origin pull/${{ inputs.prNumber }}/head
60+
- uses: ./.github/actions/build-rspack
61+
with:
62+
path: ${{ env.RSPACK_DIR }}
63+
ref: pull/${{ inputs.prNumber }}/head
4664
- name: Run benchmark
47-
run: node bin/bench.js
65+
run: node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
66+
- uses: actions/upload-artifact@v4
67+
with:
68+
name: benchmark-artifacts-${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
69+
path: output
70+
71+
comment-compare-results:
72+
runs-on: ubuntu-latest
73+
needs: [create-comment, bench]
74+
if: always()
75+
steps:
76+
- uses: actions/checkout@v4
77+
- name: Init env
78+
uses: ./.github/actions/env
79+
- uses: actions/download-artifact@v4
80+
with:
81+
pattern: benchmark-artifacts-*
82+
path: output
83+
merge-multiple: true
4884
- id: print-results
4985
name: Print results
5086
run: |
51-
result=$(node bin/compare-bench.js latest current)
87+
result=$(node bin/cli.js compare --base latest --current current)
5288
echo "$result"
5389
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
5490
if [[ $result =~ "Threshold exceeded" ]]; then
5591
echo "Some benchmark cases exceed the threshold, please visit the previous step for more information"
5692
exit 1
5793
fi
58-
59-
update-comment:
60-
runs-on: ubuntu-latest
61-
needs: [create-comment, run-bench]
62-
if: always()
63-
steps:
6494
- uses: actions/github-script@v6
6595
with:
6696
github-token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }}
6797
script: |
68-
const diffResult = `${{ needs.run-bench.outputs.diff-result }}`
69-
let result = "task ${{ needs.run-bench.result }}"
98+
const diffResult = `${{ steps.print-results.outputs.diff-result }}`
99+
let result = "task ${{ needs.bench.result }}"
70100
if (diffResult) {
71101
result = diffResult.replace(/@@/g, "\n");
72102
}

.github/workflows/ci.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- "**/*.md"
99
pull_request:
1010
types: [opened, synchronize]
11-
branches: [ main ]
11+
branches: [main]
1212
paths-ignore:
1313
- "**/*.md"
1414

@@ -17,21 +17,40 @@ concurrency:
1717
cancel-in-progress: ${{ github.ref_name != 'main' }}
1818

1919
jobs:
20-
ci:
20+
prepare-binding:
21+
name: Prepare Rspack Binding
2122
runs-on: [self-hosted, benchmark]
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Init env
26+
uses: ./.github/actions/env
27+
- uses: ./.github/actions/prepare-rspack-binding
28+
with:
29+
path: ${{ env.RSPACK_DIR }}
30+
31+
bench:
32+
needs: prepare-binding
33+
runs-on: [self-hosted, benchmark]
34+
timeout-minutes: 30
35+
strategy:
36+
matrix:
37+
shardIndex: [1, 2, 3]
38+
shardTotal: [3]
39+
fail-fast: false
2240
steps:
2341
- name: Checkout
24-
uses: actions/checkout@v2
42+
uses: actions/checkout@v4
2543
- name: Init env
2644
uses: ./.github/actions/env
27-
- name: Build rspack
28-
run: node bin/build-rspack.js
45+
- uses: ./.github/actions/build-rspack
46+
with:
47+
path: ${{ env.RSPACK_DIR }}
2948
- name: Run benchmark
30-
run: node bin/bench.js
49+
run: node bin/cli.js bench --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
3150
- id: print-compare-results
3251
name: Print compare results
3352
run: |
34-
result=$(node bin/compare-bench.js latest current)
53+
result=$(node bin/cli.js compare --base latest --current current)
3554
echo "$result"
3655
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
3756
- name: Check Threshold

.github/workflows/scheduled_bench.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ jobs:
88
bench:
99
runs-on: [self-hosted, benchmark]
1010
steps:
11-
- name: Checkout
12-
uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1312
- name: Init env
1413
uses: ./.github/actions/env
1514
- name: Build rspack
16-
run: node bin/build-rspack.js
15+
run: node bin/cli.js build
1716
- name: Run benchmark
18-
run: node bin/bench.js
17+
run: node bin/cli.js bench
1918
- id: print-compare-results
2019
name: Print compare results
2120
run: |
22-
result=$(node bin/compare-bench.js latest current)
21+
result=$(node bin/cli.js compare --base latest --current current)
2322
echo "$result"
2423
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
2524
- name: Setup git user

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.rspack/**
2+
output/**
3+
cases/**
4+
pnpm-lock.yaml
5+
pnpm-workspace.yaml

0 commit comments

Comments
 (0)