Skip to content

Commit

Permalink
chore(core): change repo e2e to use verdaccio executor
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Jun 5, 2023
1 parent fe27b87 commit e77bbf5
Show file tree
Hide file tree
Showing 39 changed files with 160 additions and 171 deletions.
1 change: 0 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ pnpm-lock.yaml @nrwl/nx-pipelines-reviewers
# Scripts
/scripts/depcheck @FrozenPandaz @vsavkin @jaysoo
/scripts/documentation @nrwl/nx-docs-reviewers
/scripts/local-registry @FrozenPandaz @vsavkin
/scripts/angular-support-upgrades @nrwl/nx-angular-reviewers

# CI
Expand Down
3 changes: 2 additions & 1 deletion e2e/angular-core/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* eslint-disable */
export default {
transform: {
'^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-angular-core',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/angular-extensions/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../global-setup.ts',
globalTeardown: '../global-teardown.ts',
displayName: 'e2e-angular-extensions',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/cypress/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-cypress',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/detox/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-detox',
testTimeout: 600000,
preset: '../../jest.preset.js',
Expand Down
2 changes: 2 additions & 0 deletions e2e/esbuild/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-esbuild',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/expo/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-expo',
testTimeout: 600000,
preset: '../../jest.preset.js',
Expand Down
2 changes: 2 additions & 0 deletions e2e/jest/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-jest',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/js/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-js',
preset: '../../jest.preset.js',
};
3 changes: 2 additions & 1 deletion e2e/js/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"**/*.spec.jsx",
"**/*.test.jsx",
"**/*.d.ts",
"jest.config.ts"
"jest.config.ts",
"local-registry-setup.ts"
]
}
2 changes: 2 additions & 0 deletions e2e/lerna-smoke-tests/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-lerna-smoke-tests',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/linter/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-linter',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/next/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-next',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/node/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-node',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/nx-init/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-nx-init',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/nx-misc/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-nx-misc',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/nx-run/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-nx-run',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/plugin/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-plugin',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/react-core/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-react-core',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/react-extensions/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-react-extensions',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/react-native/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-react-native',
testTimeout: 600000,
preset: '../../jest.preset.js',
Expand Down
2 changes: 2 additions & 0 deletions e2e/rollup/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-rollup',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/storybook-angular/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-storybook-angular',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/storybook/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-storybook',
preset: '../../jest.preset.js',
};
53 changes: 53 additions & 0 deletions e2e/utils/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { join } from 'path';
import { ChildProcess, execSync, spawn } from 'child_process';

export default async function () {
let port = 4873;
global.nxLocalRegistryStorage = join(
process.cwd(),
'tmp/local-registry/storage',
process.env.NX_TASK_TARGET_PROJECT ?? ''
);

global.nxLocalRegistryProcess = await new Promise<ChildProcess>(
(resolve, reject) => {
const childProcess = spawn(
`nx`,
`local-registry @nx/nx-source --location none --port ${port} --storage ${global.nxLocalRegistryStorage}`.split(
' '
)
);

childProcess.stdout.on('data', (data) => {
if (data.toString().includes('http://localhost:')) {
port ??= parseInt(
data.toString().match(/localhost:(?<port>\d+)/)?.groups?.port
);
console.log('Local registry started on port ' + port);

const registry = `http://localhost:${port}`;
process.env.npm_config_registry = registry;
process.env.YARN_REGISTRY = registry;
console.log('Set npm and yarn config registry to ' + registry);

resolve(childProcess);
}
});
childProcess.stderr.on('data', (data) => {
process.stdout.write(data);
reject(data);
});
childProcess.on('error', (err) => {
console.log('local registry error', err);
reject(err);
});
childProcess.on('exit', (code) => {
console.log('local registry exit', code);
reject(code);
});
}
);

console.log('Publishing packages to local registry');
execSync('pnpm nx-release --local major');
}
11 changes: 11 additions & 0 deletions e2e/utils/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { existsSync, rmSync } from 'fs-extra';

export default function () {
if (global.nxLocalRegistryProcess) {
global.nxLocalRegistryProcess.kill();
}

if (existsSync(global.nxLocalRegistryStorage)) {
rmSync(global.nxLocalRegistryStorage);
}
}
2 changes: 2 additions & 0 deletions e2e/vite/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-vite',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/web/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-web',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/webpack/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-webpack',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/workspace-create-npm/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-workspace-create-npm',
preset: '../../jest.preset.js',
};
2 changes: 2 additions & 0 deletions e2e/workspace-create/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-workspace-create',
preset: '../../jest.preset.js',
};
3 changes: 0 additions & 3 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const nxPreset = require('@nx/jest/preset').default;

process.env.npm_config_registry = `http://localhost:4872`;
process.env.YARN_REGISTRY = `http://localhost:4872`;

module.exports = {
...nxPreset,
testTimeout: 30000,
Expand Down
Loading

0 comments on commit e77bbf5

Please sign in to comment.