1- name : Test Shared librairies
1+ name : Benchmark and shared librairies
22
33on :
44 pull_request :
1919 - README.md
2020 - .github/**
2121 - ' !.github/workflows/test-shared.yml'
22+ workflow_dispatch :
23+ inputs :
24+ repo :
25+ type : string
26+ description : ' GitHub repository to fetch from (default to the current repo)'
27+ pr_id :
28+ type : number
29+ required : true
30+ description : ' The PR to test'
31+ commit :
32+ required : true
33+ type : string
34+ description : ' The expect HEAD of the PR'
35+ category :
36+ required : true
37+ type : string
38+ description : The category (or categories) of tests to run, for example buffers, cluster etc. Maps to a folders in node/benchmark
39+ filter :
40+ type : string
41+ description : A substring to restrict the benchmarks to run in a category. e.g. `net-c2c`
42+ runs :
43+ type : number
44+ default : 30
45+ description : How many times to repeat each benchmark
2246
2347concurrency :
2448 group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
5074 runs-on : ${{ matrix.runner }}
5175 steps :
5276 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
77+ if : ${{ github.event_name != 'workflow_dispatch' }}
5378 with :
5479 persist-credentials : false
5580
81+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
82+ if : ${{ github.event_name == 'workflow_dispatch' }}
83+ with :
84+ repository : ${{ inputs.repo || github.repository }}
85+ ref : refs/pull/${{ inputs.pr_id }}/merge
86+ persist-credentials : false
87+ fetch-depth : 2
88+
89+ - name : Validate PR head and roll back to base commit
90+ if : ${{ github.event_name == 'workflow_dispatch' }}
91+ run : |
92+ [ "$(git rev-parse HEAD^2)" = "$EXPECTED_SHA" ]
93+ git reset HEAD^ --hard
94+ env :
95+ EXPECTED_SHA : ${{ inputs.commit }}
96+
5697 - uses : cachix/install-nix-action@f0fe604f8a612776892427721526b4c7cfb23aba # v31
5798 with :
5899 extra_nix_config : sandbox = true
@@ -73,10 +114,15 @@ jobs:
73114 core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
74115 core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
75116
76- - name : Patch npm gyp
117+ - name : Patch npm gyp (to be able to build addons for the tests)
118+ if : ${{ github.event_name != 'workflow_dispatch' }}
77119 run : curl -L https://github.com/npm/cli/pull/8531.diff | git apply --directory=deps/npm --exclude=deps/npm/package-lock.json
120+
121+ - name : Load shell.nix
122+ if : ${{ github.event_name == 'workflow_dispatch' }}
123+ run : curl -fsLSO https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/shell.nix
78124
79- - name : Build Node.js and run tests
125+ - name : Build Node.js ${{ github.event_name == 'workflow_dispatch' && 'on the base commit' || ' and run tests' }}
80126 run : |
81127 nix-shell \
82128 --pure --keep FLAKY_TESTS \
@@ -86,5 +132,98 @@ jobs:
86132 --arg devTools '[]' \
87133 --arg benchmarkTools '[]' \
88134 --run '
89- make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
135+ 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"
136+ '
137+
138+ - name : Re-build Node.js on the merge commit
139+ # ccache is disabled here to avoid polluting the cache. Local build outputs should make this build relatively quick anyway.
140+ if : ${{ github.event_name == 'workflow_dispatch' }}
141+ run : |
142+ mv out/Release/node base_node
143+ git reset FETCH_HEAD --hard
144+ nix-shell \
145+ --pure \
146+ --arg loadJSBuiltinsDynamically false \
147+ --arg ccache 'null' \
148+ --arg devTools '[]' \
149+ --arg benchmarkTools '[]' \
150+ --run '
151+ make -j4 V=1
152+ '
153+
154+ - name : Run benchmark
155+ if : ${{ github.event_name == 'workflow_dispatch' }}
156+ run : |
157+ nix-shell \
158+ --pure --keep FILTER \
159+ --arg loadJSBuiltinsDynamically false \
160+ --arg ccache 'null' \
161+ --arg icu 'null' \
162+ --arg sharedLibDeps '{}' \
163+ --arg devTools '[]' \
164+ --run '
165+ set -o pipefail
166+ ./base_node benchmark/compare.js \
167+ --filter "$FILTER" \
168+ --runs ${{ inputs.runs }} \
169+ --old ./base_node --new ./node \
170+ -- ${{ inputs.category }} \
171+ | tee /dev/stderr \
172+ > ${{ matrix.system }}.csv
173+ Rscript benchmark/compare.R < ${{ matrix.system }}.csv
174+ '
175+ env :
176+ FILTER : ${{ inputs.filter }}
177+
178+ - name : Upload raw benchmark results
179+ if : ${{ github.event_name == 'workflow_dispatch' }}
180+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
181+ with :
182+ name : csv-${{ matrix.system }}
183+ path : ${{ matrix.system }}.csv
184+
185+
186+ aggregate-benchmark-results :
187+ needs : build
188+ name : Aggregate benchmark results
189+ if : ${{ github.event_name == 'workflow_dispatch' }}
190+ runs-on : ubuntu-latest
191+ steps :
192+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
193+ with :
194+ persist-credentials : false
195+ sparse-checkout : |
196+ benchmark/*.R
197+ shell.nix
198+ sparse-checkout-cone-mode : false
199+
200+ - name : Download benchmark raw results
201+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
202+ with :
203+ pattern : csv-*
204+ merge-multiple : true
205+ path : raw-results
206+
207+ - uses : cachix/install-nix-action@f0fe604f8a612776892427721526b4c7cfb23aba # v31
208+ with :
209+ extra_nix_config : sandbox = true
210+ github_access_token : ${{ secrets.GITHUB_TOKEN }}
211+ nix_path : nixpkgs=${{ env.NIXPKGS_REPO }}/archive/${{ env.NIXPKGS_PIN }}.tar.gz
212+
213+ - uses : cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
214+ with :
215+ name : nodejs
216+ authToken : ${{ secrets.CACHIX_AUTH_TOKEN }}
217+
218+ - name : Benchmark results
219+ run : |
220+ nix-shell \
221+ --pure \
222+ --arg loadJSBuiltinsDynamically false \
223+ --arg ccache 'null' \
224+ --arg icu 'null' \
225+ --arg sharedLibDeps '{}' \
226+ --arg devTools '[]' \
227+ --run '
228+ awk "FNR==1 && NR!=1{next;}{print}" raw-results/*.csv | Rscript benchmark/compare.R
90229 '
0 commit comments