Skip to content

Commit

Permalink
Fix filter error and simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jul 21, 2020
1 parent 1fc9c06 commit 843b259
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 58 deletions.
6 changes: 5 additions & 1 deletion lib/ci/build-types/citgm_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class CITGMBuild extends TestBuild {
parseResults(data) {
const { childReports, totalCount, skipCount, failCount } = data;
const results = { all: {}, failures: {}, statistics: {} };
const failureStatuses = ['FAILED', 'REGRESSION'];

const passCount = totalCount - failCount - skipCount;
results.statistics.passed = passCount;
Expand All @@ -82,7 +83,10 @@ class CITGMBuild extends TestBuild {

results.all[nodeName] = { url, modules: cases };

const failedModules = cases.filter(c => c.status === 'FAILED');
const failedModules = cases.filter(c => {
return failureStatuses.includes(c.status);
});

results.failures[nodeName] = { url, modules: failedModules };
});

Expand Down
37 changes: 26 additions & 11 deletions lib/ci/build-types/citgm_comparison_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,25 @@ class CITGMComparisonBuild {
const { failures: comparisonFailures } = comparisonBuild.results;

const failures = {};
for (const platform in baseFailures) {
const { modules: baseModules } = baseFailures[platform];
const { modules: comparisonModules } = comparisonFailures[platform];
for (const platform in comparisonFailures) {
// Account for no failure on this platform, or different platform.
if (!Object.prototype.hasOwnProperty.call(baseFailures, platform)) {
failures[platform] = [];
continue;
}

const newFailures = comparisonModules.filter(f => {
return !baseModules.includes(f.name);
const baseModules = baseFailures[platform].modules.map(f => {
return f.name;
});
const comparisonModules = comparisonFailures[platform].modules.map(f => {
return f.name;
});

// Filter for every failed module in the comparison job module set
// that is not present in the failure set for the base job module set.
const newFailures = comparisonModules.filter(f => {
return !baseModules.includes(f);
});
if (newFailures.length !== 0) {
result = statusType.FAILURE;
}
Expand All @@ -65,26 +76,30 @@ class CITGMComparisonBuild {
displayBuilds() {
const { builds, cli, results, result } = this;

const baseID = builds.baseBuild.id;
const comparisonID = builds.comparisonBuild.id;
const bID = builds.baseBuild.id;
const cID = builds.comparisonBuild.id;

cli.separator('Results');

if (result === statusType.SUCCESS) {
cli.log('\n\n');
const str = `No new failures in ${baseID} compared to ${comparisonID}`;
const str = `No new failures in ${bID} compared to ${cID}`;
cli.log(`${statusType.SUCCESS}: ${str}\n\n`);
return;
}

const output = {};
let totalFailures = 0;
for (const platform in results.failures) {
const modules = results.failures[platform];
const failures = modules.map(f => f.name);
const failures = results.failures[platform];
totalFailures += failures.length;

output[platform] = failures;
}

cli.log('\n\n');
const str = `${totalFailures} failures in ${bID} not present in ${cID}`;
cli.log(`${statusType.FAILURE}: ${str}\n\n`);
console.table(output);
}

Expand Down Expand Up @@ -128,7 +143,7 @@ class CITGMComparisonBuild {
const data = results.failures[failure];
output += `### ${failure}\n\n`;

const failures = data.map(f => `* ${f.name}`);
const failures = data.map(f => `* ${f}`);
output += failures.length ? `${failures.join('\n')}\n\n` : 'None.\n\n';
}
return output;
Expand Down
49 changes: 14 additions & 35 deletions test/fixtures/jenkins/citgm-compare/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,22 @@
"source": "https://github.com/nodejs/node/pull/33811/",
"upstream": "https://ci.nodejs.org/job/citgm-smoker/2392/"
},
"debian9-64": [
{
"name": "express-session-v1.17.1",
"status": "FAILED"
},
{
"name": "yeoman-generator-v4.10.1",
"status": "FAILED"
}
],
"centos7-ppcle": [
{
"name": "ember-cli-v3.18.0",
"status": "FAILED"
},
{
"name": "multer-v1.4.2",
"status": "FAILED"
},
{
"name": "torrent-stream-v1.2.0",
"status": "FAILED"
}
],
"rhel7-s390x": [
{
"name": "torrent-stream-v1.2.0",
"status": "FAILED"
}
"multer-v1.4.2"
],
"fedora-latest-x64": [
{
"name": "spawn-wrap-v2.0.0",
"status": "FAILED"
}
"spawn-wrap-v2.0.0"
],
"ubuntu1804-64": [],
"fedora-last-latest-x64": [],
"ubuntu1604-64": []
}
"debian9-64": [
"express-session-v1.17.1",
"yeoman-generator-v4.10.1"
],
"osx1014": [],
"rhel7-s390x": [
"torrent-stream-v1.2.0"
],
"aix71-ppc64": [],
"ubuntu1604-64": [],
"ubuntu1804-64": []
}
28 changes: 17 additions & 11 deletions test/fixtures/jenkins/citgm-compare/expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@

## New Failures in job [#2390](https://ci.nodejs.org/job/citgm-smoker/2390/)

### centos7-ppcle

* multer-v1.4.2

### fedora-latest-x64

* spawn-wrap-v2.0.0

### fedora-last-latest-x64

None.

### debian9-64

* express-session-v1.17.1
* yeoman-generator-v4.10.1

### centos7-ppcle
### osx1014

* ember-cli-v3.18.0
* multer-v1.4.2
* torrent-stream-v1.2.0
None.

### rhel7-s390x

* torrent-stream-v1.2.0

### fedora-latest-x64

* spawn-wrap-v2.0.0

### ubuntu1804-64
### aix71-ppc64

None.

### fedora-last-latest-x64
### ubuntu1604-64

None.

### ubuntu1604-64
### ubuntu1804-64

None.

0 comments on commit 843b259

Please sign in to comment.