chore: store artifacts with test results (#9912)

This commit is contained in:
Alex Rudenko 2023-03-24 15:31:47 +01:00 committed by GitHub
parent dcfec6dbbd
commit 3a31070d05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 4 deletions

View File

@ -148,13 +148,18 @@ jobs:
run: npm run test-types
- name: Run all tests (for non-Linux)
if: ${{ matrix.os != 'ubuntu-latest' }}
run: npm run test -- --test-suite ${{ matrix.suite }}
run: npm run test -- --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
- name: Install linux dependencies.
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install xvfb
- name: Run all tests (for Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: xvfb-run --auto-servernum npm run test -- --test-suite ${{ matrix.suite }}
run: xvfb-run --auto-servernum npm run test -- --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
- uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: /tmp/artifacts/*.json
chrome-tests-required:
name: '[Required] Chrome tests'
@ -208,13 +213,18 @@ jobs:
run: npm run test-types
- name: Run all tests (for non-Linux)
if: ${{ matrix.os != 'ubuntu-latest' }}
run: npm run test -- --test-suite ${{ matrix.suite }}
run: npm run test -- --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
- name: Install linux dependencies.
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install xvfb
- name: Run all tests (for Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: xvfb-run --auto-servernum npm run test -- --test-suite ${{ matrix.suite }}
run: xvfb-run --auto-servernum npm run test -- --test-suite ${{ matrix.suite }} --save-stats-to /tmp/artifacts/${{ github.event_name }}_INSERTID.json
- uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: /tmp/artifacts/*.json
firefox-tests-required:
name: '[Required] Firefox tests'

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
import {randomUUID} from 'crypto';
import fs from 'fs';
import {spawn, SpawnOptions} from 'node:child_process';
import os from 'os';
@ -36,6 +37,7 @@ import {
getExpectationUpdates,
printSuggestions,
RecommendedExpectation,
writeJSON,
} from './utils.js';
function getApplicableTestSuites(
@ -78,6 +80,9 @@ async function main() {
let statsFilename = '';
if (statsFilenameIdx !== -1) {
statsFilename = process.argv[statsFilenameIdx + 1] as string;
if (statsFilename.includes('INSERTID')) {
statsFilename = statsFilename.replace(/INSERTID/gi, randomUUID());
}
}
const platform = zPlatform.parse(os.platform());
@ -205,11 +210,17 @@ async function main() {
platforms: [os.platform()],
parameters,
});
results.parameters = parameters;
results.platform = platform;
results.date = new Date().toISOString();
if (updates.length > 0) {
fail = true;
recommendations.push(...updates);
results.updates = updates;
writeJSON(tmpFilename, results);
} else {
console.log('Test run matches expectations');
writeJSON(tmpFilename, results);
continue;
}
} catch (err) {

View File

@ -16,6 +16,8 @@
import {z} from 'zod';
import {RecommendedExpectation} from './utils.js';
export const zPlatform = z.enum(['win32', 'linux', 'darwin']);
export type Platform = z.infer<typeof zPlatform>;
@ -57,4 +59,9 @@ export type MochaResults = {
pending: MochaTestResult[];
passes: MochaTestResult[];
failures: MochaTestResult[];
// Added by mochaRunner.
updates?: RecommendedExpectation[];
parameters?: string[];
platform?: string;
date?: string;
};

View File

@ -44,6 +44,10 @@ export function readJSON(path: string): unknown {
return JSON.parse(fs.readFileSync(path, 'utf-8'));
}
export function writeJSON(path: string, json: unknown): unknown {
return fs.writeFileSync(path, JSON.stringify(json, null, 2));
}
export function filterByPlatform<T extends {platforms: NodeJS.Platform[]}>(
items: T[],
platform: NodeJS.Platform