forked from getdokan/dokan
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae2b960
commit 55a49e9
Showing
3 changed files
with
98 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Helper function to format duration | ||
const getFormattedDuration = milliseconds => { | ||
const hours = Math.floor(milliseconds / (1000 * 60 * 60)); | ||
const min = Math.floor((milliseconds / (1000 * 60)) % 60); | ||
const sec = Math.floor((milliseconds / 1000) % 60); | ||
return `${hours < 1 ? '' : hours + 'h '}${min < 1 ? '' : min + 'm '}${sec < 1 ? '' : sec + 's'}`; | ||
}; | ||
|
||
const mergeReports = reportPaths => { | ||
const mergedReport = { | ||
suite_name: '', | ||
total_tests: 0, | ||
passed: 0, | ||
failed: 0, | ||
flaky: 0, | ||
skipped: 0, | ||
suite_duration: 0, | ||
suite_duration_formatted: '', | ||
tests: [], | ||
passed_tests: [], | ||
failed_tests: [], | ||
flaky_tests: [], | ||
skipped_tests: [], | ||
}; | ||
|
||
reportPaths.forEach(reportPath => { | ||
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8')); | ||
mergedReport.total_tests += report.total_tests; | ||
mergedReport.passed += report.passed; | ||
mergedReport.failed += report.failed; | ||
mergedReport.flaky += report.flaky; | ||
mergedReport.skipped += report.skipped; | ||
mergedReport.suite_duration += report.suite_duration; | ||
|
||
// Append and de-duplicate test arrays | ||
mergedReport.tests.push(...report.tests); | ||
mergedReport.passed_tests.push(...report.passed_tests); | ||
mergedReport.failed_tests.push(...report.failed_tests); | ||
mergedReport.flaky_tests.push(...report.flaky_tests); | ||
mergedReport.skipped_tests.push(...report.skipped_tests); | ||
}); | ||
|
||
// Remove duplicates and sort arrays | ||
mergedReport.tests = [...new Set(mergedReport.tests)].sort(); | ||
mergedReport.passed_tests = [...new Set(mergedReport.passed_tests)].sort(); | ||
mergedReport.failed_tests = [...new Set(mergedReport.failed_tests)].sort(); | ||
mergedReport.flaky_tests = [...new Set(mergedReport.flaky_tests)].sort(); | ||
mergedReport.skipped_tests = [...new Set(mergedReport.skipped_tests)].sort(); | ||
|
||
// Format the suite duration | ||
mergedReport.suite_duration_formatted = getFormattedDuration(mergedReport.suite_duration); | ||
|
||
return mergedReport; | ||
}; | ||
|
||
// Main script execution | ||
const reportsFolder = './all-reports'; // Change to your artifacts location | ||
const reportPaths = []; | ||
|
||
// Collect all result.json files | ||
const findReports = dir => { | ||
const files = fs.readdirSync(dir); | ||
files.forEach(file => { | ||
const fullPath = path.join(dir, file); | ||
if (fs.statSync(fullPath).isDirectory()) { | ||
findReports(fullPath); // Recurse into subdirectories | ||
} else if (file === 'results.json') { | ||
reportPaths.push(fullPath); | ||
} | ||
}); | ||
}; | ||
|
||
findReports(reportsFolder); | ||
|
||
if (reportPaths.length === 0) { | ||
console.error('No results.json files found in artifacts.'); | ||
process.exit(1); | ||
} | ||
|
||
// Merge reports | ||
const mergedReport = mergeReports(reportPaths); | ||
|
||
// Save the merged report | ||
const outputPath = './all-reports/merged-summary.json'; | ||
fs.writeFileSync(outputPath, JSON.stringify(mergedReport, null, 2), 'utf8'); | ||
|
||
console.log(`Merged summary report saved to ${outputPath}`); |