Skip to content

Commit 87e9c6e

Browse files
committed
ci-results: prototype
1 parent dfd609f commit 87e9c6e

File tree

5 files changed

+740
-5
lines changed

5 files changed

+740
-5
lines changed

bin/ncu-ci

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
const {
6+
PRBuild, BenchmarkRun, CommitBuild
7+
} = require('../components/jenkins');
8+
const { runPromise } = require('../lib/run');
9+
const Request = require('../lib/request');
10+
const CLI = require('../lib/cli');
11+
const yargs = require('yargs');
12+
13+
const argv = yargs
14+
.command({
15+
command: 'pr <jobid>',
16+
desc: 'Show results of a node-test-pull-request CI job',
17+
builder: (yargs) => {
18+
yargs
19+
.positional('jobid', {
20+
describe: 'id of the job',
21+
type: 'number'
22+
});
23+
},
24+
handler
25+
})
26+
.command({
27+
command: 'commit <jobid>',
28+
desc: 'Show results of a node-test-commit CI job',
29+
builder: (yargs) => {
30+
yargs
31+
.positional('jobid', {
32+
describe: 'id of the job',
33+
type: 'number'
34+
});
35+
},
36+
handler
37+
})
38+
.command({
39+
command: 'benchmark <jobid>',
40+
desc: 'Show results of a benchmark-node-micro-benchmarks CI job',
41+
builder: (yargs) => {
42+
yargs
43+
.positional('jobid', {
44+
describe: 'id of the job',
45+
type: 'number'
46+
});
47+
},
48+
handler
49+
})
50+
.demandCommand(1, 'must provide a valid command')
51+
.option('markdown', {
52+
alias: 'm',
53+
type: 'string',
54+
describe: 'file to output comments in markdown'
55+
})
56+
.argv;
57+
58+
async function main(command, argv) {
59+
const cli = new CLI();
60+
const request = new Request({});
61+
let build;
62+
const { jobid, markdown } = argv;
63+
switch(command) {
64+
case 'pr':
65+
build = new PRBuild(cli, request, jobid);
66+
await build.getResults();
67+
break;
68+
case 'commit':
69+
build = new CommitBuild(cli, request, jobid);
70+
await build.getResults();
71+
break;
72+
case 'benchmark':
73+
build = new BenchmarkRun(cli, request, jobid);
74+
await build.getResults();
75+
break;
76+
default:
77+
throw new Error('Unknown CI type!');
78+
}
79+
80+
build.display();
81+
82+
if (markdown) {
83+
build.writeToMarkdown(markdown);
84+
}
85+
}
86+
87+
function handler(argv) {
88+
const [ command ] = argv._;
89+
runPromise(main(command, argv));
90+
}

0 commit comments

Comments
 (0)