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 }}
5377 runs-on : ${{ matrix.runner }}
5478 steps :
5579 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
80+ if : ${{ github.event_name != 'workflow_dispatch' }}
5681 with :
5782 persist-credentials : false
5883
84+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
85+ if : ${{ github.event_name == 'workflow_dispatch' }}
86+ with :
87+ repository : ${{ inputs.repo || github.repository }}
88+ ref : refs/pull/${{ inputs.pr_id }}/merge
89+ persist-credentials : false
90+ fetch-depth : 2
91+
92+ - name : Validate PR head and roll back to base commit
93+ if : ${{ github.event_name == 'workflow_dispatch' }}
94+ run : |
95+ [ "$(git rev-parse HEAD^2)" = "$EXPECTED_SHA" ]
96+ git reset HEAD^ --hard
97+ env :
98+ EXPECTED_SHA : ${{ inputs.commit }}
99+
59100 - uses : cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
60101 with :
61102 extra_nix_config : sandbox = true
69110 core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
70111 core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
71112
72- - name : Build Node.js and run tests
113+ - name : Build Node.js ${{ github.event_name == 'workflow_dispatch' && 'on the base commit' || ' and run tests' }}
73114 run : |
74115 nix-shell \
75116 -I nixpkgs=./tools/nix/pkgs.nix \
@@ -81,5 +122,114 @@ jobs:
81122 --arg benchmarkTools '[]' \
82123 ${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-inspector"]'' \' || '\' }}
83124 --run '
84- make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
125+ 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"
85126 '
127+
128+ - name : Re-build Node.js on the merge commit
129+ # ccache is disabled here to avoid polluting the cache. Local build outputs should make this build relatively quick anyway.
130+ if : ${{ github.event_name == 'workflow_dispatch' }}
131+ run : |
132+ mv out/Release/node base_node
133+ git reset FETCH_HEAD --hard
134+ nix-shell \
135+ -I nixpkgs=./tools/nix/pkgs.nix \
136+ --pure \
137+ --arg loadJSBuiltinsDynamically false \
138+ --arg ccache 'null' \
139+ --arg devTools '[]' \
140+ --arg benchmarkTools '[]' \
141+ --run '
142+ make -j4 V=1
143+ '
144+
145+ - name : Run benchmark
146+ if : ${{ github.event_name == 'workflow_dispatch' }}
147+ run : |
148+ nix-shell \
149+ -I nixpkgs=./tools/nix/pkgs.nix \
150+ --pure --keep FILTER --keep LC_ALL --keep LANG \
151+ --arg loadJSBuiltinsDynamically false \
152+ --arg ccache 'null' \
153+ --arg icu 'null' \
154+ --arg sharedLibDeps '{}' \
155+ --arg devTools '[]' \
156+ --run '
157+ set -o pipefail
158+ ./base_node benchmark/compare.js \
159+ --filter "$FILTER" \
160+ --runs ${{ inputs.runs }} \
161+ --old ./base_node --new ./node \
162+ -- ${{ inputs.category }} \
163+ | tee /dev/stderr \
164+ > ${{ matrix.system }}.csv
165+ echo "Warning: do not take GHA benchmark results as face value, always confirm them"
166+ echo "using a dedicated machine, e.g. Jenkins CI."
167+ echo
168+ echo "Benchmark results:"
169+ echo
170+ echo '"'"'```'"'"'
171+ Rscript benchmark/compare.R < ${{ matrix.system }}.csv
172+ echo '"'"'```'"'"'
173+ echo
174+ echo "Warning: do not take GHA benchmark results as face value, always confirm them"
175+ echo "using a dedicated machine, e.g. Jenkins CI."
176+ ' | tee /dev/stderr >> "$GITHUB_STEP_SUMMARY"
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+ tools/nix/*.nix
199+ *.nix
200+ sparse-checkout-cone-mode : false
201+
202+ - name : Download benchmark raw results
203+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
204+ with :
205+ pattern : csv-*
206+ merge-multiple : true
207+ path : raw-results
208+
209+ - uses : cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
210+ with :
211+ extra_nix_config : sandbox = true
212+
213+ - name : Benchmark results
214+ run : |
215+ nix-shell \
216+ -I nixpkgs=./tools/nix/pkgs.nix \
217+ --pure --keep LC_ALL --keep LANG \
218+ --arg loadJSBuiltinsDynamically false \
219+ --arg ccache 'null' \
220+ --arg icu 'null' \
221+ --arg sharedLibDeps '{}' \
222+ --arg devTools '[]' \
223+ --run '
224+ echo "Warning: do not take GHA benchmark results as face value, always confirm them"
225+ echo "using a dedicated machine, e.g. Jenkins CI."
226+ echo
227+ echo "Benchmark results:"
228+ echo
229+ echo '"'"'```'"'"'
230+ awk "FNR==1 && NR!=1{next;}{print}" raw-results/*.csv | Rscript benchmark/compare.R
231+ echo '"'"'```'"'"'
232+ echo
233+ echo "Warning: do not take GHA benchmark results as face value, always confirm them"
234+ echo "using a dedicated machine, e.g. Jenkins CI."
235+ ' | tee /dev/stderr >> "$GITHUB_STEP_SUMMARY"
0 commit comments