-
Notifications
You must be signed in to change notification settings - Fork 492
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
test(core): merge all package test reports #6261
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0b2aed9
test(core): merge all package test reports
jpinkney-aws 081c031
fixup
jpinkney-aws 5ef73cf
test failures
jpinkney-aws dfe2892
failure
jpinkney-aws 5273b20
test
jpinkney-aws 5b6e145
test
jpinkney-aws adf5ca6
test
jpinkney-aws 4e5655f
test
jpinkney-aws bb0bf30
fixup
jpinkney-aws b7e94e0
fixup
jpinkney-aws 9d89d5b
fixup
jpinkney-aws 155f4c5
fixup
jpinkney-aws d03a757
fixup
jpinkney-aws 924b90e
fixup
jpinkney-aws 5d3ade7
test
jpinkney-aws 9a6f7b7
test
jpinkney-aws 28384ad
test
jpinkney-aws a5f44d8
test
jpinkney-aws e7d26cb
fix strings
jpinkney-aws 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
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
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
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
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
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
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,71 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
import * as xml2js from 'xml2js' | ||
|
||
/** | ||
* Merge all of the packages/ test reports into a single directory | ||
*/ | ||
async function mergeReports() { | ||
console.log('Merging test reports') | ||
|
||
const packagesDir = `${__dirname}/../packages` | ||
|
||
// Get all packages/* directories | ||
const packageDirs = fs.readdirSync(packagesDir).map((dir) => path.join(packagesDir, dir)) | ||
|
||
// Find report.xml files in .test-reports subdirectories | ||
const testReports = packageDirs | ||
.map((dir) => `${dir}/.test-reports/report.xml`) | ||
.filter((file) => fs.existsSync(file)) | ||
|
||
const mergedReport = { | ||
testsuites: { | ||
testsuite: [], | ||
}, | ||
} | ||
|
||
// Collect all test reports into a single merged test report object | ||
for (const file of testReports) { | ||
const content = fs.readFileSync(file) | ||
const result: { testsuites: { testsuite: [] } } = await xml2js.parseStringPromise(content) | ||
if (result.testsuites && result.testsuites.testsuite) { | ||
mergedReport.testsuites.testsuite.push(...result.testsuites.testsuite) | ||
} | ||
} | ||
|
||
const builder = new xml2js.Builder() | ||
const xml = builder.buildObject(mergedReport) | ||
|
||
/** | ||
* Create the new test reports directory and write the test report | ||
*/ | ||
const reportsDir = path.join(__dirname, '..', '.test-reports') | ||
jpinkney-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Create reports directory if it doesn't exist | ||
if (!fs.existsSync(reportsDir)) { | ||
fs.mkdirSync(reportsDir, { recursive: true }) | ||
} | ||
|
||
fs.writeFileSync(`${reportsDir}/report.xml`, xml) | ||
|
||
const exitCodeArg = process.argv[2] | ||
if (exitCodeArg) { | ||
/** | ||
* Retrieves the exit code from the previous test run execution. | ||
* | ||
* This allows us to: | ||
* 1. Merge and upload test reports regardless of the test execution status | ||
* 2. Preserve the original test run exit code | ||
* 3. Report the test status back to CI | ||
*/ | ||
const exitCode = parseInt(exitCodeArg || '0', 10) | ||
process.exit(exitCode) | ||
} | ||
} | ||
|
||
mergeReports() |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on a local test of this command:
I suspect the above
;
may not correctly pipe all the output fromnpm test
torun_and_report
as intended.To confirm that the piping to
run_and_report
is still working correctly, can you try temporarily changing this search patter to something that always outputs, like:then CI should fail.
If it doesn't, we can fix the issue by changing the pipeline to something like (note: whitespace near the braces is required):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested and that was indeed the case. I've switched to your suggestion and it seems to work as expected