mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
ci: optimize installation tests and inspect code (#11150)
This commit is contained in:
parent
8aa6cb37d2
commit
cfe4b8b0cd
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -60,7 +60,6 @@ jobs:
|
|||||||
rm $diff_file
|
rm $diff_file
|
||||||
|
|
||||||
check-changes:
|
check-changes:
|
||||||
needs: inspect-code
|
|
||||||
uses: ./.github/workflows/changed-packages.yml
|
uses: ./.github/workflows/changed-packages.yml
|
||||||
with:
|
with:
|
||||||
check-mergeable-state: true
|
check-mergeable-state: true
|
||||||
|
@ -16,12 +16,16 @@
|
|||||||
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import {readdir} from 'fs/promises';
|
import {readdir} from 'fs/promises';
|
||||||
|
import {platform} from 'os';
|
||||||
import {join} from 'path';
|
import {join} from 'path';
|
||||||
|
|
||||||
import {configureSandbox} from './sandbox.js';
|
import {configureSandbox} from './sandbox.js';
|
||||||
import {readAsset} from './util.js';
|
import {readAsset} from './util.js';
|
||||||
|
|
||||||
describe('`puppeteer` with Firefox', () => {
|
// Skipping this test on Windows as windows runners are much slower.
|
||||||
|
(platform() === 'win32' ? describe.skip : describe)(
|
||||||
|
'`puppeteer` with Firefox',
|
||||||
|
() => {
|
||||||
configureSandbox({
|
configureSandbox({
|
||||||
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
||||||
env: cwd => {
|
env: cwd => {
|
||||||
@ -44,4 +48,5 @@ describe('`puppeteer` with Firefox', () => {
|
|||||||
const script = await readAsset('puppeteer-core', 'imports.js');
|
const script = await readAsset('puppeteer-core', 'imports.js');
|
||||||
await this.runScript(script, 'mjs');
|
await this.runScript(script, 'mjs');
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
@ -15,12 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {readFile, writeFile} from 'fs/promises';
|
import {readFile, writeFile} from 'fs/promises';
|
||||||
|
import {platform} from 'os';
|
||||||
import {join} from 'path';
|
import {join} from 'path';
|
||||||
|
|
||||||
import {configureSandbox} from './sandbox.js';
|
import {configureSandbox} from './sandbox.js';
|
||||||
import {execFile, readAsset} from './util.js';
|
import {execFile, readAsset} from './util.js';
|
||||||
|
|
||||||
describe('`puppeteer` with TypeScript', () => {
|
// Skipping this test on Windows as windows runners are much slower.
|
||||||
|
(platform() === 'win32' ? describe.skip : describe)(
|
||||||
|
'`puppeteer` with TypeScript',
|
||||||
|
() => {
|
||||||
configureSandbox({
|
configureSandbox({
|
||||||
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
||||||
devDependencies: ['typescript@4.7.4', '@types/node@16.3.3'],
|
devDependencies: ['typescript@4.7.4', '@types/node@16.3.3'],
|
||||||
@ -51,4 +55,5 @@ describe('`puppeteer` with TypeScript', () => {
|
|||||||
|
|
||||||
await this.runScript(script, 'cjs');
|
await this.runScript(script, 'cjs');
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import {readdirSync} from 'fs';
|
import {readdirSync} from 'fs';
|
||||||
import {readdir} from 'fs/promises';
|
import {readdir} from 'fs/promises';
|
||||||
|
import {platform} from 'os';
|
||||||
import {join} from 'path';
|
import {join} from 'path';
|
||||||
|
|
||||||
import {configureSandbox} from './sandbox.js';
|
import {configureSandbox} from './sandbox.js';
|
||||||
@ -46,7 +47,10 @@ describe('`puppeteer`', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('`puppeteer` with PUPPETEER_DOWNLOAD_PATH', () => {
|
// Skipping this test on Windows as windows runners are much slower.
|
||||||
|
(platform() === 'win32' ? describe.skip : describe)(
|
||||||
|
'`puppeteer` with PUPPETEER_DOWNLOAD_PATH',
|
||||||
|
() => {
|
||||||
configureSandbox({
|
configureSandbox({
|
||||||
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
||||||
env: cwd => {
|
env: cwd => {
|
||||||
@ -64,9 +68,13 @@ describe('`puppeteer` with PUPPETEER_DOWNLOAD_PATH', () => {
|
|||||||
const script = await readAsset('puppeteer', 'basic.js');
|
const script = await readAsset('puppeteer', 'basic.js');
|
||||||
await this.runScript(script, 'mjs');
|
await this.runScript(script, 'mjs');
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
describe('`puppeteer` clears cache', () => {
|
// Skipping this test on Windows as windows runners are much slower.
|
||||||
|
(platform() === 'win32' ? describe.skip : describe)(
|
||||||
|
'`puppeteer` clears cache',
|
||||||
|
() => {
|
||||||
configureSandbox({
|
configureSandbox({
|
||||||
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
||||||
env: cwd => {
|
env: cwd => {
|
||||||
@ -99,4 +107,5 @@ describe('`puppeteer` clears cache', () => {
|
|||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
@ -72,6 +72,7 @@ declare module 'mocha' {
|
|||||||
*/
|
*/
|
||||||
export const configureSandbox = (options: SandboxOptions): void => {
|
export const configureSandbox = (options: SandboxOptions): void => {
|
||||||
before(async function (): Promise<void> {
|
before(async function (): Promise<void> {
|
||||||
|
console.time('before');
|
||||||
const sandbox = await mkdtemp(join(tmpdir(), 'puppeteer-'));
|
const sandbox = await mkdtemp(join(tmpdir(), 'puppeteer-'));
|
||||||
const dependencies = (options.dependencies ?? []).map(module => {
|
const dependencies = (options.dependencies ?? []).map(module => {
|
||||||
switch (module) {
|
switch (module) {
|
||||||
@ -125,13 +126,16 @@ export const configureSandbox = (options: SandboxOptions): void => {
|
|||||||
await writeFile(script, content);
|
await writeFile(script, content);
|
||||||
await execFile('node', [script], {cwd: sandbox, env});
|
await execFile('node', [script], {cwd: sandbox, env});
|
||||||
};
|
};
|
||||||
|
console.timeEnd('before');
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
console.time('after');
|
||||||
if (!process.env['KEEP_SANDBOX']) {
|
if (!process.env['KEEP_SANDBOX']) {
|
||||||
await rm(this.sandbox, {recursive: true, force: true, maxRetries: 5});
|
await rm(this.sandbox, {recursive: true, force: true, maxRetries: 5});
|
||||||
} else {
|
} else {
|
||||||
console.log('sandbox saved in', this.sandbox);
|
console.log('sandbox saved in', this.sandbox);
|
||||||
}
|
}
|
||||||
|
console.timeEnd('after');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user