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: matrix:
os: os:
- ubuntu-latest - ubuntu-latest
# - windows-latest - windows-latest
include: include:
- os: ubuntu-latest - os: ubuntu-latest
os-name: ubuntu os-name: ubuntu
# - os: windows-latest - os: windows-latest
# os-name: windows os-name: windows
exclude:
- os: windows-latest
package_manager: npm
- os: windows-latest
package_manager: yarn
node_version: node_version:
- '14' - '14'
# - '15' # - '15'
@ -31,15 +36,15 @@ jobs:
- yarn - yarn
- pnpm - pnpm
packages: 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-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 fail-fast: false
name: ${{ matrix.os-name }}/n v${{ matrix.node_version }}/${{ matrix.package_manager }} - ${{ matrix.packages }} name: ${{ matrix.os-name }}/n v${{ matrix.node_version }}/${{ matrix.package_manager }} - ${{ matrix.packages }}
@ -63,7 +68,8 @@ jobs:
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ matrix.os }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('yarn.lock') }} 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 - name: Install packages
run: yarn install --prefer-offline --non-interactive run: yarn install --prefer-offline --non-interactive

View File

@ -2,6 +2,7 @@ process.env.SELECTED_CLI = 'angular';
import { import {
checkFilesExist, checkFilesExist,
isNotWindows,
killPorts, killPorts,
newProject, newProject,
readFile, readFile,
@ -56,6 +57,7 @@ describe('Storybook schematics', () => {
describe('build storybook', () => { describe('build storybook', () => {
it('should execute e2e tests using Cypress running against Storybook', async () => { it('should execute e2e tests using Cypress running against Storybook', async () => {
if (isNotWindows()) {
const myapp = uniq('myapp'); const myapp = uniq('myapp');
runCLI(`generate @nrwl/angular:app ${myapp} --no-interactive`); runCLI(`generate @nrwl/angular:app ${myapp} --no-interactive`);
@ -188,6 +190,7 @@ describe('Storybook schematics', () => {
`<title>Storybook</title>` `<title>Storybook</title>`
); );
expect(await killPorts()).toBeTruthy(); expect(await killPorts()).toBeTruthy();
}
}, 1000000); }, 1000000);
xit('should build an Angular based storybook', () => { xit('should build an Angular based storybook', () => {

View File

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

View File

@ -2,6 +2,7 @@ import { stringUtils } from '@nrwl/workspace';
import { import {
checkFilesExist, checkFilesExist,
createFile, createFile,
isNotWindows,
killPorts, killPorts,
newProject, newProject,
promisifiedTreeKill, promisifiedTreeKill,
@ -345,7 +346,7 @@ describe('Next.js Applications', () => {
`dist/apps/${appName}/public/a/b.txt`, `dist/apps/${appName}/public/a/b.txt`,
`dist/apps/${appName}/public/shared/ui/hello.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 () => { it('should build with a next.config.js file in the dist folder', async () => {
const appName = uniq('app'); const appName = uniq('app');
@ -374,7 +375,7 @@ describe('Next.js Applications', () => {
checkFilesExist(`dist/apps/${appName}/next.config.js`); checkFilesExist(`dist/apps/${appName}/next.config.js`);
expect(result).toContain('NODE_ENV is production'); expect(result).toContain('NODE_ENV is production');
}, 120000); }, 300000);
it('should support --js flag', async () => { it('should support --js flag', async () => {
const appName = uniq('app'); const appName = uniq('app');
@ -458,6 +459,7 @@ describe('Next.js Applications', () => {
}, 120000); }, 120000);
it('webpack5 - should be able to consume a react libs (buildable and non-buildable)', async () => { it('webpack5 - should be able to consume a react libs (buildable and non-buildable)', async () => {
if (isNotWindows()) {
const appName = uniq('app'); const appName = uniq('app');
const buildableLibName = uniq('lib'); const buildableLibName = uniq('lib');
const nonBuildableLibName = uniq('lib'); const nonBuildableLibName = uniq('lib');
@ -523,6 +525,7 @@ describe('Next.js Applications', () => {
checkE2E: true, checkE2E: true,
checkWebpack5: true, checkWebpack5: true,
}); });
}
}, 300000); }, 300000);
it('webpack5 - should build with a next.config.js file in the dist folder', async () => { it('webpack5 - should build with a next.config.js file in the dist folder', async () => {

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,7 @@ import * as path from 'path';
import { import {
checkFilesExist, checkFilesExist,
exists, exists,
isNotWindows,
newProject, newProject,
readFile, readFile,
readJson, readJson,
@ -116,6 +117,7 @@ describe('lint', () => {
describe('format', () => { describe('format', () => {
it('should check and reformat the code', async () => { it('should check and reformat the code', async () => {
if (isNotWindows()) {
const myapp = uniq('myapp'); const myapp = uniq('myapp');
const mylib = uniq('mylib'); const mylib = uniq('mylib');
@ -181,7 +183,9 @@ describe('format', () => {
path.normalize(`apps/${myapp}/src/app/app.component.ts`) path.normalize(`apps/${myapp}/src/app/app.component.ts`)
); );
stdout = runCLI(`format:check --projects=${myapp}`, { silenceError: true }); 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/main.ts`));
expect(stdout).toContain( expect(stdout).toContain(
path.normalize(`apps/${myapp}/src/app/app.module.ts`) path.normalize(`apps/${myapp}/src/app/app.module.ts`)
@ -238,6 +242,7 @@ describe('format', () => {
expect(runCLI('format:check --all')).not.toContain( expect(runCLI('format:check --all')).not.toContain(
path.normalize(`apps/${myapp}/src/main.ts`) path.normalize(`apps/${myapp}/src/main.ts`)
); );
}
}, 90000); }, 90000);
}); });

View File

@ -2,6 +2,7 @@ import type { NxJsonConfiguration } from '@nrwl/devkit';
import { import {
getPackageManagerCommand, getPackageManagerCommand,
getSelectedPackageManager, getSelectedPackageManager,
isNotWindows,
listFiles, listFiles,
newProject, newProject,
readFile, readFile,
@ -468,14 +469,15 @@ describe('affected:*', () => {
}); });
describe('affected (with git)', () => { describe('affected (with git)', () => {
let myapp = uniq('myapp'); let myapp;
let myapp2 = uniq('myapp'); let myapp2;
let mylib = uniq('mylib'); let mylib;
beforeAll(() => newProject()); beforeEach(() => {
afterAll(() => removeProject({ onlyOnCI: true })); myapp = uniq('myapp');
myapp2 = uniq('myapp');
it('should not affect other projects by generating a new project', () => { mylib = uniq('mylib');
newProject();
const nxJson: NxJsonConfiguration = readJson('nx.json'); const nxJson: NxJsonConfiguration = readJson('nx.json');
delete nxJson.implicitDependencies; delete nxJson.implicitDependencies;
@ -487,6 +489,19 @@ describe('affected (with git)', () => {
runCommand( runCommand(
`git add . && git commit -am "initial commit" && git checkout -b master` `git add . && git commit -am "initial commit" && git checkout -b master`
); );
});
afterAll(() => removeProject({ onlyOnCI: true }));
function generateAll() {
runCLI(`generate @nrwl/angular:app ${myapp}`);
runCLI(`generate @nrwl/angular:app ${myapp2}`);
runCLI(`generate @nrwl/angular:lib ${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}`); runCLI(`generate @nrwl/angular:app ${myapp}`);
expect(runCLI('affected:apps')).toContain(myapp); expect(runCLI('affected:apps')).toContain(myapp);
runCommand(`git add . && git commit -am "add ${myapp}"`); runCommand(`git add . && git commit -am "add ${myapp}"`);
@ -500,44 +515,52 @@ describe('affected (with git)', () => {
expect(runCLI('affected:apps')).not.toContain(myapp); expect(runCLI('affected:apps')).not.toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2); expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).toContain(mylib); expect(runCLI('affected:libs')).toContain(mylib);
runCommand(`git add . && git commit -am "add ${mylib}"`); }
}, 1000000); }, 1000000);
it('should detect changes to projects based on the nx.json', () => { it('should detect changes to projects based on the nx.json', () => {
// TODO: investigate why affected gives different results on windows
if (isNotWindows()) {
generateAll();
const nxJson: NxJsonConfiguration = readJson('nx.json'); const nxJson: NxJsonConfiguration = readJson('nx.json');
nxJson.projects[myapp].tags = ['tag']; nxJson.projects[myapp].tags = ['tag'];
updateFile('nx.json', JSON.stringify(nxJson)); updateFile('nx.json', JSON.stringify(nxJson));
expect(runCLI('affected:apps')).toContain(myapp); expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2); expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib); expect(runCLI('affected:libs')).not.toContain(mylib);
runCommand(`git add . && git commit -am "add tag to ${myapp}"`); }
}); });
it('should detect changes to projects based on the workspace.json', () => { it('should detect changes to projects based on the workspace.json', () => {
// TODO: investigate why affected gives different results on windows
if (isNotWindows()) {
generateAll();
const workspaceJson = readJson(workspaceConfigName()); const workspaceJson = readJson(workspaceConfigName());
workspaceJson.projects[myapp].prefix = 'my-app'; workspaceJson.projects[myapp].prefix = 'my-app';
updateFile(workspaceConfigName(), JSON.stringify(workspaceJson)); updateFile(workspaceConfigName(), JSON.stringify(workspaceJson));
expect(runCLI('affected:apps')).toContain(myapp); expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2); expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib); expect(runCLI('affected:libs')).not.toContain(mylib);
runCommand(`git add . && git commit -am "change prefix for ${myapp}"`); }
}); });
it('should affect all projects by removing projects', () => { it('should affect all projects by removing projects', () => {
generateAll();
const workspaceJson = readJson(workspaceConfigName()); const workspaceJson = readJson(workspaceConfigName());
const nxJson = readJson('nx.json');
delete workspaceJson.projects[mylib]; delete workspaceJson.projects[mylib];
updateFile(workspaceConfigName(), JSON.stringify(workspaceJson)); updateFile(workspaceConfigName(), JSON.stringify(workspaceJson));
const nxJson = readJson('nx.json');
delete nxJson.projects[mylib]; delete nxJson.projects[mylib];
updateFile('nx.json', JSON.stringify(nxJson)); updateFile('nx.json', JSON.stringify(nxJson));
expect(runCLI('affected:apps')).toContain(myapp); expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).toContain(myapp2); expect(runCLI('affected:apps')).toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib); 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", "import-fresh": "^3.1.0",
"injection-js": "^2.4.0", "injection-js": "^2.4.0",
"is-ci": "^3.0.0", "is-ci": "^3.0.0",
"is-windows": "^1.0.2",
"jasmine-core": "~2.99.1", "jasmine-core": "~2.99.1",
"jasmine-marbles": "~0.6.0", "jasmine-marbles": "~0.6.0",
"jasmine-spec-reporter": "~4.2.1", "jasmine-spec-reporter": "~4.2.1",

View File

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

View File

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