From 44806a2598d44dd0876a9c092bfed026fdef83d6 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 9 May 2025 03:36:10 +0100 Subject: [PATCH 1/2] fix(ncu-ci): pass `COMMIT_SHA_CHECK` to V8 CI Similar to `node-test-pull-request`, `node-test-commit-v8-linux` also now requires `COMMIT_SHA_CHECK` to be passed to it. Refs: https://github.com/nodejs/node-core-utils/pull/911 --- lib/ci/run_ci.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ci/run_ci.js b/lib/ci/run_ci.js index 1561030b..d894cbb9 100644 --- a/lib/ci/run_ci.js +++ b/lib/ci/run_ci.js @@ -62,7 +62,8 @@ export class RunPRJob { parameter: [ { name: 'GITHUB_ORG', value: this.owner }, { name: 'REPO_NAME', value: this.repo }, - { name: 'GIT_REMOTE_REF', value: `refs/pull/${this.prid}/head` } + { name: 'GIT_REMOTE_REF', value: `refs/pull/${this.prid}/head` }, + { name: 'COMMIT_SHA_CHECK', value: this.certifySafe } ] })); return payload; From 031133c1e91ce69d259f25fc84acc3a82d032e37 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 9 May 2025 16:27:04 +0100 Subject: [PATCH 2/2] fixup! fix(ncu-ci): pass `COMMIT_SHA_CHECK` to V8 CI --- test/unit/ci_start.test.js | 65 ++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a/test/unit/ci_start.test.js b/test/unit/ci_start.test.js index c56e5308..154356e4 100644 --- a/test/unit/ci_start.test.js +++ b/test/unit/ci_start.test.js @@ -8,7 +8,8 @@ import { FormData } from 'undici'; import { RunPRJob, CI_CRUMB_URL, - CI_PR_URL + CI_PR_URL, + CI_V8_URL } from '../../lib/ci/run_ci.js'; import PRChecker from '../../lib/pr_checker.js'; @@ -24,15 +25,25 @@ describe('Jenkins', () => { sinon.stub(FormData.prototype, 'append').callsFake(function(key, value) { assert.strictEqual(key, 'json'); const { parameter } = JSON.parse(value); - const expectedParameters = { - CERTIFY_SAFE: 'on', - COMMIT_SHA_CHECK: 'deadbeef', - TARGET_GITHUB_ORG: owner, - TARGET_REPO_NAME: repo, - PR_ID: prid, - REBASE_ONTO: '', - DESCRIPTION_SETTER_DESCRIPTION: '' - }; + // Expected parameters are different for node-test-pull-request and + // node-test-commit-v8-linux, but we don't know which this FormData + // is for, so we make a guess. + const expectedParameters = parameter.some(({ name, _ }) => name === 'PR_ID') + ? { + CERTIFY_SAFE: 'on', + COMMIT_SHA_CHECK: 'deadbeef', + TARGET_GITHUB_ORG: owner, + TARGET_REPO_NAME: repo, + PR_ID: prid, + REBASE_ONTO: '', + DESCRIPTION_SETTER_DESCRIPTION: '' + } + : { + GITHUB_ORG: owner, + REPO_NAME: repo, + GIT_REMOTE_REF: `refs/pull/${prid}/head`, + COMMIT_SHA_CHECK: 'deadbeef' + }; for (const { name, value } of parameter) { assert.strictEqual(value, expectedParameters[name]); delete expectedParameters[name]; @@ -96,6 +107,40 @@ describe('Jenkins', () => { assert.ok(await jobRunner.start()); }); + it('should start node-test-commit-v8-linux', async() => { + const cli = new TestCLI(); + + const request = { + gql: sinon.stub().returns({ + repository: { + pullRequest: { + labels: { + nodes: [{ name: 'v8 engine' }] + } + } + } + }), + fetch: sinon.stub() + .callsFake((url, { method, headers, body }) => { + assert.strictEqual(url, CI_PR_URL); + assert.strictEqual(method, 'POST'); + assert.deepStrictEqual(headers, { 'Jenkins-Crumb': crumb }); + assert.ok(body._validated); + return Promise.resolve({ status: 201 }); + }).onSecondCall().callsFake((url, { method, headers, body }) => { + assert.strictEqual(url, CI_V8_URL); + assert.strictEqual(method, 'POST'); + assert.deepStrictEqual(headers, { 'Jenkins-Crumb': crumb }); + assert.ok(body._validated); + return Promise.resolve({ status: 201 }); + }), + json: sinon.stub().withArgs(CI_CRUMB_URL) + .returns(Promise.resolve({ crumb })) + }; + const jobRunner = new RunPRJob(cli, request, owner, repo, prid, 'deadbeef'); + assert.ok(await jobRunner.start()); + }); + it('should return false if node-pull-request not started', async() => { const cli = new TestCLI();