-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92c3e9d
commit 7996277
Showing
17 changed files
with
33,272 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const { | ||
PRBuild, BenchmarkRun, CommitBuild, jobCache | ||
} = require('../components/jenkins'); | ||
const { runPromise } = require('../lib/run'); | ||
const Request = require('../lib/request'); | ||
const CLI = require('../lib/cli'); | ||
const yargs = require('yargs'); | ||
|
||
// This is used for testing | ||
// Default cache dir is ${ncu-source-dir}/.ncu/cache | ||
jobCache.enable(); | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const argv = yargs | ||
.command({ | ||
command: 'pr <jobid>', | ||
desc: 'Show results of a node-test-pull-request CI job', | ||
builder: (yargs) => { | ||
yargs | ||
.positional('jobid', { | ||
describe: 'id of the job', | ||
type: 'number' | ||
}); | ||
}, | ||
handler | ||
}) | ||
.command({ | ||
command: 'commit <jobid>', | ||
desc: 'Show results of a node-test-commit CI job', | ||
builder: (yargs) => { | ||
yargs | ||
.positional('jobid', { | ||
describe: 'id of the job', | ||
type: 'number' | ||
}); | ||
}, | ||
handler | ||
}) | ||
.command({ | ||
command: 'benchmark <jobid>', | ||
desc: 'Show results of a benchmark-node-micro-benchmarks CI job', | ||
builder: (yargs) => { | ||
yargs | ||
.positional('jobid', { | ||
describe: 'id of the job', | ||
type: 'number' | ||
}); | ||
}, | ||
handler | ||
}) | ||
.demandCommand(1, 'must provide a valid command') | ||
.option('markdown', { | ||
alias: 'm', | ||
type: 'string', | ||
describe: 'file to write results in markdown' | ||
}) | ||
.help() | ||
.argv; | ||
|
||
async function main(command, argv) { | ||
const cli = new CLI(); | ||
const request = new Request({}); | ||
let build; | ||
const { jobid, markdown } = argv; | ||
switch (command) { | ||
case 'pr': | ||
build = new PRBuild(cli, request, jobid); | ||
await build.getResults(); | ||
break; | ||
case 'commit': | ||
build = new CommitBuild(cli, request, jobid); | ||
await build.getResults(); | ||
break; | ||
case 'benchmark': | ||
build = new BenchmarkRun(cli, request, jobid); | ||
await build.getResults(); | ||
break; | ||
default: | ||
throw new Error('Unknown CI type!'); | ||
} | ||
|
||
build.display(); | ||
|
||
if (markdown) { | ||
build.writeToMarkdown(markdown); | ||
} | ||
} | ||
|
||
function handler(argv) { | ||
const [ command ] = argv._; | ||
runPromise(main(command, argv)); | ||
} |
Oops, something went wrong.