diff --git a/bin/ncu-ci.js b/bin/ncu-ci.js index 5bc2023f..a84b964b 100755 --- a/bin/ncu-ci.js +++ b/bin/ncu-ci.js @@ -113,11 +113,6 @@ const args = yargs(hideBin(process.argv)) describe: 'ID of the PR', type: 'number' }) - .positional('certify-safe', { - describe: 'If not provided, the command will reject PRs that have ' + - 'been pushed since the last review', - type: 'boolean' - }) .option('owner', { default: '', describe: 'GitHub repository owner' @@ -296,7 +291,7 @@ class RunPRJobCommand { this.cli.setExitCode(1); return; } - const jobRunner = new RunPRJob(cli, request, owner, repo, prid, this.argv.certifySafe); + const jobRunner = new RunPRJob(cli, request, owner, repo, prid); if (!(await jobRunner.start())) { this.cli.setExitCode(1); process.exitCode = 1; diff --git a/lib/ci/run_ci.js b/lib/ci/run_ci.js index d0572e7e..46891c21 100644 --- a/lib/ci/run_ci.js +++ b/lib/ci/run_ci.js @@ -7,7 +7,6 @@ import { } from './ci_type_parser.js'; import PRData from '../pr_data.js'; import { debuglog } from '../verbosity.js'; -import PRChecker from '../pr_checker.js'; export const CI_CRUMB_URL = `https://${CI_DOMAIN}/crumbIssuer/api/json`; const CI_PR_NAME = CI_TYPES.get(CI_TYPES_KEYS.PR).jobName; @@ -17,18 +16,13 @@ const CI_V8_NAME = CI_TYPES.get(CI_TYPES_KEYS.V8).jobName; export const CI_V8_URL = `https://${CI_DOMAIN}/job/${CI_V8_NAME}/build`; export class RunPRJob { - constructor(cli, request, owner, repo, prid, certifySafe) { + constructor(cli, request, owner, repo, prid) { this.cli = cli; this.request = request; this.owner = owner; this.repo = repo; this.prid = prid; this.prData = new PRData({ prid, owner, repo }, cli, request); - this.certifySafe = - certifySafe || - Promise.all([this.prData.getReviews(), this.prData.getPR()]).then(() => - new PRChecker(cli, this.prData, request, {}).checkCommitsAfterReview() - ); } async getCrumb() { @@ -68,13 +62,7 @@ export class RunPRJob { } async start() { - const { cli, certifySafe } = this; - - if (!(await certifySafe)) { - cli.error('Refusing to run CI on potentially unsafe PR'); - return false; - } - + const { cli } = this; cli.startSpinner('Validating Jenkins credentials'); const crumb = await this.getCrumb(); diff --git a/lib/pr_checker.js b/lib/pr_checker.js index 37cdbd51..f4e2b0f7 100644 --- a/lib/pr_checker.js +++ b/lib/pr_checker.js @@ -534,7 +534,6 @@ export default class PRChecker { ); if (reviewIndex === -1) { - cli.warn('No approving reviews found'); return false; } diff --git a/test/unit/ci_start.test.js b/test/unit/ci_start.test.js index 0d2d8d13..4c8eea9f 100644 --- a/test/unit/ci_start.test.js +++ b/test/unit/ci_start.test.js @@ -1,4 +1,4 @@ -import { describe, it, before, afterEach } from 'node:test'; +import { describe, it, before } from 'node:test'; import assert from 'assert'; import sinon from 'sinon'; @@ -9,7 +9,6 @@ import { CI_CRUMB_URL, CI_PR_URL } from '../../lib/ci/run_ci.js'; -import PRChecker from '../../lib/pr_checker.js'; import TestCLI from '../fixtures/test_cli.js'; @@ -52,7 +51,7 @@ describe('Jenkins', () => { .returns(Promise.resolve({ crumb })) }; - const jobRunner = new RunPRJob(cli, request, owner, repo, prid, true); + const jobRunner = new RunPRJob(cli, request, owner, repo, prid); assert.strictEqual(await jobRunner.start(), false); }); @@ -62,7 +61,7 @@ describe('Jenkins', () => { json: sinon.stub().throws() }; - const jobRunner = new RunPRJob(cli, request, owner, repo, prid, true); + const jobRunner = new RunPRJob(cli, request, owner, repo, prid); assert.strictEqual(await jobRunner.start(), false); }); @@ -90,7 +89,7 @@ describe('Jenkins', () => { json: sinon.stub().withArgs(CI_CRUMB_URL) .returns(Promise.resolve({ crumb })) }; - const jobRunner = new RunPRJob(cli, request, owner, repo, prid, true); + const jobRunner = new RunPRJob(cli, request, owner, repo, prid); assert.ok(await jobRunner.start()); }); @@ -109,48 +108,7 @@ describe('Jenkins', () => { json: sinon.stub().withArgs(CI_CRUMB_URL) .returns(Promise.resolve({ crumb })) }; - const jobRunner = new RunPRJob(cli, request, owner, repo, prid, true); + const jobRunner = new RunPRJob(cli, request, owner, repo, prid); assert.strictEqual(await jobRunner.start(), false); }); - - describe('without --certify-safe flag', { concurrency: false }, () => { - afterEach(() => { - sinon.restore(); - }); - for (const certifySafe of [true, false]) { - it(`should return ${certifySafe} if PR checker reports it as ${ - certifySafe ? '' : 'potentially un' - }safe`, async() => { - const cli = new TestCLI(); - - sinon.replace(PRChecker.prototype, 'checkCommitsAfterReview', - sinon.fake.returns(Promise.resolve(certifySafe))); - - const request = { - gql: sinon.stub().returns({ - repository: { - pullRequest: { - labels: { - nodes: [] - } - } - } - }), - 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 }); - }), - json: sinon.stub().withArgs(CI_CRUMB_URL) - .returns(Promise.resolve({ crumb })) - }; - - const jobRunner = new RunPRJob(cli, request, owner, repo, prid, false); - assert.strictEqual(await jobRunner.start(), certifySafe); - }); - } - }); }); diff --git a/test/unit/pr_checker.test.js b/test/unit/pr_checker.test.js index 3e10a71c..a86a837d 100644 --- a/test/unit/pr_checker.test.js +++ b/test/unit/pr_checker.test.js @@ -2179,9 +2179,7 @@ describe('PRChecker', () => { it('should skip the check if there are no reviews', () => { const { commits } = multipleCommitsAfterReview; - const expectedLogs = { - warn: [['No approving reviews found']] - }; + const expectedLogs = {}; const data = { pr: firstTimerPR,