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 }}
@@ -44,12 +68,28 @@ jobs:
4468 system : aarch64-linux
4569 - runner : macos-13
4670 system : x86_64-darwin
47- - runner : macos-14
71+ - runner : macos-latest
4872 system : aarch64-darwin
4973 name : ' ${{ matrix.system }}: with shared libraries'
5074 runs-on : ${{ matrix.runner }}
5175 steps :
5276 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
77+ if : ${{ github.event_name != 'workflow_dispatch' }}
78+
79+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
80+ if : ${{ github.event_name == 'workflow_dispatch' }}
81+ with :
82+ repository : ${{ inputs.repo || github.repository }}
83+ ref : refs/pull/${{ inputs.pr_id }}/merge
84+ fetch-depth : 2
85+
86+ - name : Validate PR head and roll back to base commit
87+ if : ${{ github.event_name == 'workflow_dispatch' }}
88+ run : |
89+ [ "$(git rev-parse HEAD^2)" = "$EXPECTED_SHA" ]
90+ git reset HEAD^ --hard
91+ env :
92+ EXPECTED_SHA : ${{ inputs.commit }}
5393
5494 - uses : cachix/install-nix-action@f0fe604f8a612776892427721526b4c7cfb23aba # v31
5595 with :
@@ -71,10 +111,15 @@ jobs:
71111 core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
72112 core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
73113
74- - name : Patch npm gyp
114+ - name : Patch npm gyp (to be able to build addons for the tests)
115+ if : ${{ github.event_name != 'workflow_dispatch' }}
75116 run : curl -L https://github.com/npm/cli/pull/8531.diff | git apply --directory=deps/npm --exclude=deps/npm/package-lock.json
117+
118+ - name : Load shell.nix
119+ if : ${{ github.event_name == 'workflow_dispatch' }}
120+ run : curl -fsLSO https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/shell.nix
76121
77- - name : Build Node.js and run tests
122+ - name : Build Node.js ${{ github.event_name == 'workflow_dispatch' && 'on the base commit' || ' and run tests' }}
78123 run : |
79124 nix-shell \
80125 --pure --keep FLAKY_TESTS \
@@ -84,5 +129,89 @@ jobs:
84129 --arg devTools '[]' \
85130 --arg benchmarkTools '[]' \
86131 --run '
87- make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
132+ 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"
133+ '
134+
135+ - name : Re-build Node.js on the merge commit
136+ # ccache is disabled here to avoid polluting the cache. Local build outputs should make this build relatively quick anyway.
137+ if : ${{ github.event_name == 'workflow_dispatch' }}
138+ run : |
139+ mv out/Release/node base_node
140+ git reset FETCH_HEAD --hard
141+ nix-shell \
142+ --pure \
143+ --arg loadJSBuiltinsDynamically false \
144+ --arg ccache 'null' \
145+ --arg devTools '[]' \
146+ --arg benchmarkTools '[]' \
147+ --run '
148+ make -j4 V=1
149+ '
150+
151+ - name : Run benchmark
152+ if : ${{ github.event_name == 'workflow_dispatch' }}
153+ run : |
154+ nix-shell \
155+ --pure --keep FILTER \
156+ --arg loadJSBuiltinsDynamically false \
157+ --arg ccache 'null' \
158+ --arg devTools '[]' \
159+ --run '
160+ set -o pipefail
161+ ./base_node benchmark/compare.js \
162+ --filter "$FILTER" \
163+ --runs ${{ inputs.runs }} \
164+ --old ./base_node --new ./node \
165+ -- ${{ inputs.category }} \
166+ | tee /dev/stderr \
167+ > ${{ matrix.system }}.csv
168+ Rscript benchmark/compare.R < ${{ matrix.system }}.csv
169+ '
170+ env :
171+ FILTER : ${{ inputs.filter }}
172+
173+ - name : Upload raw benchmark results
174+ if : ${{ github.event_name == 'workflow_dispatch' }}
175+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
176+ with :
177+ name : csv-${{ matrix.system }}
178+ path : ${{ matrix.system }}.csv
179+
180+
181+ aggregate-benchmark-results :
182+ needs : build
183+ name : Aggregate benchmark results
184+ if : ${{ github.event_name == 'workflow_dispatch' }}
185+ runs-on : ubuntu-latest
186+ steps :
187+ - name : Download benchmark raw results
188+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
189+ with :
190+ pattern : csv-*
191+ merge-multiple : true
192+
193+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
194+ with :
195+ sparse-checkout : benchmark
196+
197+ - uses : cachix/install-nix-action@f0fe604f8a612776892427721526b4c7cfb23aba # v31
198+ with :
199+ extra_nix_config : sandbox = true
200+ github_access_token : ${{ secrets.GITHUB_TOKEN }}
201+ nix_path : nixpkgs=${{ env.NIXPKGS_REPO }}/archive/${{ env.NIXPKGS_PIN }}.tar.gz
202+
203+ - uses : cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
204+ with :
205+ name : nodejs
206+ authToken : ${{ secrets.CACHIX_AUTH_TOKEN }}
207+
208+ - name : Benchmark results
209+ run : |
210+ nix-shell \
211+ --pure \
212+ --arg loadJSBuiltinsDynamically false \
213+ --arg ccache 'null' \
214+ --arg devTools '[]' \
215+ --run '
216+ cat *.csv | Rscript benchmark/compare.R
88217 '
0 commit comments