ci: fix empty retries env var (#11151)

This commit is contained in:
Nikolay Vitkov 2023-10-13 14:13:54 +02:00 committed by GitHub
parent 8290dc9de9
commit eae37d99e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 8 deletions

View File

@ -37,6 +37,7 @@ on:
retries: retries:
description: Number of retries per test description: Number of retries per test
required: false required: false
default: 100
type: number type: number
jobs: jobs:

View File

@ -32,7 +32,11 @@ const skippedTests: Array<{testIdPattern: string; skip: true}> = process.env[
? JSON.parse(process.env['PUPPETEER_SKIPPED_TEST_CONFIG']) ? JSON.parse(process.env['PUPPETEER_SKIPPED_TEST_CONFIG'])
: []; : [];
const deflakeRetries = Number(process.env['PUPPETEER_DEFLAKE_RETRIES'] ?? 100); const deflakeRetries = Number(
process.env['PUPPETEER_DEFLAKE_RETRIES']
? process.env['PUPPETEER_DEFLAKE_RETRIES']
: 100
);
const deflakeTestPattern: string | undefined = const deflakeTestPattern: string | undefined =
process.env['PUPPETEER_DEFLAKE_TESTS']; process.env['PUPPETEER_DEFLAKE_TESTS'];
@ -136,10 +140,7 @@ function customBDDInterface(suite: Mocha.Suite) {
); );
if (shouldDeflakeTest(test)) { if (shouldDeflakeTest(test)) {
const deflakeSuit = Mocha.Suite.create(suite, 'with Debug Logs'); const deflakeSuit = Mocha.Suite.create(suite, 'with Debug Logs');
test.parent = deflakeSuit; test.file = file;
deflakeSuit.file = file;
deflakeSuit.parent = suite;
deflakeSuit.beforeEach(function () { deflakeSuit.beforeEach(function () {
setLogCapture(true); setLogCapture(true);
}); });
@ -147,7 +148,6 @@ function customBDDInterface(suite: Mocha.Suite) {
for (let i = 0; i < deflakeRetries; i++) { for (let i = 0; i < deflakeRetries; i++) {
deflakeSuit.addTest(test.clone()); deflakeSuit.addTest(test.clone());
} }
return test; return test;
} else if (!(itOnly || describeOnly) && shouldSkipTest(test)) { } else if (!(itOnly || describeOnly) && shouldSkipTest(test)) {
const test = new Mocha.Test(title); const test = new Mocha.Test(title);

View File

@ -25,7 +25,7 @@ import type {
} from './types.js'; } from './types.js';
export function extendProcessEnv(envs: object[]): NodeJS.ProcessEnv { export function extendProcessEnv(envs: object[]): NodeJS.ProcessEnv {
return envs.reduce( const env = envs.reduce(
(acc: object, item: object) => { (acc: object, item: object) => {
Object.assign(acc, item); Object.assign(acc, item);
return acc; return acc;
@ -33,7 +33,28 @@ export function extendProcessEnv(envs: object[]): NodeJS.ProcessEnv {
{ {
...process.env, ...process.env,
} }
) as NodeJS.ProcessEnv; );
if (process.env['CI']) {
const puppeteerEnv = Object.entries(env).reduce(
(acc, [key, value]) => {
if (key.startsWith('PUPPETEER_')) {
acc[key] = value;
}
return acc;
},
{} as Record<string, unknown>
);
console.log(
'PUPPETEER env:\n',
JSON.stringify(puppeteerEnv, null, 2),
'\n'
);
}
return env as NodeJS.ProcessEnv;
} }
export function getFilename(file: string): string { export function getFilename(file: string): string {