Update mock-server, upload ci logs on failure

This commit is contained in:
Fedor Indutny 2022-02-24 17:21:56 -08:00 committed by GitHub
parent 21db47c423
commit 1d89ffcc2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 83 additions and 10 deletions

View file

@ -3,10 +3,14 @@
/* eslint-disable no-await-in-loop, no-console */
import createDebug from 'debug';
import fs from 'fs/promises';
import path from 'path';
import { Bootstrap } from '../bootstrap';
export const debug = createDebug('mock:benchmarks');
export { Bootstrap } from '../bootstrap';
export { Bootstrap };
export { App } from '../playwright';
export type StatsType = {
@ -59,6 +63,19 @@ export function stats(
return result;
}
export async function saveLogs(bootstrap: Bootstrap): Promise<void> {
const { ARTIFACTS_DIR } = process.env;
if (!ARTIFACTS_DIR) {
console.error('Not saving logs. Please set ARTIFACTS_DIR env variable');
return;
}
await fs.mkdir(ARTIFACTS_DIR, { recursive: true });
const { logsDir } = bootstrap;
await fs.rename(logsDir, path.join(ARTIFACTS_DIR, 'logs'));
}
// Can happen if electron exits prematurely
process.on('unhandledRejection', reason => {
console.error('Unhandled rejection:');