Skip to content

Commit e8da1fd

Browse files
committed
fixup! fixup! ncu-ci: initial implementation
1 parent b8f43bd commit e8da1fd

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

bin/ncu-ci

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
'use strict';
44

55
const {
6-
PRBuild, BenchmarkRun, CommitBuild, jobCache
6+
PRBuild, BenchmarkRun, CommitBuild, jobCache, parseJobFromURL
77
} = require('../components/jenkins');
88
const { runPromise } = require('../lib/run');
99
const Request = require('../lib/request');
1010
const CLI = require('../lib/cli');
11+
const { parsePRFromURL } = require('../lib/links');
1112
const yargs = require('yargs');
1213

1314
// This is used for testing
@@ -73,10 +74,10 @@ const argv = yargs
7374
.help()
7475
.argv;
7576

76-
async function getResults(cli, request, command, argv) {
77+
async function getResults(cli, request, job) {
7778
let build;
78-
const { jobid, markdown } = argv;
79-
switch (command) {
79+
const { type, jobid, markdown } = job;
80+
switch (type) {
8081
case 'pr':
8182
build = new PRBuild(cli, request, jobid);
8283
await build.getResults();
@@ -107,9 +108,30 @@ async function main(command, argv) {
107108
const queue = [];
108109

109110
if (command === 'url') {
110-
111+
let parsed = parseJobFromURL(argv.url);
112+
if (parsed) {
113+
queue.push({
114+
type: parsed.command,
115+
jobid: parsed.jobid,
116+
markdown: argv.markdown
117+
});
118+
} else {
119+
parsed = parsePRFromURL(argv.url);
120+
if (parsed) {
121+
// Get OP and comments from the PR
122+
// const ciMap = new JobParser(thread).parse();
123+
}
124+
}
125+
} else {
126+
queue.push({
127+
type: command,
128+
argv: argv
129+
});
111130
}
112131

132+
for (let job of queue) {
133+
await getResults(cli, request, job);
134+
}
113135
}
114136

115137
function handler(argv) {

components/jenkins.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const qs = require('querystring');
55
const chalk = require('chalk');
66
const { appendFile } = require('../lib/file');
77

8-
const DOMAIN = 'ci.nodejs.org';
8+
const CI_DOMAIN = 'ci.nodejs.org';
99

1010
const SUCCESS = 'SUCCESS';
1111
const FAILURE = 'FAILURE';
@@ -33,11 +33,11 @@ const BUILD_TREE = 'result,runs[url,number,result]';
3333
const LINTER_TREE = 'result,url,number';
3434

3535
function getPath(url) {
36-
return url.replace(`https://${DOMAIN}/`, '').replace('api/json', '');
36+
return url.replace(`https://${CI_DOMAIN}/`, '').replace('api/json', '');
3737
}
3838

3939
function getUrl(path) {
40-
return `https://${DOMAIN}/${getPath(path)}`;
40+
return `https://${CI_DOMAIN}/${getPath(path)}`;
4141
}
4242

4343
function resultName(result) {
@@ -87,7 +87,7 @@ class Job {
8787

8888
get jobUrl() {
8989
const { path } = this;
90-
return `https://${DOMAIN}/${path}`;
90+
return `https://${CI_DOMAIN}/${path}`;
9191
}
9292

9393
get apiUrl() {
@@ -98,12 +98,12 @@ class Job {
9898

9999
get consoleUrl() {
100100
const { path } = this;
101-
return `https://${DOMAIN}/${path}consoleText`;
101+
return `https://${CI_DOMAIN}/${path}consoleText`;
102102
}
103103

104104
get consoleUIUrl() {
105105
const { path } = this;
106-
return `https://${DOMAIN}/${path}console`;
106+
return `https://${CI_DOMAIN}/${path}console`;
107107
}
108108

109109
async getBuildData() {
@@ -526,6 +526,10 @@ const FAILURE_PATTERNS = [{
526526
pattern: /FATAL: .+/g,
527527
filter: pickReason(-1, 0, 5),
528528
name: 'build failure'
529+
}, {
530+
pattern: /error: .+/g,
531+
filter: pickReason(-1, 0, 5),
532+
name: 'build failure'
529533
}, {
530534
pattern: /make.*: write error/mg,
531535
filter: pickReason(0, 0, 3),

0 commit comments

Comments
 (0)