Skip to content

Commit

Permalink
fix(testing): fix windows e2e storage ENOENT (#17506)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Jun 9, 2023
1 parent bf2c42c commit fc42b7b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ 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
33 changes: 21 additions & 12 deletions e2e/utils/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import { join } from 'path';
import { ChildProcess, execSync, spawn } from 'child_process';
import { ChildProcess, execSync, fork } from 'child_process';
import { tmpdir } from 'tmp';
import { existsSync } from 'fs-extra';
import { Config } from '@jest/types';

export default async function () {
export default async function (globalConfig: Config.ConfigGlobals) {
const isVerbose =
process.env.NX_VERBOSE_LOGGING === 'true' || globalConfig.verbose;
const storageLocation = join(
process.cwd(),
'tmp/local-registry/storage',
tmpdir,
'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 --storage ${storageLocation} --clear ${
const childProcess = fork(
require.resolve(`nx`),
`local-registry @nx/nx-source --config scripts/local-registry/config.yml --location none --storage ${storageLocation} --clear ${
process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true'
}`.split(' ')
}`.split(' '),
{ stdio: 'pipe' }
);

childProcess.stdout.on('data', (data) => {
childProcess?.stdout?.on('data', (data) => {
if (data.toString().includes('http://localhost:')) {
const port = parseInt(
data.toString().match(/localhost:(?<port>\d+)/)?.groups?.port
Expand All @@ -31,7 +37,7 @@ export default async function () {
resolve(childProcess);
}
});
childProcess.stderr.on('data', (data) => {
childProcess?.stderr?.on('data', (data) => {
process.stderr.write(data);
reject(data);
});
Expand All @@ -46,10 +52,13 @@ export default async function () {
}
);

if (process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true') {
if (
process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true' ||
!existsSync('./build')
) {
console.log('Publishing packages to local registry');
execSync('pnpm nx-release --local major', {
stdio: process.env.CI === 'true' ? 'ignore' : 'inherit',
stdio: isVerbose ? 'inherit' : 'ignore',
});
}
}
2 changes: 1 addition & 1 deletion packages/js/src/executors/verdaccio/verdaccio.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function verdaccioExecutor(

try {
const port = await detectPort(options.port);
if (port === options.port) {
if (port !== options.port) {
logger.info(`Port ${options.port} was occupied. Using port ${port}.`);
options.port = port;
}
Expand Down
34 changes: 34 additions & 0 deletions scripts/local-registry/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# path to a directory with all packages
storage: ../../tmp/local-registry/storage

listen: 127.0.0.1:4872 # change to 127.0.0.1 to avoid IPv6 issue

# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
max_fails: 100
maxage: 30m
fail_timeout: 10m
timeout: 600s
cache: false

packages:
'@nrwl/*':
access: $all
publish: $all

'**':
access: $all
publish: $all
unpublish: $all
proxy: npmjs

# log settings
logs:
type: stdout
format: pretty
level: warn

publish:
allow_offline: true # set offline to true to allow publish offline

1 comment on commit fc42b7b

@vercel
Copy link

@vercel vercel bot commented on fc42b7b Jun 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.