diff --git a/bin/ncu-ci b/bin/ncu-ci index b72c9545..1007ed48 100755 --- a/bin/ncu-ci +++ b/bin/ncu-ci @@ -6,7 +6,12 @@ const { JobParser, parseJobFromURL, CI_TYPES_KEYS: { - PR, COMMIT, BENCHMARK, CITGM, DAILY_MASTER + PR, + COMMIT, + BENCHMARK, + CITGM, + CITGM_NOBUILD, + DAILY_MASTER } } = require('../lib/ci/ci_type_parser'); @@ -164,6 +169,10 @@ const argv = yargs default: false, describe: 'Write the results as markdown to clipboard' }) + .option('nobuild', { + describe: 'If running cigtm, whether or not the CITGM job is citgm-nobuild', + type: 'boolean' + }) .option('json ', { type: 'string', describe: 'Write the results as json to ' @@ -231,7 +240,8 @@ class CICommand { build = new CommitBuild(cli, request, job.jobid); break; case CITGM: - build = new CITGMBuild(cli, request, job.jobid); + case CITGM_NOBUILD: + build = new CITGMBuild(cli, request, job); break; case BENCHMARK: build = new BenchmarkRun(cli, request, job.jobid); @@ -353,7 +363,8 @@ class JobCommand extends CICommand { async initialize() { this.queue.push({ type: commandToType[this.command], - jobid: this.argv.jobid + jobid: this.argv.jobid, + noBuild: this.argv.nobuild || false }); } } diff --git a/docs/ncu-ci.md b/docs/ncu-ci.md index 62673832..7113d858 100644 --- a/docs/ncu-ci.md +++ b/docs/ncu-ci.md @@ -27,6 +27,8 @@ Commands: Options: --version Show version number [boolean] --copy Write the results as markdown to clipboard [default: false] + --nobuild If running cigtm, whether or not the CITGM job is + citgm-nobuild [boolean] --json Write the results as json to [string] --markdown Write the results as markdown to [string] --help Show help [boolean] diff --git a/lib/ci/ci_result_parser.js b/lib/ci/ci_result_parser.js index 345f4809..3ac57007 100644 --- a/lib/ci/ci_result_parser.js +++ b/lib/ci/ci_result_parser.js @@ -760,18 +760,21 @@ class PRBuild extends TestBuild { } class CITGMBuild extends TestBuild { - constructor(cli, request, id) { - const path = `job/citgm-smoker/${id}/`; + constructor(cli, request, job) { + const { jobid, noBuild } = job; + const path = noBuild + ? `job/citgm-smoker-nobuild/${jobid}/` + : `job/citgm-smoker/${jobid}/`; + const tree = CITGM_MAIN_TREE; super(cli, request, path, tree); - this.id = id; + this.id = jobid; + this.noBuild = noBuild; } async getResults() { - const { id } = this; - let headerData; try { headerData = await this.getBuildData('Summary'); @@ -789,7 +792,7 @@ class CITGMBuild extends TestBuild { // they do summary data, so we need to update the endpoint // and issue a second API call in order to fetch result data. this.tree = CITGM_REPORT_TREE; - this.path = `job/citgm-smoker/${this.id}/testReport/`; + this.updatePath(true); let resultData; try { @@ -804,7 +807,7 @@ class CITGMBuild extends TestBuild { this.results = this.parseResults(resultData); // Update id again so that it correctly displays in Summary output. - this.path = `job/citgm-smoker/${id}/`; + this.updatePath(false); return { result }; } @@ -833,6 +836,19 @@ class CITGMBuild extends TestBuild { return results; } + updatePath(testReport) { + const { id, noBuild } = this; + if (testReport) { + this.path = noBuild + ? `job/citgm-smoker-nobuild/${id}/testReport/` + : `job/citgm-smoker/${id}/testReport/`; + } else { + this.path = noBuild + ? `job/citgm-smoker-nobuild/${id}/` + : `job/citgm-smoker/${id}/`; + } + } + displayBuilds() { const { cli, results } = this; const { failed, skipped, passed, total } = results.statistics; @@ -894,7 +910,8 @@ class CITGMBuild extends TestBuild { output += `### [${failure}](${data.url})\n\n`; const failures = data.modules.map(f => `* ${f.name}`); - output += `${failures.join('\n')}\n\n`; + const items = failures.length > 0 ? `${failures.join('\n')}` : 'None.'; + output += `${items}\n\n`; } return output; } diff --git a/lib/ci/ci_type_parser.js b/lib/ci/ci_type_parser.js index 517c21d7..b00c7a01 100644 --- a/lib/ci/ci_type_parser.js +++ b/lib/ci/ci_type_parser.js @@ -9,6 +9,7 @@ const CI_DOMAIN = 'ci.nodejs.org'; // constants const CITGM = 'CITGM'; +const CITGM_NOBUILD = 'CITGM_NOBUILD'; const PR = 'PR'; const COMMIT = 'COMMIT'; const BENCHMARK = 'BENCHMARK'; @@ -41,6 +42,12 @@ const CI_TYPES = new Map([ pattern: /job\/citgm-smoker\/(\d+)/, type: JOB_CI }], + [CITGM_NOBUILD, { + name: 'CITGM', + jobName: 'citgm-smoker-nobuild', + pattern: /job\/citgm-smoker-nobuild\/(\d+)/, + type: JOB_CI | LITE_CI + }], [PR, { name: 'Full PR', jobName: 'node-test-pull-request', @@ -218,8 +225,18 @@ module.exports = { CI_DOMAIN, CI_TYPES, CI_TYPES_KEYS: { - CITGM, PR, COMMIT, BENCHMARK, LIBUV, V8, NOINTL, - LINTER, LITE_PR, LITE_COMMIT, DAILY_MASTER + CITGM, + CITGM_NOBUILD, + PR, + COMMIT, + BENCHMARK, + LIBUV, + V8, + NOINTL, + LINTER, + LITE_PR, + LITE_COMMIT, + DAILY_MASTER }, CI_PROVIDERS, isFullCI, diff --git a/test/fixtures/jenkins/citgm-nobuild/citgm-smoker-nobuild-866-testReport.json b/test/fixtures/jenkins/citgm-nobuild/citgm-smoker-nobuild-866-testReport.json new file mode 100644 index 00000000..aa1d7ce7 --- /dev/null +++ b/test/fixtures/jenkins/citgm-nobuild/citgm-smoker-nobuild-866-testReport.json @@ -0,0 +1,236 @@ +{ + "_class":"hudson.tasks.test.MatrixTestResult", + "failCount":3, + "skipCount":0, + "totalCount":12, + "childReports":[ + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1015/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=win2016-vs2017/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"FAILED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=fedora-last-latest-x64/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=debian9-64/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1804-64/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=rhel7-s390x/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=aix71-ppc64/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"FAILED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1014/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=win10-vs2019/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"FAILED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=fedora-latest-x64/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=centos7-ppcle/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + }, + { + "child":{ + "_class":"hudson.matrix.MatrixRun", + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1604-64/866/" + }, + "result":{ + "_class":"hudson.tasks.junit.TestResult", + "suites":[ + { + "cases":[ + { + "name":"through2-v4.0.2", + "status":"PASSED" + } + ] + } + ] + } + } + ] +} \ No newline at end of file diff --git a/test/fixtures/jenkins/citgm-nobuild/citgm-smoker-nobuild-866.json b/test/fixtures/jenkins/citgm-nobuild/citgm-smoker-nobuild-866.json new file mode 100644 index 00000000..e0c07461 --- /dev/null +++ b/test/fixtures/jenkins/citgm-nobuild/citgm-smoker-nobuild-866.json @@ -0,0 +1,185 @@ +{ + "_class":"hudson.matrix.MatrixBuild", + "actions":[ + { + "_class":"hudson.model.CauseAction", + "causes":[ + { + "_class":"hudson.model.Cause$UpstreamCause", + "shortDescription":"Started by upstream project \"citgm-smoker-pipeline\" build number 119", + "upstreamBuild":119, + "upstreamProject":"citgm-smoker-pipeline", + "upstreamUrl":"job/citgm-smoker-pipeline/" + } + ] + }, + { + + }, + { + "_class":"hudson.model.ParametersAction", + "parameters":[ + { + "_class":"hudson.model.StringParameterValue", + "name":"CITGM_LOGLEVEL", + "value":"verbose" + }, + { + "_class":"hudson.model.StringParameterValue", + "name":"DOWNLOAD_LOCATION", + "value":"release" + }, + { + "_class":"hudson.plugins.matrix_configuration_parameter.DefaultMatrixCombinationsParameterValue", + "name":"MACHINES" + }, + { + "_class":"hudson.model.StringParameterValue", + "name":"CITGM_COMMAND", + "value":"citgm through2" + }, + { + "_class":"hudson.model.StringParameterValue", + "name":"NPM_LOGLEVEL", + "value":"error" + }, + { + "_class":"hudson.model.StringParameterValue", + "name":"CITGM", + "value":"richardlau/citgm#through2" + }, + { + "_class":"hudson.model.StringParameterValue", + "name":"NODE_VERSION", + "value":"v14" + } + ] + }, + { + + }, + { + + }, + { + + }, + { + + }, + { + + }, + { + "_class":"hudson.tasks.test.MatrixTestResult", + "failCount":3, + "skipCount":0, + "totalCount":12, + "urlName":"testReport" + }, + { + + }, + { + + }, + { + + }, + { + + }, + { + + }, + { + + } + ], + "artifacts":[ + + ], + "building":false, + "description":null, + "displayName":"#866", + "duration":304970, + "estimatedDuration":3455013, + "executor":null, + "fullDisplayName":"citgm-smoker-nobuild #866", + "id":"866", + "keepLog":false, + "number":866, + "queueId":818578, + "result":"FAILURE", + "timestamp":1593612323547, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/866/", + "builtOn":"test-packetnet-ubuntu1804-x64-1", + "changeSet":{ + "_class":"hudson.scm.EmptyChangeLogSet", + "items":[ + + ], + "kind":null + }, + "culprits":[ + + ], + "runs":[ + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=aix71-ppc64/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=centos7-ppcle/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=debian9-64/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=fedora-last-latest-x64/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=fedora-latest-x64/866/" + }, + { + "number":864, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1010/864/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1014/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1015/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=rhel7-s390x/866/" + }, + { + "number":864, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1404-64/864/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1604-64/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1804-64/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=win10-vs2019/866/" + }, + { + "number":866, + "url":"https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=win2016-vs2017/866/" + } + ] +} \ No newline at end of file diff --git a/test/fixtures/jenkins/citgm-nobuild/expected.json b/test/fixtures/jenkins/citgm-nobuild/expected.json new file mode 100644 index 00000000..2d102048 --- /dev/null +++ b/test/fixtures/jenkins/citgm-nobuild/expected.json @@ -0,0 +1,70 @@ +{ + "upstream": "https://ci.nodejs.org/job/citgm-smoker-nobuild/866/", + "passed": 9, + "total": 12, + "skipped": 0, + "failed": 3, + "osx1015": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1015/866/", + "modules": [] + }, + "win2016-vs2017": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=win2016-vs2017/866/", + "modules": [ + { + "name": "through2-v4.0.2", + "status": "FAILED" + } + ] + }, + "fedora-last-latest-x64": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=fedora-last-latest-x64/866/", + "modules": [] + }, + "debian9-64": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=debian9-64/866/", + "modules": [] + }, + "ubuntu1804-64": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1804-64/866/", + "modules": [] + }, + "rhel7-s390x": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=rhel7-s390x/866/", + "modules": [] + }, + "aix71-ppc64": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=aix71-ppc64/866/", + "modules": [ + { + "name": "through2-v4.0.2", + "status": "FAILED" + } + ] + }, + "osx1014": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1014/866/", + "modules": [] + }, + "win10-vs2019": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=win10-vs2019/866/", + "modules": [ + { + "name": "through2-v4.0.2", + "status": "FAILED" + } + ] + }, + "fedora-latest-x64": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=fedora-latest-x64/866/", + "modules": [] + }, + "centos7-ppcle": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=centos7-ppcle/866/", + "modules": [] + }, + "ubuntu1604-64": { + "url": "https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1604-64/866/", + "modules": [] + } +} \ No newline at end of file diff --git a/test/fixtures/jenkins/citgm-nobuild/expected.md b/test/fixtures/jenkins/citgm-nobuild/expected.md new file mode 100644 index 00000000..26bd4e1b --- /dev/null +++ b/test/fixtures/jenkins/citgm-nobuild/expected.md @@ -0,0 +1,58 @@ +# CITGM Data for [866](https://ci.nodejs.org/job/citgm-smoker-nobuild/866/) + +## Statistics for job [866](https://ci.nodejs.org/job/citgm-smoker-nobuild/866/) + +| FAILED | SKIPPED | PASSED | TOTAL | +| -------- | --------- | -------- | ------- | +| 3 | 0 | 9 | 12 | + +## Failures in job [866](https://ci.nodejs.org/job/citgm-smoker-nobuild/866/) + +### [osx1015](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1015/866/) + +None. + +### [win2016-vs2017](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=win2016-vs2017/866/) + +* through2-v4.0.2 + +### [fedora-last-latest-x64](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=fedora-last-latest-x64/866/) + +None. + +### [debian9-64](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=debian9-64/866/) + +None. + +### [ubuntu1804-64](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1804-64/866/) + +None. + +### [rhel7-s390x](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=rhel7-s390x/866/) + +None. + +### [aix71-ppc64](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=aix71-ppc64/866/) + +* through2-v4.0.2 + +### [osx1014](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=osx1014/866/) + +None. + +### [win10-vs2019](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=win10-vs2019/866/) + +* through2-v4.0.2 + +### [fedora-latest-x64](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=fedora-latest-x64/866/) + +None. + +### [centos7-ppcle](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=centos7-ppcle/866/) + +None. + +### [ubuntu1604-64](https://ci.nodejs.org/job/citgm-smoker-nobuild/nodes=ubuntu1604-64/866/) + +None. + diff --git a/test/unit/ci_result_parser.test.js b/test/unit/ci_result_parser.test.js index b4ad6952..4f207c93 100644 --- a/test/unit/ci_result_parser.test.js +++ b/test/unit/ci_result_parser.test.js @@ -185,7 +185,29 @@ describe('Jenkins', () => { jobCache.enable(); const cli = new TestCLI(); - const citgmBuild = new CITGMBuild(cli, {}, 2400); + const job = { jobid: 2400, noBuild: false }; + const citgmBuild = new CITGMBuild(cli, {}, job); + await citgmBuild.getResults(); + + const expectedJson = fixtures.readJSON(...prefix, 'expected.json'); + assert.deepStrictEqual(citgmBuild.formatAsJson(), expectedJson); + + const markdown = citgmBuild.formatAsMarkdown(); + const expected = fixtures.readFile(...prefix, 'expected.md'); + assert.strictEqual(markdown, expected); + }); + + it('should correctly fetch CITGM nobuild job results', async() => { + tmpdir.refresh(); + const prefix = ['jenkins', 'citgm-nobuild']; + const fixturesDir = path.join(__dirname, '..', 'fixtures', ...prefix); + copyShallow(fixturesDir, tmpdir.path); + jobCache.dir = tmpdir.path; + jobCache.enable(); + + const cli = new TestCLI(); + const job = { jobid: 866, noBuild: true }; + const citgmBuild = new CITGMBuild(cli, {}, job); await citgmBuild.getResults(); const expectedJson = fixtures.readJSON(...prefix, 'expected.json');