chore(repo): enable windows nightly tests (#5889)

This commit is contained in:
Miroslav Jonaš 2021-06-18 21:16:50 +02:00 committed by GitHub
parent 0f4c18218e
commit b3c36dc067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 323 additions and 273 deletions

View File

@ -17,12 +17,17 @@ jobs:
matrix:
os:
- ubuntu-latest
# - windows-latest
- windows-latest
include:
- os: ubuntu-latest
os-name: ubuntu
# - os: windows-latest
# os-name: windows
- os: windows-latest
os-name: windows
exclude:
- os: windows-latest
package_manager: npm
- os: windows-latest
package_manager: yarn
node_version:
- '14'
# - '15'
@ -31,15 +36,15 @@ jobs:
- yarn
- pnpm
packages:
- e2e-workspace
- e2e-cli,e2e-nx-plugin,dep-graph-dep-graph-e2e
- e2e-cypress,e2e-jest
- e2e-react
- e2e-next
- e2e-gatsby
- e2e-node
- e2e-web,e2e-linter,e2e-storybook
- e2e-angular
- e2e-cli,e2e-nx-plugin,e2e-jest,e2e-linter,e2e-cypress
- e2e-cypress
- e2e-gatsby,e2e-react
- e2e-next
- e2e-node
- e2e-web
- e2e-storybook
- e2e-workspace
fail-fast: false
name: ${{ matrix.os-name }}/n v${{ matrix.node_version }}/${{ matrix.package_manager }} - ${{ matrix.packages }}
@ -63,7 +68,8 @@ jobs:
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ matrix.os }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ matrix.os }}-node-${{ matrix.node-version }}-yarn-
restore-keys: |
${{ matrix.os }}-node-${{ matrix.node-version }}-yarn-
- name: Install packages
run: yarn install --prefer-offline --non-interactive
@ -121,4 +127,4 @@ jobs:
mention_users: 'U01UELKLYF2'
mention_users_when: 'failure,warnings'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}

View File

