-
Notifications
You must be signed in to change notification settings - Fork 122
feat: allow citgm job comparison #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7d54e44
refactor: pull some builds into own files
codebytere 08b01ad
feat: enable citgm run comparisons
codebytere 5148297
spec: add tests for comparisons
codebytere 063238a
Fix filter error and simplify logic
codebytere 18109a6
Remove accidental test diff
codebytere 91f107e
Fixup after nobuild PR
codebytere 8f9dd8e
Add new test for noBuild comparison
codebytere 3f4fcb1
Add better documentation
codebytere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: enable citgm run comparisons
- Loading branch information
commit 08b01adead389ece3deea32c6e2cb9cb4df0cb1a
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,138 @@ | ||
| 'use strict'; | ||
|
|
||
| const { statusType } = require('../ci_utils'); | ||
| const { CITGMBuild } = require('./citgm_build'); | ||
|
|
||
| class CITGMComparisonBuild { | ||
| constructor(cli, request, ids) { | ||
| const baseBuild = new CITGMBuild(cli, request, ids[0]); | ||
| const comparisonBuild = new CITGMBuild(cli, request, ids[1]); | ||
|
|
||
| this.cli = cli; | ||
| this.builds = { baseBuild, comparisonBuild }; | ||
| this.results = {}; | ||
| this.ids = ids; | ||
| } | ||
|
|
||
| async getResults() { | ||
| const { builds } = this; | ||
| const { baseBuild, comparisonBuild } = builds; | ||
|
|
||
| // Result in a comparison context reflects | ||
| // whether or not there were failures in | ||
| // comparisonBuild not present in baseBuild, | ||
| // e.g if there were new failures. | ||
| let result = statusType.SUCCESS; | ||
|
|
||
| await baseBuild.getResults(); | ||
| await comparisonBuild.getResults(); | ||
|
|
||
| const { failures: baseFailures } = baseBuild.results; | ||
| const { failures: comparisonFailures } = comparisonBuild.results; | ||
|
|
||
| const failures = {}; | ||
| for (const platform in baseFailures) { | ||
| const { modules: baseModules } = comparisonFailures[platform]; | ||
| const { modules: comparisonModules } = comparisonFailures[platform]; | ||
|
|
||
| const newFailures = comparisonModules.filter(f => { | ||
| return !baseModules.includes(f.name); | ||
| }); | ||
|
|
||
| if (newFailures.length !== 0) { | ||
| result = statusType.FAILURE; | ||
| } | ||
|
|
||
| failures[platform] = newFailures; | ||
| } | ||
|
|
||
| this.results.failures = failures; | ||
| this.result = result; | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| display() { | ||
| const { builds } = this; | ||
|
|
||
| // Display header for both CITGM runs. | ||
| builds.baseBuild.displayHeader(); | ||
| builds.comparisonBuild.displayHeader(); | ||
|
|
||
| this.displayBuilds(); | ||
| } | ||
|
|
||
| displayBuilds() { | ||
| const { builds, cli, results, result } = this; | ||
|
|
||
| const baseID = builds.baseBuild.id; | ||
| const comparisonID = builds.comparisonBuild.id; | ||
|
|
||
| cli.separator('Results'); | ||
|
|
||
| if (result === statusType.SUCCESS) { | ||
| cli.log('\n\n'); | ||
| const str = `No new failures in ${baseID} compared to ${comparisonID}`; | ||
| cli.log(`${statusType.SUCCESS}: ${str}\n\n`); | ||
| return; | ||
| } | ||
|
|
||
| const output = {}; | ||
| for (const platform in results.failures) { | ||
| const modules = results.failures[platform]; | ||
| const failures = modules.map(f => f.name); | ||
|
|
||
| output[platform] = failures; | ||
| } | ||
|
|
||
| console.table(output); | ||
| } | ||
|
|
||
| formatAsJson() { | ||
| const { builds, results } = this; | ||
| const { baseBuild, comparisonBuild } = builds; | ||
|
|
||
| const result = { | ||
| baseBuild: { | ||
| source: baseBuild.sourceURL, | ||
| upstream: comparisonBuild.jobUrl | ||
| }, | ||
| comparisonBuild: { | ||
| source: comparisonBuild.sourceURL, | ||
| upstream: baseBuild.jobUrl | ||
| }, | ||
| ...results.failures | ||
| }; | ||
|
|
||
| return JSON.parse(JSON.stringify(result)); | ||
| } | ||
|
|
||
| formatAsMarkdown() { | ||
| const { builds, result, results } = this; | ||
| const { baseBuild, comparisonBuild } = builds; | ||
|
|
||
| const bLink = `[#${baseBuild.id}](${baseBuild.jobUrl})`; | ||
| const cLink = `[#${comparisonBuild.id}](${comparisonBuild.jobUrl})`; | ||
|
|
||
| let output = `# CITGM Data for ${bLink} - ${cLink}\n\n`; | ||
|
|
||
| if (result === 'success') { | ||
| const bID = baseBuild.id; | ||
| const cID = comparisonBuild.id; | ||
| output += `No new failures in ${cID} compared to ${bID}`; | ||
| return output; | ||
| } | ||
|
|
||
| output += `## New Failures in job ${cLink}\n\n`; | ||
| for (const failure in results.failures) { | ||
| const data = results.failures[failure]; | ||
| output += `### ${failure}\n\n`; | ||
|
|
||
| const failures = data.map(f => `* ${f.name}`); | ||
| output += failures.length ? `${failures.join('\n')}\n\n` : 'None.\n\n'; | ||
| } | ||
| return output; | ||
| } | ||
| } | ||
|
|
||
| module.exports = { CITGMComparisonBuild }; | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.