mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: store artifacts with test results (#9912)
This commit is contained in:
parent
dcfec6dbbd
commit
3a31070d05
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
@ -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'
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user