Skip to content

Commit

Permalink
fixup! fixup! fixup! ncu-ci: initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Apr 22, 2018
1 parent e8da1fd commit 976bef4
Show file tree
Hide file tree
Showing 5 changed files with 733 additions and 735 deletions.
57 changes: 31 additions & 26 deletions bin/ncu-ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
'use strict';

const {
PRBuild, BenchmarkRun, CommitBuild, jobCache, parseJobFromURL
} = require('../components/jenkins');
PRBuild, BenchmarkRun, CommitBuild, jobCache, parseJobFromURL, constants
} = require('../lib/ci');

const {
PR, COMMIT, BENCHMARK
} = constants;

const { runPromise } = require('../lib/run');
const Request = require('../lib/request');
const CLI = require('../lib/cli');
const { parsePRFromURL } = require('../lib/links');
const yargs = require('yargs');

// This is used for testing
Expand Down Expand Up @@ -77,21 +81,18 @@ const argv = yargs
async function getResults(cli, request, job) {
let build;
const { type, jobid, markdown } = job;
switch (type) {
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!');
if (type === PR) {
build = new PRBuild(cli, request, jobid);
await build.getResults();
} else if (type === COMMIT) {
build = new CommitBuild(cli, request, jobid);
await build.getResults();
} else if (type === BENCHMARK) {
build = new BenchmarkRun(cli, request, jobid);
await build.getResults();
} else {
yargs.showHelp();
return;
}

build.display();
Expand All @@ -107,25 +108,29 @@ async function main(command, argv) {
const request = new Request({});
const queue = [];

const commandToType = {
'commit': COMMIT,
'pr': PR,
'benchmark': BENCHMARK
};

if (command === 'url') {
let parsed = parseJobFromURL(argv.url);
if (parsed) {
queue.push({
type: parsed.command,
type: parsed.type,
jobid: parsed.jobid,
markdown: argv.markdown
});
} else {
parsed = parsePRFromURL(argv.url);
if (parsed) {
// Get OP and comments from the PR
// const ciMap = new JobParser(thread).parse();
}
// TODO: parse CI links from PR thread
return yargs.showHelp();
}
} else {
queue.push({
type: command,
argv: argv
type: commandToType[command],
jobid: argv.jobid,
markdown: argv.markdown
});
}

Expand Down
Loading

0 comments on commit 976bef4

Please sign in to comment.