Files
nomad/scripts/combine-ui-test-results.js
Phil Renaud 4b91c17dfa [ui, ci] retain artifacts from test runs including test timing (#24555)
* retain artifacts from test runs including test timing

* Pinning commit hashes for action helpers

* trigger for ui-test run

* Trying to isolate down to a simple upload

* Once more with mkdir

* What if we just wrote our own test reporter tho

* Let the partitioned runs handle placement

* Filter out common token logs, add a summary at the end, and note failures in logtime

* Custom reporter cannot also have an output file, he finds out two days late

* Aggregate summary, duration, and removing failure case

* Conditional test report generation

* Timeouts are errors

* Trying with un-partitioned input json file

* Remove the commented-out lines for main-only runs

* combine-ui-test-results as its own script
2024-12-03 09:56:06 -05:00

52 lines
1.2 KiB
JavaScript

#!/usr/bin/env node
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
'use strict';
const fs = require('fs');
const NUM_PARTITIONS = 4;
function combineResults() {
const results = [];
let duration = 0;
let aggregateSummary = { total: 0, passed: 0, failed: 0 };
for (let i = 1; i <= NUM_PARTITIONS; i++) {
try {
const data = JSON.parse(
fs.readFileSync(`../test-results/test-results-${i}/test-results.json`).toString()
);
results.push(...data.tests);
duration += data.duration;
aggregateSummary.total += data.summary.total;
aggregateSummary.passed += data.summary.passed;
aggregateSummary.failed += data.summary.failed;
} catch (err) {
console.error(`Error reading partition ${i}:`, err);
}
}
const output = {
timestamp: new Date().toISOString(),
sha: process.env.GITHUB_SHA,
summary: {
total: aggregateSummary.total,
passed: aggregateSummary.passed,
failed: aggregateSummary.failed
},
duration,
tests: results
};
fs.writeFileSync('../ui/combined-test-results.json', JSON.stringify(output, null, 2));
}
if (require.main === module) {
combineResults();
}
module.exports = combineResults;