Skip to content

fix(ncu-ci): pass COMMIT_SHA_CHECK to V8 CI #928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ci/run_ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
65 changes: 55 additions & 10 deletions test/unit/ci_start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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: '<pr base branch>',
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: '<pr base branch>',
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];
Expand Down Expand Up @@ -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();

Expand Down
Loading