Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nodejs/node-core-utils
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.1
Choose a base ref
...
head repository: nodejs/node-core-utils
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.1.0
Choose a head ref
  • 5 commits
  • 9 files changed
  • 5 contributors

Commits on Oct 7, 2022

  1. feat: add --since option to ncu-ci (#649)

    * feat: add --since option to ncu-ci
    
    Co-authored-by: Michaël Zasso <[email protected]>
    joyeecheung and targos authored Oct 7, 2022
    Copy the full SHA
    e01ca12 View commit details

Commits on Oct 9, 2022

  1. Copy the full SHA
    c4ab7f5 View commit details

Commits on Oct 12, 2022

  1. fix: only parse commit messages during git node backport analysis (#651)

    Previously we parse the entire commit, including the diff, which
    can result in ENOBUFS errors. Adding `-s` option to the `git show`
    command would eliminate the commit body in the output, which
    we don't need, so the error can be less likely to happen during
    commit message analysis.
    joyeecheung authored Oct 12, 2022
    Copy the full SHA
    4e59a64 View commit details

Commits on Oct 22, 2022

  1. feat: add auto run v8 ci

    gengjiawen authored and Trott committed Oct 22, 2022
    Copy the full SHA
    046bc0d View commit details
  2. chore(main): release 2.1.0 (#650)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored Oct 22, 2022
    Copy the full SHA
    04d513d View commit details
Showing with 96 additions and 9 deletions.
  1. +1 −0 .npmrc
  2. +13 −0 CHANGELOG.md
  3. +22 −1 bin/ncu-ci.js
  4. +3 −3 docs/git-node.md
  5. +1 −1 lib/backport_session.js
  6. +6 −3 lib/ci/ci_utils.js
  7. +40 −0 lib/ci/run_ci.js
  8. +1 −1 package.json
  9. +9 −0 test/unit/ci_start.test.js
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package-lock=false
auto-install-peers=true
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [2.1.0](https://github.com/nodejs/node-core-utils/compare/v2.0.1...v2.1.0) (2022-10-22)


### Features

* add --since option to ncu-ci ([#649](https://github.com/nodejs/node-core-utils/issues/649)) ([e01ca12](https://github.com/nodejs/node-core-utils/commit/e01ca12368677e1f8f72f97c4170b386cb250fb8))
* add auto run v8 ci ([046bc0d](https://github.com/nodejs/node-core-utils/commit/046bc0dbea44dafdb42f92bc1006d7cdd7a5f286))


### Bug Fixes

* only parse commit messages during git node backport analysis ([#651](https://github.com/nodejs/node-core-utils/issues/651)) ([4e59a64](https://github.com/nodejs/node-core-utils/commit/4e59a647a1ffd87b79ad953936d20de495505bd0))

## [2.0.1](https://github.com/nodejs/node-core-utils/compare/v2.0.0...v2.0.1) (2022-07-31)


23 changes: 22 additions & 1 deletion bin/ncu-ci.js
Original file line number Diff line number Diff line change
@@ -86,6 +86,19 @@ const args = yargs(hideBin(process.argv))
.option('limit', {
default: 99,
describe: 'Maximum number of CIs to get data from'
})
.option('since <date>', {
type: 'string',
describe: 'Time since when the CI results should be queried'
}).check(argv => {
try {
// eslint-disable-next-line no-new
new Date(argv.since);
} catch {
throw new Error('--since <date> should be string that can ' +
'be parsed by new Date()');
}
return true;
});
},
handler
@@ -421,7 +434,12 @@ class WalkCommand extends CICommand {

async initialize() {
const ciType = commandToType[this.argv.type];
const builds = await listBuilds(this.cli, this.request, ciType);
const since = this.argv.since ? new Date(this.argv.since) : undefined;
const builds = await listBuilds(this.cli, this.request, ciType, since);
if (builds.count === 0) {
this.cli.log('No applicable builds found.');
return;
}
this.queue.push({ type: 'health', ciType, builds });
for (const build of builds.failed.slice(0, this.argv.limit)) {
this.queue.push(build);
@@ -430,6 +448,9 @@ class WalkCommand extends CICommand {

async aggregate() {
const { argv, cli } = this;
if (this.queue.length === 0) {
return;
}
const aggregator = new FailureAggregator(cli, this.json);
this.json = aggregator.aggregate();
cli.log('');
6 changes: 3 additions & 3 deletions docs/git-node.md
Original file line number Diff line number Diff line change
@@ -166,8 +166,8 @@ Options:

### Optional Settings

The same Settings used by
[`git node metadata`](#git-node-metadata-optional-settings) are also used by
The same Settings used by
[`git node metadata`](#git-node-metadata-optional-settings) are also used by
`git node land`.

## `git node backport`
@@ -334,7 +334,7 @@ $ brew install gpatch

And make sure `which patch` points to `/usr/local/bin/patch` installed by
homebrew instead of `/usr/bin/patch` that comes with the system (e.g. by
modifying yoru `PATH` environment variable).
modifying your `PATH` environment variable).

### `git node v8 major`

2 changes: 1 addition & 1 deletion lib/backport_session.js
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ export default class BackportSession extends Session {

getCommitMessage(rev) {
return runSync('git',
['show', '--format=%B', rev]
['show', '--format=%B', '-s', rev]
).trim();
}

9 changes: 6 additions & 3 deletions lib/ci/ci_utils.js
Original file line number Diff line number Diff line change
@@ -50,16 +50,19 @@ function filterBuild(builds, type) {
.map(build => parseJobFromURL(build.url));
}

export async function listBuilds(cli, request, type) {
export async function listBuilds(cli, request, type, since) {
// assert(type === COMMIT || type === PR)
const { jobName } = CI_TYPES.get(type);
const tree = 'builds[url,result]';
const tree = 'builds[url,result,timestamp]';
const url = `https://${CI_DOMAIN}/job/${jobName}/api/json?tree=${qs.escape(tree)}`;

cli.startSpinner(`Querying ${url}`);

const result = await request.json(url);
const builds = result.builds;
let builds = result.builds;
if (since) {
builds = builds.filter(build => build.timestamp > since);
}
const failed = filterBuild(builds, statusType.FAILURE);
const aborted = filterBuild(builds, statusType.ABORTED);
const pending = filterBuild(builds, null);
40 changes: 40 additions & 0 deletions lib/ci/run_ci.js
Original file line number Diff line number Diff line change
@@ -5,18 +5,24 @@ import {
CI_TYPES,
CI_TYPES_KEYS
} from './ci_type_parser.js';
import PRData from '../pr_data.js';
import { debuglog } from '../verbosity.js';

export const CI_CRUMB_URL = `https://${CI_DOMAIN}/crumbIssuer/api/json`;
const CI_PR_NAME = CI_TYPES.get(CI_TYPES_KEYS.PR).jobName;
export const CI_PR_URL = `https://${CI_DOMAIN}/job/${CI_PR_NAME}/build`;

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) {
this.cli = cli;
this.request = request;
this.owner = owner;
this.repo = repo;
this.prid = prid;
this.prData = new PRData({ prid, owner, repo }, cli, request);
}

async getCrumb() {
@@ -43,6 +49,18 @@ export class RunPRJob {
return payload;
}

get v8Payload() {
const payload = new FormData();
payload.append('json', JSON.stringify({
parameter: [
{ name: 'GITHUB_ORG', value: this.owner },
{ name: 'REPO_NAME', value: this.repo },
{ name: 'GIT_REMOTE_REF', value: `refs/pull/${this.prid}/head` }
]
}));
return payload;
}

async start() {
const { cli } = this;
cli.startSpinner('Validating Jenkins credentials');
@@ -71,7 +89,29 @@ export class RunPRJob {
return false;
}
cli.stopSpinner('PR CI job successfully started');

// check if the job need a v8 build and trigger it
await this.prData.getPR();
const labels = this.prData.pr.labels;
if (labels.nodes.map(i => i.name).includes('v8 engine')) {
cli.startSpinner('Starting V8 CI job');
const response = await this.request.fetch(CI_V8_URL, {
method: 'POST',
headers: {
'Jenkins-Crumb': crumb
},
body: this.v8Payload
});
if (response.status !== 201) {
cli.stopSpinner(
`Failed to start V8 CI: ${response.status} ${response.statusText}`,
this.cli.SPINNER_STATUS.FAILED);
return false;
}
cli.stopSpinner('V8 CI job successfully started');
}
} catch (err) {
debuglog(err);
cli.stopSpinner('Failed to start CI', this.cli.SPINNER_STATUS.FAILED);
return false;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-core-utils",
"version": "2.0.1",
"version": "2.1.0",
"description": "Utilities for Node.js core collaborators",
"type": "module",
"bin": {
9 changes: 9 additions & 0 deletions test/unit/ci_start.test.js
Original file line number Diff line number Diff line change
@@ -67,6 +67,15 @@ describe('Jenkins', () => {
const cli = new TestCLI();

const request = {
gql: sinon.stub().returns({
repository: {
pullRequest: {
labels: {
nodes: []
}
}
}
}),
fetch: sinon.stub()
.callsFake((url, { method, headers, body }) => {
assert.strictEqual(url, CI_PR_URL);