1- name : Test Shared librairies
1+ name : Benchmark and shared librairies
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 }}
5276 runs-on : ${{ matrix.runner }}
5377 steps :
5478 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
79+ if : ${{ github.event_name != 'workflow_dispatch' }}
5580 with :
5681 persist-credentials : false
5782
83+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
84+ if : ${{ github.event_name == 'workflow_dispatch' }}
85+ with :
86+ repository : ${{ inputs.repo || github.repository }}
87+ ref : refs/pull/${{ inputs.pr_id }}/merge
88+ persist-credentials : false
89+ fetch-depth : 2
90+
91+ - name : Validate PR head and roll back to base commit
92+ if : ${{ github.event_name == 'workflow_dispatch' }}
93+ run : |
94+ [ "$(git rev-parse HEAD^2)" = "$EXPECTED_SHA" ]
95+ git reset HEAD^ --hard
96+ env :
97+ EXPECTED_SHA : ${{ inputs.commit }}
98+
5899 - uses : cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
59100 with :
60101 extra_nix_config : sandbox = true
@@ -68,12 +109,19 @@ jobs:
68109 core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
69110 core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
70111
112+ - name : Load shell.nix
113+ if : github.event_name == 'workflow_dispatch'
114+ run : |
115+ [ -f shell.nix ] || curl -fsLSO https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/shell.nix
116+ [ -f nixpkgs.nix ] || curl -fsLSO https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/nixpkgs.nix
117+
71118 - name : Patch npm gyp
119+ if : github.event_name != 'workflow_dispatch'
72120 run : |
73121 curl -L https://github.com/nodejs/gyp-next/commit/8224deef984add7e7afe846cfb82c9d3fa6da1fb.diff \
74122 | git apply --directory=deps/npm/node_modules/node-gyp/gyp
75123
76- - name : Build Node.js and run tests
124+ - name : Build Node.js ${{ github.event_name == 'workflow_dispatch' && 'on the base commit' || ' and run tests' }}
77125 run : |
78126 nix-shell \
79127 -I nixpkgs=./nixpkgs.nix \
@@ -84,5 +132,93 @@ jobs:
84132 --arg devTools '[]' \
85133 --arg benchmarkTools '[]' \
86134 --run '
87- 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+ -I nixpkgs=./nixpkgs.nix \
146+ --pure \
147+ --arg loadJSBuiltinsDynamically false \
148+ --arg ccache 'null' \
149+ --arg devTools '[]' \
150+ --arg benchmarkTools '[]' \
151+ --run '
152+ make -j4 V=1
153+ '
154+
155+ - name : Run benchmark
156+ if : ${{ github.event_name == 'workflow_dispatch' }}
157+ run : |
158+ nix-shell \
159+ -I nixpkgs=./nixpkgs.nix \
160+ --pure --keep FILTER \
161+ --arg loadJSBuiltinsDynamically false \
162+ --arg ccache 'null' \
163+ --arg icu 'null' \
164+ --arg sharedLibDeps '{}' \
165+ --arg devTools '[]' \
166+ --run '
167+ set -o pipefail
168+ ./base_node benchmark/compare.js \
169+ --filter "$FILTER" \
170+ --runs ${{ inputs.runs }} \
171+ --old ./base_node --new ./node \
172+ -- ${{ inputs.category }} \
173+ | tee /dev/stderr \
174+ > ${{ matrix.system }}.csv
175+ Rscript benchmark/compare.R < ${{ matrix.system }}.csv
176+ '
177+ env :
178+ FILTER : ${{ inputs.filter }}
179+
180+ - name : Upload raw benchmark results
181+ if : ${{ github.event_name == 'workflow_dispatch' }}
182+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
183+ with :
184+ name : csv-${{ matrix.system }}
185+ path : ${{ matrix.system }}.csv
186+
187+ aggregate-benchmark-results :
188+ needs : build
189+ name : Aggregate benchmark results
190+ if : ${{ github.event_name == 'workflow_dispatch' }}
191+ runs-on : ubuntu-latest
192+ steps :
193+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
194+ with :
195+ persist-credentials : false
196+ sparse-checkout : |
197+ benchmark/*.R
198+ *.nix
199+ sparse-checkout-cone-mode : false
200+
201+ - name : Download benchmark raw results
202+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
203+ with :
204+ pattern : csv-*
205+ merge-multiple : true
206+ path : raw-results
207+
208+ - uses : cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
209+ with :
210+ extra_nix_config : sandbox = true
211+
212+ - name : Benchmark results
213+ run : |
214+ nix-shell \
215+ -I nixpkgs=./nixpkgs.nix \
216+ --pure \
217+ --arg loadJSBuiltinsDynamically false \
218+ --arg ccache 'null' \
219+ --arg icu 'null' \
220+ --arg sharedLibDeps '{}' \
221+ --arg devTools '[]' \
222+ --run '
223+ awk "FNR==1 && NR!=1{next;}{print}" raw-results/*.csv | Rscript benchmark/compare.R
88224 '
0 commit comments