Skip to content

Commit 048e11f

Browse files
committed
tools: add benchmark runner to test-shared
1 parent f92b376 commit 048e11f

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

.github/workflows/test-shared.yml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ on:
1919
- README.md
2020
- .github/**
2121
- '!.github/workflows/test-shared.yml'
22+
workflow_dispatch:
23+
inputs:
24+
commit:
25+
required: true
26+
type: string
27+
description: 'The commit SHA to benchmark against the tip of the current branch'
28+
category:
29+
required: true
30+
type: string
31+
description: The category (or categories) of tests to run, for example buffers, cluster etc. Maps to a folders in node/benchmark
32+
filter:
33+
type: string
34+
description: A substring to restrict the benchmarks to run in a category. e.g. `net-c2c`
35+
runs:
36+
type: number
37+
default: 30
38+
description: How many times to repeat each benchmark
2239

2340
concurrency:
2441
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -50,6 +67,13 @@ jobs:
5067
runs-on: ${{ matrix.runner }}
5168
steps:
5269
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
70+
with:
71+
repository: nodejs/node
72+
ref: refs/pull/59575/merge
73+
fetch-depth: 2
74+
- run: git show --name-only
75+
- run: git show --name-only HEAD^
76+
- run: git show --name-only HEAD^2
5377

5478
- uses: cachix/install-nix-action@f0fe604f8a612776892427721526b4c7cfb23aba # v31
5579
with:
@@ -63,6 +87,7 @@ jobs:
6387
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
6488

6589
- name: Configure sccache
90+
if: false
6691
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
6792
with:
6893
script: |
@@ -75,6 +100,7 @@ jobs:
75100
run: curl -L https://github.com/npm/cli/pull/8531.diff | git apply --directory=deps/npm --exclude=deps/npm/package-lock.json
76101

77102
- name: Build Node.js and run tests
103+
if: false
78104
run: |
79105
nix-shell \
80106
--pure --keep FLAKY_TESTS \
@@ -84,5 +110,47 @@ jobs:
84110
--arg devTools '[]' \
85111
--arg benchmarkTools '[]' \
86112
--run '
87-
make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
113+
make ${{ github.event_name == 'workflow_dispatch' && 'build' || 'run' }}-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
114+
'
115+
116+
- name: Pull commit to benchmark
117+
if: ${{ github.event_name == 'workflow_dispatch' }}
118+
run: git pull --allow-unrelated-histories --no-rebase --no-commit --no-ff --depth=1 origin ${{ inputs.commit }}
119+
120+
- run: git log
121+
122+
- name: Re-build Node.js
123+
# ccache is disabled here to avoid polluting the cache. Local build outputs should make this build relatively quick anyway.
124+
if: ${{ github.event_name == 'workflow_dispatch' }}
125+
run: |
126+
mv out/Release/node base_node
127+
nix-shell \
128+
--pure \
129+
--arg loadJSBuiltinsDynamically false \
130+
--arg ccache 'null' \
131+
--arg devTools '[]' \
132+
--arg benchmarkTools '[]' \
133+
--run '
134+
make build-ci -j4 V=1
135+
'
136+
137+
- name: Run benchmark
138+
if: ${{ github.event_name == 'workflow_dispatch' }}
139+
run: |
140+
nix-shell \
141+
--pure --keep FILTER \
142+
--arg loadJSBuiltinsDynamically false \
143+
--arg ccache 'null' \
144+
--arg devTools '[]' \
145+
--run '
146+
./base_node benchmark/compare.js \
147+
--filter "$FILTER" \
148+
--runs ${{ inputs.runs }} \
149+
--old ./base_node --new ./node \
150+
-- ${{ inputs.category }} \
151+
| Rscript benchmark/compare.R
88152
'
153+
env:
154+
FILTER: ${{ inputs.filter }}
155+
156+

0 commit comments

Comments
 (0)