mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: ng-schematics install Windows (#11487)
This commit is contained in:
parent
7cead042c9
commit
02af7482d9
38
.github/workflows/ci.yml
vendored
38
.github/workflows/ci.yml
vendored
@ -442,6 +442,44 @@ jobs:
|
||||
- name: Run tests
|
||||
run: npm run test --workspace @puppeteer/ng-schematics
|
||||
|
||||
ng-schematics-smoke-tests:
|
||||
name: Angular Schematics smoke tests on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: check-changes
|
||||
if: ${{ contains(fromJSON(needs.check-changes.outputs.changes), 'ng-schematics') }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
- macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
|
||||
with:
|
||||
cache: npm
|
||||
node-version: lts/*
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
env:
|
||||
PUPPETEER_SKIP_DOWNLOAD: true
|
||||
- name: Run tests
|
||||
run: npm run test:smoke
|
||||
working-directory: ./packages/ng-schematics
|
||||
|
||||
ng-schematics-smoke-tests-required:
|
||||
name: '[Required] Angular Schematics smoke tests'
|
||||
needs: [check-changes, ng-schematics-smoke-tests]
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ always() }}
|
||||
steps:
|
||||
- if: ${{ needs.ng-schematics-smoke-tests.result != 'success' && contains(fromJSON(needs.check-changes.outputs.changes), 'ng-schematics') }}
|
||||
run: 'exit 1'
|
||||
- run: 'exit 0'
|
||||
|
||||
browsers-tests:
|
||||
name: Browsers tests on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
@ -16,6 +16,6 @@
|
||||
|
||||
export const testChromeBuildId = '113.0.5672.0';
|
||||
export const testChromiumBuildId = '1083080';
|
||||
export const testFirefoxBuildId = '121.0a1';
|
||||
export const testFirefoxBuildId = '122.0a1';
|
||||
export const testChromeDriverBuildId = '115.0.5763.0';
|
||||
export const testChromeHeadlessShellBuildId = '118.0.5950.0';
|
||||
|
@ -31,9 +31,9 @@ ng e2e
|
||||
|
||||
When adding schematics to your project you can to provide following options:
|
||||
|
||||
| Option | Description | Value | Required |
|
||||
| -------------- | ------------------------------------------------------ | ------------------------------------------ | -------- |
|
||||
| `--testRunner` | The testing framework to install along side Puppeteer. | `"jasmine"`, `"jest"`, `"mocha"`, `"node"` | `true` |
|
||||
| Option | Description | Value | Required |
|
||||
| --------------- | ------------------------------------------------------ | ------------------------------------------ | -------- |
|
||||
| `--test-runner` | The testing framework to install along side Puppeteer. | `"jasmine"`, `"jest"`, `"mocha"`, `"node"` | `true` |
|
||||
|
||||
## Creating a single test file
|
||||
|
||||
|
@ -9,7 +9,8 @@
|
||||
"dev": "npm run build --watch",
|
||||
"sandbox:test": "node tools/sandbox.js --test",
|
||||
"sandbox": "node tools/sandbox.js",
|
||||
"test": "wireit"
|
||||
"test": "wireit",
|
||||
"test:smoke": "wireit"
|
||||
},
|
||||
"wireit": {
|
||||
"build": {
|
||||
@ -31,6 +32,12 @@
|
||||
"dependencies": [
|
||||
"build"
|
||||
]
|
||||
},
|
||||
"test:smoke": {
|
||||
"command": "node ./tools/smoke.mjs",
|
||||
"dependencies": [
|
||||
"build"
|
||||
]
|
||||
}
|
||||
},
|
||||
"keywords": [
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {spawn} from 'child_process';
|
||||
import {normalize, join} from 'path';
|
||||
|
||||
import {
|
||||
createBuilder,
|
||||
@ -69,7 +70,7 @@ function updateExecutablePath(command: string, root?: string) {
|
||||
path = `./${path}${command}`;
|
||||
}
|
||||
|
||||
return path;
|
||||
return normalize(path);
|
||||
}
|
||||
|
||||
async function executeCommand(context: BuilderContext, command: string[]) {
|
||||
@ -84,12 +85,13 @@ async function executeCommand(context: BuilderContext, command: string[]) {
|
||||
const {executable, args, debugError, error} = getExecutable(command);
|
||||
let path = context.workspaceRoot;
|
||||
if (context.target) {
|
||||
path = `${path}/${project['root']}`;
|
||||
path = join(path, (project['root'] as string | undefined) ?? '');
|
||||
}
|
||||
|
||||
const child = spawn(executable, args, {
|
||||
cwd: path,
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
});
|
||||
|
||||
child.on('error', message => {
|
||||
|
@ -19,11 +19,6 @@ import {readFile, writeFile} from 'fs/promises';
|
||||
import {join} from 'path';
|
||||
import {cwd} from 'process';
|
||||
|
||||
const isInit = process.argv.indexOf('--init') !== -1;
|
||||
const isMulti = process.argv.indexOf('--multi') !== -1;
|
||||
const isBuild = process.argv.indexOf('--build') !== -1;
|
||||
const isE2E = process.argv.indexOf('--e2e') !== -1;
|
||||
const isConfig = process.argv.indexOf('--config') !== -1;
|
||||
const commands = {
|
||||
build: ['npm run build'],
|
||||
createSandbox: ['npx ng new sandbox --defaults'],
|
||||
@ -44,30 +39,55 @@ const commands = {
|
||||
},
|
||||
},
|
||||
],
|
||||
runSchematics: [
|
||||
{
|
||||
command: 'npm run schematics',
|
||||
options: {
|
||||
cwd: join(cwd(), '/sandbox/'),
|
||||
/**
|
||||
* @param {Boolean} isMulti
|
||||
*/
|
||||
runSchematics: isMulti => {
|
||||
return [
|
||||
{
|
||||
command: 'npm run schematics',
|
||||
options: {
|
||||
cwd: join(cwd(), isMulti ? '/multi/' : '/sandbox/'),
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
runSchematicsE2E: [
|
||||
{
|
||||
command: 'npm run schematics:e2e',
|
||||
options: {
|
||||
cwd: join(cwd(), '/sandbox/'),
|
||||
];
|
||||
},
|
||||
/**
|
||||
* @param {Boolean} isMulti
|
||||
*/
|
||||
runSchematicsE2E: isMulti => {
|
||||
return [
|
||||
{
|
||||
command: 'npm run schematics:e2e',
|
||||
options: {
|
||||
cwd: join(cwd(), isMulti ? '/multi/' : '/sandbox/'),
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
runSchematicsConfig: [
|
||||
{
|
||||
command: 'npm run schematics:config',
|
||||
options: {
|
||||
cwd: join(cwd(), '/sandbox/'),
|
||||
];
|
||||
},
|
||||
/**
|
||||
* @param {Boolean} isMulti
|
||||
*/
|
||||
runSchematicsConfig: isMulti => {
|
||||
return [
|
||||
{
|
||||
command: 'npm run schematics:config',
|
||||
options: {
|
||||
cwd: join(cwd(), isMulti ? '/multi/' : '/sandbox/'),
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
];
|
||||
},
|
||||
runSchematicsSmoke: isMulti => {
|
||||
return [
|
||||
{
|
||||
command: 'npm run schematics:smoke',
|
||||
options: {
|
||||
cwd: join(cwd(), isMulti ? '/multi/' : '/sandbox/'),
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
const scripts = {
|
||||
// Builds the ng-schematics before running them
|
||||
@ -76,12 +96,11 @@ const scripts = {
|
||||
'delete:file':
|
||||
'rm -f .puppeteerrc.cjs && rm -f tsconfig.e2e.json && rm -R -f e2e/',
|
||||
// Runs the Puppeteer Ng-Schematics against the sandbox
|
||||
schematics:
|
||||
'npm run delete:file && npm run build:schematics && schematics ../:ng-add --dry-run=false',
|
||||
'schematics:e2e':
|
||||
'npm run build:schematics && schematics ../:e2e --dry-run=false',
|
||||
'schematics:config':
|
||||
'npm run build:schematics && schematics ../:config --dry-run=false',
|
||||
schematics: 'schematics ../:ng-add --dry-run=false',
|
||||
'schematics:e2e': 'schematics ../:e2e --dry-run=false',
|
||||
'schematics:config': 'schematics ../:config --dry-run=false',
|
||||
'schematics:smoke':
|
||||
'schematics ../:ng-add --dry-run=false --test-runner="node" && ng e2e',
|
||||
};
|
||||
/**
|
||||
*
|
||||
@ -123,7 +142,18 @@ async function executeCommand(commands) {
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
/**
|
||||
*
|
||||
* @param {*} param0
|
||||
*/
|
||||
export async function runNgSchematicsSandbox({
|
||||
isInit,
|
||||
isMulti,
|
||||
isBuild,
|
||||
isE2E,
|
||||
isConfig,
|
||||
isSmoke,
|
||||
}) {
|
||||
if (isInit) {
|
||||
if (isMulti) {
|
||||
await executeCommand(commands.createMultiWorkspace);
|
||||
@ -133,7 +163,6 @@ async function main() {
|
||||
}
|
||||
|
||||
const directory = isMulti ? 'multi' : 'sandbox';
|
||||
|
||||
const packageJsonFile = join(cwd(), `/${directory}/package.json`);
|
||||
const packageJson = JSON.parse(await readFile(packageJsonFile));
|
||||
packageJson['scripts'] = {
|
||||
@ -146,16 +175,35 @@ async function main() {
|
||||
await executeCommand(commands.build);
|
||||
}
|
||||
if (isE2E) {
|
||||
await executeCommand(commands.runSchematicsE2E);
|
||||
await executeCommand(commands.runSchematicsE2E(isMulti));
|
||||
} else if (isConfig) {
|
||||
await executeCommand(commands.runSchematicsConfig);
|
||||
await executeCommand(commands.runSchematicsConfig(isMulti));
|
||||
} else if (isSmoke) {
|
||||
await executeCommand(commands.runSchematicsSmoke(isMulti));
|
||||
} else {
|
||||
await executeCommand(commands.runSchematics);
|
||||
await executeCommand(commands.runSchematics(isMulti));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(error => {
|
||||
console.log('Something went wrong');
|
||||
console.error(error);
|
||||
});
|
||||
async function main() {
|
||||
const options = {
|
||||
isInit: process.argv.indexOf('--init') !== -1,
|
||||
isMulti: process.argv.indexOf('--multi') !== -1,
|
||||
isBuild: process.argv.indexOf('--build') !== -1,
|
||||
isE2E: process.argv.indexOf('--e2e') !== -1,
|
||||
isConfig: process.argv.indexOf('--config') !== -1,
|
||||
};
|
||||
const isShell = Object.values(options).some(value => {
|
||||
return value;
|
||||
});
|
||||
|
||||
if (isShell) {
|
||||
await runNgSchematicsSandbox(getOptions()).catch(error => {
|
||||
console.log('Something went wrong');
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
27
packages/ng-schematics/tools/smoke.mjs
Normal file
27
packages/ng-schematics/tools/smoke.mjs
Normal file
@ -0,0 +1,27 @@
|
||||
import {execSync} from 'child_process';
|
||||
|
||||
import {runNgSchematicsSandbox} from './sandbox.mjs';
|
||||
|
||||
if (process.env.CI) {
|
||||
execSync('npm install -g @angular/cli@latest');
|
||||
execSync('npm install -g @angular-devkit/schematics-cli');
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
runNgSchematicsSandbox({
|
||||
isInit: true,
|
||||
}),
|
||||
runNgSchematicsSandbox({
|
||||
isInit: true,
|
||||
isMulti: true,
|
||||
}),
|
||||
]);
|
||||
|
||||
await runNgSchematicsSandbox({
|
||||
isSmoke: true,
|
||||
});
|
||||
|
||||
await runNgSchematicsSandbox({
|
||||
isMulti: true,
|
||||
isSmoke: true,
|
||||
});
|
Loading…
Reference in New Issue
Block a user