1- name : Test Shared libraries
1+ name : Benchmark and shared libraries
22
33on :
44 pull_request :
2323 - doc/**
2424 - .github/**
2525 - ' !.github/workflows/test-shared.yml'
26+ workflow_dispatch :
27+ inputs :
28+ repo :
29+ type : string
30+ description : GitHub repository to fetch from (default to the current repo)
31+ pr_id :
32+ type : number
33+ required : true
34+ description : The PR to test
35+ commit :
36+ required : true
37+ type : string
38+ description : The expect HEAD of the PR
39+ category :
40+ required : true
41+ type : string
42+ description : The category (or categories) of tests to run, for example buffers, cluster etc. Maps to a folders in node/benchmark
43+ filter :
44+ type : string
45+ description : A substring to restrict the benchmarks to run in a category. e.g. `net-c2c`
46+ runs :
47+ type : number
48+ default : 30
49+ description : How many times to repeat each benchmark
2650
2751concurrency :
2852 group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -91,6 +115,22 @@ jobs:
91115 tar xzf tarballs/*.tar.gz -C "$RUNNER_TEMP"
92116 echo "TAR_DIR=$RUNNER_TEMP/$(basename tarballs/*.tar.gz .tar.gz)" >> "$GITHUB_ENV"
93117
118+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
119+ if : ${{ github.event_name == 'workflow_dispatch' }}
120+ with :
121+ repository : ${{ inputs.repo || github.repository }}
122+ ref : refs/pull/${{ inputs.pr_id }}/merge
123+ persist-credentials : false
124+ fetch-depth : 2
125+
126+ - name : Validate PR head and roll back to base commit
127+ if : ${{ github.event_name == 'workflow_dispatch' }}
128+ run : |
129+ [ "$(git rev-parse HEAD^2)" = "$EXPECTED_SHA" ]
130+ git reset HEAD^ --hard
131+ env :
132+ EXPECTED_SHA : ${{ inputs.commit }}
133+
94134 - uses : cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
95135 with :
96136 extra_nix_config : sandbox = true
@@ -111,7 +151,7 @@ jobs:
111151 mkdir tools
112152 mv "$TAR_DIR"/tools/nix tools/.
113153
114- - name : Build Node.js and run tests
154+ - name : Build Node.js ${{ github.event_name == 'workflow_dispatch' && 'on the base commit' || ' and run tests' }}
115155 run : |
116156 nix-shell \
117157 -I nixpkgs=./tools/nix/pkgs.nix \
@@ -123,5 +163,114 @@ jobs:
123163 --arg benchmarkTools '[]' \
124164 ${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-inspector"]'' \' || '\' }}
125165 --run '
126- make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
166+ make -C "$TAR_DIR" ${{ github.event_name == 'workflow_dispatch' && 'build' || 'run' }}-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
167+ '
168+
169+ - name : Re-build Node.js on the merge commit
170+ # ccache is disabled here to avoid polluting the cache. Local build outputs should make this build relatively quick anyway.
171+ if : ${{ github.event_name == 'workflow_dispatch' }}
172+ run : |
173+ mv out/Release/node base_node
174+ git reset FETCH_HEAD --hard
175+ nix-shell \
176+ -I nixpkgs=./tools/nix/pkgs.nix \
177+ --pure \
178+ --arg loadJSBuiltinsDynamically false \
179+ --arg ccache 'null' \
180+ --arg devTools '[]' \
181+ --arg benchmarkTools '[]' \
182+ --run '
183+ make -j4 V=1
127184 '
185+
186+ - name : Run benchmark
187+ if : ${{ github.event_name == 'workflow_dispatch' }}
188+ run : |
189+ nix-shell \
190+ -I nixpkgs=./tools/nix/pkgs.nix \
191+ --pure --keep FILTER --keep LC_ALL --keep LANG \
192+ --arg loadJSBuiltinsDynamically false \
193+ --arg ccache 'null' \
194+ --arg icu 'null' \
195+ --arg sharedLibDeps '{}' \
196+ --arg devTools '[]' \
197+ --run '
198+ set -o pipefail
199+ ./base_node benchmark/compare.js \
200+ --filter "$FILTER" \
201+ --runs ${{ inputs.runs }} \
202+ --old ./base_node --new ./node \
203+ -- ${{ inputs.category }} \
204+ | tee /dev/stderr \
205+ > ${{ matrix.system }}.csv
206+ echo "Warning: do not take GHA benchmark results as face value, always confirm them"
207+ echo "using a dedicated machine, e.g. Jenkins CI."
208+ echo
209+ echo "Benchmark results:"
210+ echo
211+ echo '"'"'```'"'"'
212+ Rscript benchmark/compare.R < ${{ matrix.system }}.csv
213+ echo '"'"'```'"'"'
214+ echo
215+ echo "Warning: do not take GHA benchmark results as face value, always confirm them"
216+ echo "using a dedicated machine, e.g. Jenkins CI."
217+ ' | tee /dev/stderr >> "$GITHUB_STEP_SUMMARY"
218+ env :
219+ FILTER : ${{ inputs.filter }}
220+
221+ - name : Upload raw benchmark results
222+ if : ${{ github.event_name == 'workflow_dispatch' }}
223+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
224+ with :
225+ name : csv-${{ matrix.system }}
226+ path : ${{ matrix.system }}.csv
227+
228+ aggregate-benchmark-results :
229+ needs : build
230+ name : Aggregate benchmark results
231+ if : ${{ github.event_name == 'workflow_dispatch' }}
232+ runs-on : ubuntu-latest
233+ steps :
234+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
235+ with :
236+ persist-credentials : false
237+ sparse-checkout : |
238+ benchmark/*.R
239+ tools/nix/*.nix
240+ *.nix
241+ sparse-checkout-cone-mode : false
242+
243+ - name : Download benchmark raw results
244+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
245+ with :
246+ pattern : csv-*
247+ merge-multiple : true
248+ path : raw-results
249+
250+ - uses : cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
251+ with :
252+ extra_nix_config : sandbox = true
253+
254+ - name : Benchmark results
255+ run : |
256+ nix-shell \
257+ -I nixpkgs=./tools/nix/pkgs.nix \
258+ --pure --keep LC_ALL --keep LANG \
259+ --arg loadJSBuiltinsDynamically false \
260+ --arg ccache 'null' \
261+ --arg icu 'null' \
262+ --arg sharedLibDeps '{}' \
263+ --arg devTools '[]' \
264+ --run '
265+ echo "Warning: do not take GHA benchmark results as face value, always confirm them"
266+ echo "using a dedicated machine, e.g. Jenkins CI."
267+ echo
268+ echo "Benchmark results:"
269+ echo
270+ echo '"'"'```'"'"'
271+ awk "FNR==1 && NR!=1{next;}{print}" raw-results/*.csv | Rscript benchmark/compare.R
272+ echo '"'"'```'"'"'
273+ echo
274+ echo "Warning: do not take GHA benchmark results as face value, always confirm them"
275+ echo "using a dedicated machine, e.g. Jenkins CI."
276+ ' | tee /dev/stderr >> "$GITHUB_STEP_SUMMARY"
0 commit comments