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