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
68109 core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || '');
69110 core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
70111
71- - name : Build Node.js and run tests
112+ - name : Build Node.js ${{ github.event_name == 'workflow_dispatch' && 'on the base commit' || ' and run tests' }}
72113 run : |
73114 nix-shell \
74115 -I nixpkgs=./tools/nix/pkgs.nix \
@@ -79,5 +120,102 @@ jobs:
79120 --arg devTools '[]' \
80121 --arg benchmarkTools '[]' \
81122 --run '
82- make run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
123+ 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"
83124 '
125+
126+ - name : Re-build Node.js on the merge commit
127+ # ccache is disabled here to avoid polluting the cache. Local build outputs should make this build relatively quick anyway.
128+ if : ${{ github.event_name == 'workflow_dispatch' }}
129+ run : |
130+ mv out/Release/node base_node
131+ git reset FETCH_HEAD --hard
132+ nix-shell \
133+ -I nixpkgs=./tools/nix/pkgs.nix \
134+ --pure \
135+ --arg loadJSBuiltinsDynamically false \
136+ --arg ccache 'null' \
137+ --arg devTools '[]' \
138+ --arg benchmarkTools '[]' \
139+ --run '
140+ make -j4 V=1
141+ '
142+
143+ - name : Run benchmark
144+ if : ${{ github.event_name == 'workflow_dispatch' }}
145+ run : |
146+ nix-shell \
147+ -I nixpkgs=./tools/nix/pkgs.nix \
148+ --pure --keep FILTER --keep LC_ALL --keep LANG \
149+ --arg loadJSBuiltinsDynamically false \
150+ --arg ccache 'null' \
151+ --arg icu 'null' \
152+ --arg sharedLibDeps '{}' \
153+ --arg devTools '[]' \
154+ --run '
155+ set -o pipefail
156+ ./base_node benchmark/compare.js \
157+ --filter "$FILTER" \
158+ --runs ${{ inputs.runs }} \
159+ --old ./base_node --new ./node \
160+ -- ${{ inputs.category }} \
161+ | tee /dev/stderr \
162+ > ${{ matrix.system }}.csv
163+ echo "Benchmark results:"
164+ echo
165+ echo '"'"'```'"'"'
166+ Rscript benchmark/compare.R < ${{ matrix.system }}.csv
167+ echo '"'"'```'"'"'
168+ ' | tee /dev/stderr >> "$GITHUB_STEP_SUMMARY"
169+ env :
170+ FILTER : ${{ inputs.filter }}
171+
172+ - name : Upload raw benchmark results
173+ if : ${{ github.event_name == 'workflow_dispatch' }}
174+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
175+ with :
176+ name : csv-${{ matrix.system }}
177+ path : ${{ matrix.system }}.csv
178+
179+ aggregate-benchmark-results :
180+ needs : build
181+ name : Aggregate benchmark results
182+ if : ${{ github.event_name == 'workflow_dispatch' }}
183+ runs-on : ubuntu-latest
184+ steps :
185+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
186+ with :
187+ persist-credentials : false
188+ sparse-checkout : |
189+ benchmark/*.R
190+ tools/nix/*.nix
191+ *.nix
192+ sparse-checkout-cone-mode : false
193+
194+ - name : Download benchmark raw results
195+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
196+ with :
197+ pattern : csv-*
198+ merge-multiple : true
199+ path : raw-results
200+
201+ - uses : cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1
202+ with :
203+ extra_nix_config : sandbox = true
204+
205+ - name : Benchmark results
206+ run : |
207+ nix-shell \
208+ -I nixpkgs=./tools/nix/pkgs.nix \
209+ --pure --keep LC_ALL --keep LANG \
210+ --arg loadJSBuiltinsDynamically false \
211+ --arg ccache 'null' \
212+ --arg icu 'null' \
213+ --arg sharedLibDeps '{}' \
214+ --arg devTools '[]' \
215+ --run '
216+ echo "Benchmark results:"
217+ echo
218+ echo '"'"'```'"'"'
219+ awk "FNR==1 && NR!=1{next;}{print}" raw-results/*.csv | Rscript benchmark/compare.R
220+ echo '"'"'```'"'"'
221+ ' | tee /dev/stderr >> "$GITHUB_STEP_SUMMARY"
0 commit comments