feat(repo): explicitly kill processes holding onto ports
This commit is contained in:
parent
c47b49cea1
commit
d4e659c660
@ -1,6 +1,7 @@
|
|||||||
import { packagesWeCareAbout } from '@nrwl/workspace/src/command-line/report';
|
import { packagesWeCareAbout } from '@nrwl/workspace/src/command-line/report';
|
||||||
import { renameSync } from 'fs';
|
import { renameSync } from 'fs';
|
||||||
import {
|
import {
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -13,6 +14,8 @@ import {
|
|||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
|
|
||||||
describe('Cli', () => {
|
describe('Cli', () => {
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should execute long running tasks', () => {
|
it('should execute long running tasks', () => {
|
||||||
newProject();
|
newProject();
|
||||||
const myapp = uniq('myapp');
|
const myapp = uniq('myapp');
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -10,6 +11,8 @@ import {
|
|||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
|
|
||||||
describe('Cypress E2E Test runner', () => {
|
describe('Cypress E2E Test runner', () => {
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
describe('project scaffolding', () => {
|
describe('project scaffolding', () => {
|
||||||
it('should generate an app with the Cypress as e2e test runner', () => {
|
it('should generate an app with the Cypress as e2e test runner', () => {
|
||||||
newProject();
|
newProject();
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
runCLI,
|
runCLI,
|
||||||
runCLIAsync,
|
runCLIAsync,
|
||||||
@ -11,6 +12,7 @@ describe('Gatsby Applications', () => {
|
|||||||
let proj: string;
|
let proj: string;
|
||||||
|
|
||||||
beforeEach(() => (proj = newProject()));
|
beforeEach(() => (proj = newProject()));
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should generate a valid gatsby application', async () => {
|
it('should generate a valid gatsby application', async () => {
|
||||||
const appName = uniq('app');
|
const appName = uniq('app');
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { stripIndents } from '@angular-devkit/core/src/utils/literals';
|
import { stripIndents } from '@angular-devkit/core/src/utils/literals';
|
||||||
import {
|
import {
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
runCLI,
|
runCLI,
|
||||||
runCLIAsync,
|
runCLIAsync,
|
||||||
@ -9,6 +10,7 @@ import {
|
|||||||
|
|
||||||
describe('Jest', () => {
|
describe('Jest', () => {
|
||||||
beforeEach(() => newProject());
|
beforeEach(() => newProject());
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should be able test projects using jest', async () => {
|
it('should be able test projects using jest', async () => {
|
||||||
const mylib = uniq('mylib');
|
const mylib = uniq('mylib');
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -10,6 +11,8 @@ import {
|
|||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
|
|
||||||
describe('Linter', () => {
|
describe('Linter', () => {
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('linting should error when rules are not followed', () => {
|
it('linting should error when rules are not followed', () => {
|
||||||
newProject();
|
newProject();
|
||||||
const myapp = uniq('myapp');
|
const myapp = uniq('myapp');
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { stringUtils } from '@nrwl/workspace';
|
import { stringUtils } from '@nrwl/workspace';
|
||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -15,6 +16,7 @@ describe('Next.js Applications', () => {
|
|||||||
let proj: string;
|
let proj: string;
|
||||||
|
|
||||||
beforeEach(() => (proj = newProject()));
|
beforeEach(() => (proj = newProject()));
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should be able to serve with a proxy configuration', async () => {
|
it('should be able to serve with a proxy configuration', async () => {
|
||||||
const appName = uniq('app');
|
const appName = uniq('app');
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import {
|
|||||||
checkFilesDoNotExist,
|
checkFilesDoNotExist,
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
createFile,
|
createFile,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -36,6 +37,7 @@ function getData(): Promise<any> {
|
|||||||
|
|
||||||
describe('Node Applications', () => {
|
describe('Node Applications', () => {
|
||||||
beforeEach(() => newProject());
|
beforeEach(() => newProject());
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should be able to generate an empty application', async () => {
|
it('should be able to generate an empty application', async () => {
|
||||||
const nodeapp = uniq('nodeapp');
|
const nodeapp = uniq('nodeapp');
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
expectTestsPass,
|
expectTestsPass,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readJson,
|
readJson,
|
||||||
runCLI,
|
runCLI,
|
||||||
@ -12,6 +13,7 @@ import {
|
|||||||
|
|
||||||
describe('Nx Plugin', () => {
|
describe('Nx Plugin', () => {
|
||||||
beforeEach(() => newProject());
|
beforeEach(() => newProject());
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should be able to generate a Nx Plugin ', async () => {
|
it('should be able to generate a Nx Plugin ', async () => {
|
||||||
const plugin = uniq('plugin');
|
const plugin = uniq('plugin');
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
checkFilesDoNotExist,
|
checkFilesDoNotExist,
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -117,6 +118,7 @@ describe('Build React libraries and apps', () => {
|
|||||||
return JSON.stringify(json, null, 2);
|
return JSON.stringify(json, null, 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
describe('Publishable libraries', () => {
|
describe('Publishable libraries', () => {
|
||||||
it('should throw an error if the dependent library has not been built before building the parent lib', () => {
|
it('should throw an error if the dependent library has not been built before building the parent lib', () => {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { serializeJson } from '@nrwl/workspace';
|
|||||||
import {
|
import {
|
||||||
checkFilesDoNotExist,
|
checkFilesDoNotExist,
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -18,6 +19,7 @@ describe('React Applications', () => {
|
|||||||
let proj: string;
|
let proj: string;
|
||||||
|
|
||||||
beforeEach(() => (proj = newProject()));
|
beforeEach(() => (proj = newProject()));
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should be able to generate a react app + lib', async () => {
|
it('should be able to generate a react app + lib', async () => {
|
||||||
const appName = uniq('app');
|
const appName = uniq('app');
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
runCLI,
|
runCLI,
|
||||||
@ -10,8 +11,10 @@ import {
|
|||||||
import { writeFileSync } from 'fs';
|
import { writeFileSync } from 'fs';
|
||||||
|
|
||||||
describe('Storybook schematics', () => {
|
describe('Storybook schematics', () => {
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
describe('serve storybook', () => {
|
describe('serve storybook', () => {
|
||||||
it('should run a React based Storybook setup', async () => {
|
xit('should run a React based Storybook setup', async () => {
|
||||||
newProject();
|
newProject();
|
||||||
|
|
||||||
const reactStorybookLib = uniq('test-ui-lib-react');
|
const reactStorybookLib = uniq('test-ui-lib-react');
|
||||||
|
|||||||
@ -133,11 +133,6 @@ export function getSelectedPackageManager(): 'npm' | 'yarn' | 'pnpm' {
|
|||||||
* for the currently selected CLI.
|
* for the currently selected CLI.
|
||||||
*/
|
*/
|
||||||
export function newProject({ name = uniq('proj') } = {}): string {
|
export function newProject({ name = uniq('proj') } = {}): string {
|
||||||
// potential leftovers from other e2e tests
|
|
||||||
// there are a lot of reasons for why sigterm sometime fails
|
|
||||||
killPort(4200);
|
|
||||||
killPort(3333);
|
|
||||||
|
|
||||||
const packageManager = getSelectedPackageManager();
|
const packageManager = getSelectedPackageManager();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -185,19 +180,28 @@ export function newProject({ name = uniq('proj') } = {}): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function killPorts() {
|
||||||
|
// potential leftovers from other e2e tests
|
||||||
|
// there are a lot of reasons for why sigterm sometime fails
|
||||||
|
await killPort(4200);
|
||||||
|
await killPort(3333);
|
||||||
|
}
|
||||||
|
|
||||||
// Useful in order to cleanup space during CI to prevent `No space left on device` exceptions
|
// Useful in order to cleanup space during CI to prevent `No space left on device` exceptions
|
||||||
export function removeProject({ onlyOnCI = false } = {}) {
|
export async function removeProject({ onlyOnCI = false } = {}) {
|
||||||
if (onlyOnCI && !isCI) {
|
if (onlyOnCI && !isCI) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
removeSync(tmpProjPath());
|
removeSync(tmpProjPath());
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
await killPorts();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runCypressTests() {
|
export function runCypressTests() {
|
||||||
// temporary disable
|
// temporary disable
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runCommandAsync(
|
export function runCommandAsync(
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readJson,
|
readJson,
|
||||||
runCLI,
|
runCLI,
|
||||||
@ -10,6 +11,8 @@ import {
|
|||||||
import { serializeJson } from '@nrwl/workspace';
|
import { serializeJson } from '@nrwl/workspace';
|
||||||
|
|
||||||
describe('file-server', () => {
|
describe('file-server', () => {
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should serve folder of files', async () => {
|
it('should serve folder of files', async () => {
|
||||||
newProject({ name: uniq('fileserver') });
|
newProject({ name: uniq('fileserver') });
|
||||||
const appName = uniq('app');
|
const appName = uniq('app');
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import {
|
|||||||
checkFilesDoNotExist,
|
checkFilesDoNotExist,
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
createFile,
|
createFile,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -14,6 +15,8 @@ import {
|
|||||||
|
|
||||||
describe('Web Components Applications', () => {
|
describe('Web Components Applications', () => {
|
||||||
beforeEach(() => newProject());
|
beforeEach(() => newProject());
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should be able to generate a web app', async () => {
|
it('should be able to generate a web app', async () => {
|
||||||
const appName = uniq('app');
|
const appName = uniq('app');
|
||||||
runCLI(`generate @nrwl/web:app ${appName} --no-interactive`);
|
runCLI(`generate @nrwl/web:app ${appName} --no-interactive`);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import {
|
|||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
e2eCwd,
|
e2eCwd,
|
||||||
expectNoAngularDevkit,
|
expectNoAngularDevkit,
|
||||||
|
killPorts,
|
||||||
readJson,
|
readJson,
|
||||||
removeProject,
|
removeProject,
|
||||||
runCreateWorkspace,
|
runCreateWorkspace,
|
||||||
@ -13,6 +14,7 @@ import { execSync } from 'child_process';
|
|||||||
|
|
||||||
describe('create-nx-workspace', () => {
|
describe('create-nx-workspace', () => {
|
||||||
afterEach(() => removeProject({ onlyOnCI: true }));
|
afterEach(() => removeProject({ onlyOnCI: true }));
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should be able to create an empty workspace', () => {
|
it('should be able to create an empty workspace', () => {
|
||||||
const wsName = uniq('empty');
|
const wsName = uniq('empty');
|
||||||
|
|||||||
@ -8,9 +8,12 @@ import {
|
|||||||
uniq,
|
uniq,
|
||||||
packageInstall,
|
packageInstall,
|
||||||
removeProject,
|
removeProject,
|
||||||
|
killPorts,
|
||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
|
|
||||||
describe('custom workspace layout', () => {
|
describe('custom workspace layout', () => {
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should work', async () => {
|
it('should work', async () => {
|
||||||
const proj = uniq('custom-layout-proj');
|
const proj = uniq('custom-layout-proj');
|
||||||
runCreateWorkspace(proj, { preset: 'oss' });
|
runCreateWorkspace(proj, { preset: 'oss' });
|
||||||
|
|||||||
@ -4,12 +4,14 @@ import {
|
|||||||
updateFile,
|
updateFile,
|
||||||
readJson,
|
readJson,
|
||||||
runCLI,
|
runCLI,
|
||||||
|
killPorts,
|
||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
|
|
||||||
describe('Nx Plugins', () => {
|
describe('Nx Plugins', () => {
|
||||||
beforeAll(() => newProject());
|
beforeAll(() => newProject());
|
||||||
|
|
||||||
afterAll(() => removeProject({ onlyOnCI: true }));
|
afterAll(() => removeProject({ onlyOnCI: true }));
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should use plugins defined in nx.json', () => {
|
it('should use plugins defined in nx.json', () => {
|
||||||
const nxJson = readJson('nx.json');
|
const nxJson = readJson('nx.json');
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readJson,
|
readJson,
|
||||||
removeProject,
|
removeProject,
|
||||||
@ -12,6 +13,7 @@ describe('Run Commands', () => {
|
|||||||
beforeAll(() => newProject());
|
beforeAll(() => newProject());
|
||||||
|
|
||||||
afterAll(() => removeProject({ onlyOnCI: true }));
|
afterAll(() => removeProject({ onlyOnCI: true }));
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should not override environment variables already set when setting a custom env file path', async () => {
|
it('should not override environment variables already set when setting a custom env file path', async () => {
|
||||||
const nodeapp = uniq('nodeapp');
|
const nodeapp = uniq('nodeapp');
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import * as path from 'path';
|
|||||||
import {
|
import {
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
exists,
|
exists,
|
||||||
|
killPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -24,6 +25,8 @@ beforeAll(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('lint', () => {
|
describe('lint', () => {
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('lint should ensure module boundaries', () => {
|
it('lint should ensure module boundaries', () => {
|
||||||
const myapp = uniq('myapp');
|
const myapp = uniq('myapp');
|
||||||
const myapp2 = uniq('myapp2');
|
const myapp2 = uniq('myapp2');
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { NxJson } from '@nrwl/workspace';
|
|||||||
import {
|
import {
|
||||||
getPackageManagerCommand,
|
getPackageManagerCommand,
|
||||||
getSelectedPackageManager,
|
getSelectedPackageManager,
|
||||||
|
killPorts,
|
||||||
listFiles,
|
listFiles,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
@ -23,6 +24,7 @@ describe('run-one', () => {
|
|||||||
beforeAll(() => (proj = newProject()));
|
beforeAll(() => (proj = newProject()));
|
||||||
|
|
||||||
afterAll(() => removeProject({ onlyOnCI: true }));
|
afterAll(() => removeProject({ onlyOnCI: true }));
|
||||||
|
afterEach(() => killPorts());
|
||||||
|
|
||||||
it('should build a specific project', () => {
|
it('should build a specific project', () => {
|
||||||
const myapp = uniq('app');
|
const myapp = uniq('app');
|
||||||
|
|||||||
1
nx.json
1
nx.json
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"npmScope": "nrwl",
|
"npmScope": "nrwl",
|
||||||
"implicitDependencies": {
|
"implicitDependencies": {
|
||||||
|
"package.json": "*",
|
||||||
".eslintrc.json": "*"
|
".eslintrc.json": "*"
|
||||||
},
|
},
|
||||||
"tasksRunnerOptions": {
|
"tasksRunnerOptions": {
|
||||||
|
|||||||
@ -2104,7 +2104,7 @@
|
|||||||
"sourceRoot": "dep-graph/dep-graph-e2e/src",
|
"sourceRoot": "dep-graph/dep-graph-e2e/src",
|
||||||
"projectType": "application",
|
"projectType": "application",
|
||||||
"targets": {
|
"targets": {
|
||||||
"e2e": {
|
"e2e-disabled": {
|
||||||
"executor": "@nrwl/cypress:cypress",
|
"executor": "@nrwl/cypress:cypress",
|
||||||
"options": {
|
"options": {
|
||||||
"cypressConfig": "dep-graph/dep-graph-e2e/cypress.json",
|
"cypressConfig": "dep-graph/dep-graph-e2e/cypress.json",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user