@ -2,6 +2,7 @@ process.env.SELECTED_CLI = 'angular';
import {
checkFilesExist,
isNotWindows,
killPorts,
newProject,
readFile,
@ -56,19 +57,20 @@ describe('Storybook schematics', () => {
describe('build storybook', () => {
it('should execute e2e tests using Cypress running against Storybook', async () => {
const myapp = uniq('myapp');
runCLI(`generate @nrwl/angular:app ${myapp} --no-interactive`);
if (isNotWindows()) {
const myapp = uniq('myapp');
runCLI(`generate @nrwl/angular:app ${myapp} --no-interactive`);
const myAngularLib = uniq('test-ui-lib');
createTestUILib(myAngularLib);
const myReactLib = uniq('test-ui-lib-react');
runCLI(`generate @nrwl/react:lib ${myReactLib} --no-interactive`);
runCLI(
`generate @nrwl/react:component Button --project=${myReactLib} --no-interactive`
);
writeFileSync(
tmpProjPath(`libs/${myReactLib}/src/lib/button.tsx`),
`
const myAngularLib = uniq('test-ui-lib');
createTestUILib(myAngularLib);
const myReactLib = uniq('test-ui-lib-react');
runCLI(`generate @nrwl/react:lib ${myReactLib} --no-interactive`);
runCLI(
`generate @nrwl/react:component Button --project=${myReactLib} --no-interactive`
);
writeFileSync(
tmpProjPath(`libs/${myReactLib}/src/lib/button.tsx`),
`
import React from 'react';
import './button.css';
@ -92,10 +94,10 @@ describe('Storybook schematics', () => {
export default Button;
`
);
writeFileSync(
tmpProjPath(`libs/${myReactLib}/src/lib/button.stories.tsx`),
`
);
writeFileSync(
tmpProjPath(`libs/${myReactLib}/src/lib/button.stories.tsx`),
`
import React from 'react';
import { Button, ButtonStyle } from './button';
import { text, number } from '@storybook/addon-knobs';
@ -113,20 +115,20 @@ describe('Storybook schematics', () => {
/>
);
`
);
);
runCLI(
`generate @nrwl/angular:storybook-configuration ${myAngularLib} --configureCypress --generateStories --generateCypressSpecs --no-interactive`
);
runCLI(
`generate @nrwl/angular:stories ${myAngularLib} --generateCypressSpecs --no-interactive`
);
runCLI(
`generate @nrwl/angular:storybook-configuration ${myAngularLib} --configureCypress --generateStories --generateCypressSpecs --no-interactive`
);
runCLI(
`generate @nrwl/angular:stories ${myAngularLib} --generateCypressSpecs --no-interactive`
);
writeFileSync(
tmpProjPath(
`apps/${myAngularLib}-e2e/src/integration/test-button/test-button.component.spec.ts`
),
`
writeFileSync(
tmpProjPath(
`apps/${myAngularLib}-e2e/src/integration/test-button/test-button.component.spec.ts`
),
`
describe('${myAngularLib}', () => {
it('should render the component', () => {
@ -144,21 +146,21 @@ describe('Storybook schematics', () => {
});
});
`
);
);
runCLI(
`generate @nrwl/react:storybook-configuration ${myReactLib} --configureCypress --no-interactive`
);
runCLI(
`generate @nrwl/react:storybook-configuration ${myReactLib} --configureCypress --no-interactive`
);
// The following line (mkdirSync...) is not needed,
// since the above schematic creates this directory.
// So, if we leave it there, there's an error saying the directory exists.
// I am not sure how it worked as it was :/
// The following line (mkdirSync...) is not needed,
// since the above schematic creates this directory.
// So, if we leave it there, there's an error saying the directory exists.
// I am not sure how it worked as it was :/
// mkdirSync(tmpProjPath(`apps/${myReactLib}-e2e/src/integration`));
writeFileSync(
tmpProjPath(`apps/${myReactLib}-e2e/src/integration/button.spec.ts`),
`
// mkdirSync(tmpProjPath(`apps/${myReactLib}-e2e/src/integration`));
writeFileSync(
tmpProjPath(`apps/${myReactLib}-e2e/src/integration/button.spec.ts`),
`
describe('react-ui', () => {
it('should render the component', () => {
cy.visit(
@ -175,19 +177,20 @@ describe('Storybook schematics', () => {
});
});
`
);
);
expect(runCLI(`run ${myAngularLib}-e2e:e2e --no-watch`)).toContain(
'All specs passed!'
);
expect(runCLI(`run ${myAngularLib}-e2e:e2e --no-watch`)).toContain(
'All specs passed!'
);
runCLI(`run ${myAngularLib}:build-storybook`);
runCLI(`run ${myAngularLib}:build-storybook`);
checkFilesExist(`dist/storybook/${myAngularLib}/index.html`);
expect(readFile(`dist/storybook/${myAngularLib}/index.html`)).toContain(
`<title>Storybook</title>`
);
expect(await killPorts()).toBeTruthy();
checkFilesExist(`dist/storybook/${myAngularLib}/index.html`);
expect(readFile(`dist/storybook/${myAngularLib}/index.html`)).toContain(
`<title>Storybook</title>`
);
expect(await killPorts()).toBeTruthy();
}
}, 1000000);
xit('should build an Angular based storybook', () => {

View File

@ -1,6 +1,5 @@
import {
checkFilesExist,
killPorts,
newProject,
runCLI,
runCLIAsync,

View File

@ -2,6 +2,7 @@ import { stringUtils } from '@nrwl/workspace';
import {
checkFilesExist,
createFile,
isNotWindows,
killPorts,
newProject,
promisifiedTreeKill,
@ -345,7 +346,7 @@ describe('Next.js Applications', () => {
`dist/apps/${appName}/public/a/b.txt`,
`dist/apps/${appName}/public/shared/ui/hello.txt`
);
}, 120000);
}, 300000);
it('should build with a next.config.js file in the dist folder', async () => {
const appName = uniq('app');
@ -374,7 +375,7 @@ describe('Next.js Applications', () => {
checkFilesExist(`dist/apps/${appName}/next.config.js`);
expect(result).toContain('NODE_ENV is production');
}, 120000);
}, 300000);
it('should support --js flag', async () => {
const appName = uniq('app');
@ -458,31 +459,32 @@ describe('Next.js Applications', () => {
}, 120000);
it('webpack5 - should be able to consume a react libs (buildable and non-buildable)', async () => {
const appName = uniq('app');
const buildableLibName = uniq('lib');
const nonBuildableLibName = uniq('lib');
if (isNotWindows()) {
const appName = uniq('app');
const buildableLibName = uniq('lib');
const nonBuildableLibName = uniq('lib');
runCLI(`generate @nrwl/next:app ${appName} --no-interactive`);
runCLI(
`generate @nrwl/react:lib ${nonBuildableLibName} --no-interactive --style=none`
);
runCLI(
`generate @nrwl/react:lib ${buildableLibName} --no-interactive --style=none --buildable`
);
runCLI(`generate @nrwl/next:app ${appName} --no-interactive`);
runCLI(
`generate @nrwl/react:lib ${nonBuildableLibName} --no-interactive --style=none`
);
runCLI(
`generate @nrwl/react:lib ${buildableLibName} --no-interactive --style=none --buildable`
);
const mainPath = `apps/${appName}/pages/index.tsx`;
updateFile(
mainPath,
`
const mainPath = `apps/${appName}/pages/index.tsx`;
updateFile(
mainPath,
`
import '@${proj}/${nonBuildableLibName}';
import '@${proj}/${buildableLibName}';
${readFile(mainPath)}
`
);
// enable webpack 5
updateFile(
`apps/${appName}/next.config.js`,
`
);
// enable webpack 5
updateFile(
`apps/${appName}/next.config.js`,
`
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withNx = require('@nrwl/next/plugins/with-nx');
@ -497,32 +499,33 @@ describe('Next.js Applications', () => {
}
});
`
);
);
// Update non-buildable lib to use css modules to test that next.js can compile it
updateFile(
`libs/${nonBuildableLibName}/src/lib/${nonBuildableLibName}.tsx`,
`
// Update non-buildable lib to use css modules to test that next.js can compile it
updateFile(
`libs/${nonBuildableLibName}/src/lib/${nonBuildableLibName}.tsx`,
`
import styles from './style.module.css';
export function Test() {
return <div className={styles.container}>Hello</div>;
}
export default Test;
`
);
updateFile(
`libs/${nonBuildableLibName}/src/lib/style.module.css`,
`
);
updateFile(
`libs/${nonBuildableLibName}/src/lib/style.module.css`,
`
.container {}
`
);
);
await checkApp(appName, {
checkUnitTest: true,
checkLint: true,
checkE2E: true,
checkWebpack5: true,
});
await checkApp(appName, {
checkUnitTest: true,
checkLint: true,
checkE2E: true,
checkWebpack5: true,
});
}
}, 300000);
it('webpack5 - should build with a next.config.js file in the dist folder', async () => {
@ -566,29 +569,29 @@ describe('Next.js Applications', () => {
createFile(
'tools/custom-next-server.ts',
`
const express = require('express');
const path = require('path');
const express = require('express');
const path = require('path');
export default async function nextCustomServer(app, settings, proxyConfig) {
const handle = app.getRequestHandler();
await app.prepare();
export default async function nextCustomServer(app, settings, proxyConfig) {
const handle = app.getRequestHandler();
await app.prepare();
const x: string = 'custom typescript server running';
console.log(x);
const x: string = 'custom typescript server running';
console.log(x);
const server = express();
server.disable('x-powered-by');
const server = express();
server.disable('x-powered-by');
server.use(
express.static(path.resolve(settings.dir, settings.conf.outdir, 'public'))
);
server.use(
express.static(path.resolve(settings.dir, settings.conf.outdir, 'public'))
);
// Default catch-all handler to allow Next.js to handle all other routes
server.all('*', (req, res) => handle(req, res));
// Default catch-all handler to allow Next.js to handle all other routes
server.all('*', (req, res) => handle(req, res));
server.listen(settings.port, settings.hostname);
}
`
server.listen(settings.port, settings.hostname);
}
`
);
updateWorkspaceConfig((workspace) => {

View File

@ -54,7 +54,7 @@ describe('Node Applications', () => {
cwd: tmpProjPath(),
}).toString();
expect(result).toContain('Hello World!');
}, 60000);
}, 300000);
xit('should be able to generate an express application', async () => {
const nodeapp = uniq('nodeapp');

View File

@ -1,12 +1,12 @@
import {
checkFilesExist,
expectTestsPass,
isNotWindows,
killPorts,
newProject,
readJson,
runCLI,
runCLIAsync,
runCypressTests,
uniq,
workspaceConfigName,
} from '@nrwl/e2e/utils';
@ -60,7 +60,7 @@ describe('Nx Plugin', () => {
const plugin = uniq('plugin-name');
runCLI(`generate @nrwl/nx-plugin:plugin ${plugin} --linter=eslint`);
if (runCypressTests()) {
if (isNotWindows()) {
const e2eResults = runCLI(`e2e ${plugin}-e2e --no-watch --headless`);
expect(e2eResults).toContain('Running target "e2e" succeeded');
expect(await killPorts()).toBeTruthy();

View File

@ -16,6 +16,7 @@ import isCI = require('is-ci');
import * as path from 'path';
import { dirSync } from 'tmp';
const kill = require('kill-port');
const isWindows = require('is-windows');
import { check as portCheck } from 'tcp-port-used';
import { parseJson } from '@nrwl/devkit';
import chalk = require('chalk');
@ -119,8 +120,7 @@ export function packageInstall(pkg: string, projName?: string) {
const pm = getPackageManagerCommand({ path: cwd });
const install = execSync(`${pm.addDev} ${pkg}`, {
cwd,
// ...{ stdio: ['pipe', 'pipe', 'pipe'] },
...{ stdio: [0, 1, 2] },
stdio: [0, 1, 2],
env: process.env,
encoding: 'utf-8',
});
@ -189,8 +189,7 @@ export function newProject({ name = uniq('proj') } = {}): string {
}
return projScope;
} catch (e) {
console.log(`Failed to set up project for e2e tests.`);
console.log(e.message);
logError(`Failed to set up project for e2e tests.`, e.message);
throw e;
}
}
@ -240,6 +239,10 @@ export function runCypressTests() {
return true;
}
export function isNotWindows() {
return !isWindows();
}
export function runCommandAsync(
command: string,
opts: RunCmdOpts = {
@ -346,7 +349,10 @@ export function runNgAdd(
if (opts.silenceError) {
return e.stdout.toString();
} else {
console.log(e.stdout.toString(), e.stderr.toString());
logError(
`Ng Add failed: ${command}`,
`${e.stdout?.toString()}\n\n${e.stderr?.toString()}`
);
throw e;
}
}
@ -372,8 +378,7 @@ export function runCLI(
''
);
if (process.env.VERBOSE_OUTPUT) {
console.log('result of running:', command);
console.log(r);
logInfo(`result of running: ${command}`, r);
}
const needsMaxWorkers = /g.*(express|nest|node|web|react):app.*/;
@ -384,10 +389,12 @@ export function runCLI(
return r;
} catch (e) {
if (opts.silenceError) {
return e.stdout.toString() + e.stderr?.toString();
return e.stdout?.toString() + e.stderr?.toString();
} else {
console.log('original command', command);
console.log(e.stdout?.toString(), e.stderr?.toString());
logError(
`Original command: ${command}`,
`${e.stdout?.toString()}\n\n${e.stderr?.toString()}`
);
throw e;
}
}
@ -415,6 +422,8 @@ export function runCommand(command: string): string {
}
return r;
} catch (e) {
// this is intentional
// npm ls fails if package is not found
return e.stdout.toString() + e.stderr.toString();
}
}
@ -567,9 +576,9 @@ export function logInfo(title: string, body?: string) {
}
export function logError(title: string, body?: string) {
const message = `${chalk.reset.inverse.bold.green(
' ERROR '
)} ${chalk.bold.red(title)}`;
const message = `${chalk.reset.inverse.bold.red(' ERROR ')} ${chalk.bold.red(
title
)}`;
return e2eConsoleLogger(message, body);
}

View File

@ -2,6 +2,7 @@ import {
checkFilesDoNotExist,
checkFilesExist,
createFile,
isNotWindows,
killPorts,
newProject,
readFile,
@ -52,7 +53,7 @@ describe('Web Components Applications', () => {
const lintE2eResults = runCLI(`lint ${appName}-e2e`);
expect(lintE2eResults).toContain('All files pass linting.');
if (runCypressTests()) {
if (isNotWindows()) {
const e2eResults = runCLI(`e2e ${appName}-e2e --headless`);
expect(e2eResults).toContain('All specs passed!');
expect(await killPorts()).toBeTruthy();

View File

@ -2,6 +2,7 @@ import * as path from 'path';
import {
checkFilesExist,
exists,
isNotWindows,
newProject,
readFile,
readJson,
@ -116,128 +117,132 @@ describe('lint', () => {
describe('format', () => {
it('should check and reformat the code', async () => {
const myapp = uniq('myapp');
const mylib = uniq('mylib');
if (isNotWindows()) {
const myapp = uniq('myapp');
const mylib = uniq('mylib');
runCLI(`generate @nrwl/angular:app ${myapp}`);
runCLI(`generate @nrwl/angular:lib ${mylib}`);
updateFile(
`apps/${myapp}/src/main.ts`,
`
runCLI(`generate @nrwl/angular:app ${myapp}`);
runCLI(`generate @nrwl/angular:lib ${mylib}`);
updateFile(
`apps/${myapp}/src/main.ts`,
`
const x = 1111;
`
);
);
updateFile(
`apps/${myapp}/src/app/app.module.ts`,
`
updateFile(
`apps/${myapp}/src/app/app.module.ts`,
`
const y = 1111;
`
);
);
updateFile(
`apps/${myapp}/src/app/app.component.ts`,
`
updateFile(
`apps/${myapp}/src/app/app.component.ts`,
`
const z = 1111;
`
);
);
updateFile(
`libs/${mylib}/index.ts`,
`
updateFile(
`libs/${mylib}/index.ts`,
`
const x = 1111;
`
);
updateFile(
`libs/${mylib}/src/${mylib}.module.ts`,
`
);
updateFile(
`libs/${mylib}/src/${mylib}.module.ts`,
`
const y = 1111;
`
);
);
updateFile(
`README.md`,
`
updateFile(
`README.md`,
`
my new readme;
`
);
);
let stdout = runCLI(
`format:check --files="libs/${mylib}/index.ts,package.json" --libs-and-apps`,
{ silenceError: true }
);
expect(stdout).toContain(path.normalize(`libs/${mylib}/index.ts`));
expect(stdout).toContain(
path.normalize(`libs/${mylib}/src/${mylib}.module.ts`)
);
expect(stdout).not.toContain(path.normalize(`README.md`)); // It will be contained only in case of exception, that we fallback to all
let stdout = runCLI(
`format:check --files="libs/${mylib}/index.ts,package.json" --libs-and-apps`,
{ silenceError: true }
);
expect(stdout).toContain(path.normalize(`libs/${mylib}/index.ts`));
expect(stdout).toContain(
path.normalize(`libs/${mylib}/src/${mylib}.module.ts`)
);
expect(stdout).not.toContain(path.normalize(`README.md`)); // It will be contained only in case of exception, that we fallback to all
stdout = runCLI(`format:check --all`, { silenceError: true });
expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`));
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`)
);
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.component.ts`)
);
stdout = runCLI(`format:check --all`, { silenceError: true });
expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`));
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`)
);
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.component.ts`)
);
stdout = runCLI(`format:check --projects=${myapp}`, { silenceError: true });
expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`));
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`)
);
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.component.ts`)
);
expect(stdout).not.toContain(path.normalize(`libs/${mylib}/index.ts`));
expect(stdout).not.toContain(
path.normalize(`libs/${mylib}/src/${mylib}.module.ts`)
);
expect(stdout).not.toContain(path.normalize(`README.md`));
stdout = runCLI(`format:check --projects=${myapp},${mylib}`, {
silenceError: true,
});
expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`));
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`)
);
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.component.ts`)
);
expect(stdout).toContain(path.normalize(`libs/${mylib}/index.ts`));
expect(stdout).toContain(
path.normalize(`libs/${mylib}/src/${mylib}.module.ts`)
);
expect(stdout).not.toContain(path.normalize(`README.md`));
const { stderr } = await runCLIAsync(
`format:check --projects=${myapp},${mylib} --all`,
{
stdout = runCLI(`format:check --projects=${myapp}`, {
silenceError: true,
}
);
expect(stderr).toContain(
'Arguments all and projects are mutually exclusive'
);
});
expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`));
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`)
);
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.component.ts`)
);
expect(stdout).not.toContain(path.normalize(`libs/${mylib}/index.ts`));
expect(stdout).not.toContain(
path.normalize(`libs/${mylib}/src/${mylib}.module.ts`)
);
expect(stdout).not.toContain(path.normalize(`README.md`));
runCLI(
`format:write --files="apps/${myapp}/src/app/app.module.ts,apps/${myapp}/src/app/app.component.ts"`
);
stdout = runCLI(`format:check --projects=${myapp},${mylib}`, {
silenceError: true,
});
expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`));
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`)
);
expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.component.ts`)
);
expect(stdout).toContain(path.normalize(`libs/${mylib}/index.ts`));
expect(stdout).toContain(
path.normalize(`libs/${mylib}/src/${mylib}.module.ts`)
);
expect(stdout).not.toContain(path.normalize(`README.md`));
stdout = runCLI('format:check --all', { silenceError: true });
expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`));
expect(stdout).not.toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`)
);
expect(stdout).not.toContain(
path.normalize(`apps/${myapp}/src/app/app.component.ts`)
);
const { stderr } = await runCLIAsync(
`format:check --projects=${myapp},${mylib} --all`,
{
silenceError: true,
}
);
expect(stderr).toContain(
'Arguments all and projects are mutually exclusive'
);
runCLI('format:write --all');
expect(runCLI('format:check --all')).not.toContain(
path.normalize(`apps/${myapp}/src/main.ts`)
);
runCLI(
`format:write --files="apps/${myapp}/src/app/app.module.ts,apps/${myapp}/src/app/app.component.ts"`
);
stdout = runCLI('format:check --all', { silenceError: true });
expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`));
expect(stdout).not.toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`)
);
expect(stdout).not.toContain(
path.normalize(`apps/${myapp}/src/app/app.component.ts`)
);
runCLI('format:write --all');
expect(runCLI('format:check --all')).not.toContain(
path.normalize(`apps/${myapp}/src/main.ts`)
);
}
}, 90000);
});

View File

@ -2,6 +2,7 @@ import type { NxJsonConfiguration } from '@nrwl/devkit';
import {
getPackageManagerCommand,
getSelectedPackageManager,
isNotWindows,
listFiles,
newProject,
readFile,
@ -468,14 +469,15 @@ describe('affected:*', () => {
});
describe('affected (with git)', () => {
let myapp = uniq('myapp');
let myapp2 = uniq('myapp');
let mylib = uniq('mylib');
let myapp;
let myapp2;
let mylib;
beforeAll(() => newProject());
afterAll(() => removeProject({ onlyOnCI: true }));
it('should not affect other projects by generating a new project', () => {
beforeEach(() => {
myapp = uniq('myapp');
myapp2 = uniq('myapp');
mylib = uniq('mylib');
newProject();
const nxJson: NxJsonConfiguration = readJson('nx.json');
delete nxJson.implicitDependencies;
@ -487,57 +489,78 @@ describe('affected (with git)', () => {
runCommand(
`git add . && git commit -am "initial commit" && git checkout -b master`
);
});
afterAll(() => removeProject({ onlyOnCI: true }));
function generateAll() {
runCLI(`generate @nrwl/angular:app ${myapp}`);
expect(runCLI('affected:apps')).toContain(myapp);
runCommand(`git add . && git commit -am "add ${myapp}"`);
runCLI(`generate @nrwl/angular:app ${myapp2}`);
expect(runCLI('affected:apps')).not.toContain(myapp);
expect(runCLI('affected:apps')).toContain(myapp2);
runCommand(`git add . && git commit -am "add ${myapp2}"`);
runCLI(`generate @nrwl/angular:lib ${mylib}`);
expect(runCLI('affected:apps')).not.toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).toContain(mylib);
runCommand(`git add . && git commit -am "add ${mylib}"`);
runCommand(`git add . && git commit -am "add all"`);
}
it('should not affect other projects by generating a new project', () => {
// TODO: investigate why affected gives different results on windows
if (isNotWindows()) {
runCLI(`generate @nrwl/angular:app ${myapp}`);
expect(runCLI('affected:apps')).toContain(myapp);
runCommand(`git add . && git commit -am "add ${myapp}"`);
runCLI(`generate @nrwl/angular:app ${myapp2}`);
expect(runCLI('affected:apps')).not.toContain(myapp);
expect(runCLI('affected:apps')).toContain(myapp2);
runCommand(`git add . && git commit -am "add ${myapp2}"`);
runCLI(`generate @nrwl/angular:lib ${mylib}`);
expect(runCLI('affected:apps')).not.toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).toContain(mylib);
}
}, 1000000);
it('should detect changes to projects based on the nx.json', () => {
const nxJson: NxJsonConfiguration = readJson('nx.json');
// TODO: investigate why affected gives different results on windows
if (isNotWindows()) {
generateAll();
const nxJson: NxJsonConfiguration = readJson('nx.json');
nxJson.projects[myapp].tags = ['tag'];
updateFile('nx.json', JSON.stringify(nxJson));
expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib);
runCommand(`git add . && git commit -am "add tag to ${myapp}"`);
nxJson.projects[myapp].tags = ['tag'];
updateFile('nx.json', JSON.stringify(nxJson));
expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib);
}
});
it('should detect changes to projects based on the workspace.json', () => {
const workspaceJson = readJson(workspaceConfigName());
// TODO: investigate why affected gives different results on windows
if (isNotWindows()) {
generateAll();
const workspaceJson = readJson(workspaceConfigName());
workspaceJson.projects[myapp].prefix = 'my-app';
updateFile(workspaceConfigName(), JSON.stringify(workspaceJson));
expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib);
runCommand(`git add . && git commit -am "change prefix for ${myapp}"`);
workspaceJson.projects[myapp].prefix = 'my-app';
updateFile(workspaceConfigName(), JSON.stringify(workspaceJson));
expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib);
}
});
it('should affect all projects by removing projects', () => {
generateAll();
const workspaceJson = readJson(workspaceConfigName());
const nxJson = readJson('nx.json');
delete workspaceJson.projects[mylib];
updateFile(workspaceConfigName(), JSON.stringify(workspaceJson));
const nxJson = readJson('nx.json');
delete nxJson.projects[mylib];
updateFile('nx.json', JSON.stringify(nxJson));
expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib);
runCommand(`git add . && git commit -am "remove ${mylib}"`);
});
});

View File

@ -153,6 +153,7 @@
"import-fresh": "^3.1.0",
"injection-js": "^2.4.0",
"is-ci": "^3.0.0",
"is-windows": "^1.0.2",
"jasmine-core": "~2.99.1",
"jasmine-marbles": "~0.6.0",
"jasmine-spec-reporter": "~4.2.1",

View File

@ -48,7 +48,7 @@ export async function conversionGenerator(
if (projectConfig.projectType === 'application') {
await addLintingToApplication(host, {
linter: 'eslint' as any,
linter: 'eslint',
name: projectName,
appProjectRoot: projectConfig.root,
js,

View File

@ -13,7 +13,7 @@ describe('<%= pluginName %> e2e', () => {
const result = await runNxCommandAsync(`build ${plugin}`);
expect(result.stdout).toContain('Executor ran');
}, 30000)
}, 120000)
describe('--directory', () => {
it('should create src in the specified directory', async () => {
@ -23,7 +23,7 @@ describe('<%= pluginName %> e2e', () => {
`generate <%=npmPackageName%>:<%= pluginName %> ${plugin} --directory subdir`
);
expect(() => checkFilesExist(`libs/subdir/${plugin}/src/index.ts`)).not.toThrow();
}, 30000);
}, 120000);
});
describe('--tags', () => {
@ -35,6 +35,6 @@ describe('<%= pluginName %> e2e', () => {
);
const nxJson = readJson('nx.json');
expect(nxJson.projects[plugin].tags).toEqual(['e2etag', 'e2ePackage']);
}, 30000);
}, 120000);
});
})
})