Skip to content

Commit 96cd8e3

Browse files
committed
chore: update e2e tasks, to only populate local registry once for all tests
1 parent cceb3e3 commit 96cd8e3

File tree

21 files changed

+266
-140
lines changed

21 files changed

+266
-140
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
# Connect your workspace on nx.app and uncomment this to enable task distribution.
3737
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e" targets have been requested
38-
- run: pnpm exec nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml" --stop-agents-after="e2e" --with-env-vars="ANDROID_SDK_VERSION,FLUTTER_VERSION,JDK_VERSION"
38+
- run: pnpm exec nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml" --stop-agents-after="e2e-ci" --with-env-vars="ANDROID_SDK_VERSION,FLUTTER_VERSION,JDK_VERSION"
3939

4040
# This line is needed for nx affected to work when CI is running on a PR
4141
- run: git branch --track develop origin/develop || exit 0
@@ -46,4 +46,4 @@ jobs:
4646
main-branch-name: 'develop'
4747

4848
- run: pnpm exec nx-cloud record -- nx format:check
49-
- run: pnpm exec nx affected -t lint test-ci build e2e --parallel=5 --exclude=smoke
49+
- run: NX_VERBOSE_LOGGING=true pnpm exec nx affected -t lint test build e2e-ci --parallel=5 --exclude=smoke

.verdaccio/config.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ packages:
2323
proxy: npmjs
2424

2525
# log settings
26-
logs:
26+
log:
2727
type: stdout
2828
format: pretty
2929
level: warn
3030

3131
publish:
3232
allow_offline: true # set offline to true to allow publish offline
3333

34-
listen: 0.0.0.0:4873 # listen on all addresses (INADDR_ANY)

e2e/nx-flutter-e2e/tests/create-nx-flutter.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
12
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
23
import { createCLITestProject } from '@nxrocks/common/testing';
34
import { execSync } from 'child_process';
@@ -27,7 +28,7 @@ describe('create-nx-flutter', () => {
2728
);
2829

2930
// npm ls will fail if the package is not installed properly
30-
execSync('npm ls @nxrocks/nx-flutter', {
31+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-flutter`, {
3132
cwd: useNxWrapper
3233
? join(projectDirectory, '/.nx/installation')
3334
: projectDirectory,

e2e/nx-ktor-e2e/tests/create-nx-ktor.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
12
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
23
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
34
import { execSync } from 'child_process';
@@ -27,7 +28,7 @@ describe('create-nx-ktor', () => {
2728
);
2829

2930
// npm ls will fail if the package is not installed properly
30-
execSync('npm ls @nxrocks/nx-ktor', {
31+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-ktor`, {
3132
cwd: useNxWrapper
3233
? join(projectDirectory, '/.nx/installation')
3334
: projectDirectory,

e2e/nx-ktor-e2e/tests/nx-ktor.spec.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
12
import { uniq } from '@nx/plugin/testing';
23
import {
34
createTestProject,
@@ -19,11 +20,14 @@ describe('nx-ktor e2e', () => {
1920

2021
// The plugin has been built and published to a local registry in the jest globalSetup
2122
// Install the plugin built with the latest source code into the test repo
22-
execSync(`npm install @nxrocks/[email protected]`, {
23-
cwd: projectDirectory,
24-
stdio: 'inherit',
25-
env: process.env,
26-
});
23+
execSync(
24+
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
25+
{
26+
cwd: projectDirectory,
27+
stdio: 'inherit',
28+
env: process.env,
29+
}
30+
);
2731
});
2832

2933
afterAll(() => {
@@ -37,7 +41,7 @@ describe('nx-ktor e2e', () => {
3741

3842
it('should be installed', () => {
3943
// npm ls will fail if the package is not installed properly
40-
execSync('npm ls @nxrocks/nx-ktor', {
44+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-ktor`, {
4145
cwd: projectDirectory,
4246
stdio: 'inherit',
4347
});

e2e/nx-melos-e2e/tests/nx-melos.spec.ts

+20-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { checkFilesExist, createTestProject, runNxCommandAsync } from '@nxrocks/common/testing';
1+
import { getPackageManagerCommand } from '@nx/devkit';
2+
import {
3+
checkFilesExist,
4+
createTestProject,
5+
runNxCommandAsync,
6+
} from '@nxrocks/common/testing';
27
import { execSync } from 'child_process';
38
import { rmSync } from 'fs-extra';
49

@@ -10,24 +15,28 @@ describe('nx-melos e2e', () => {
1015

1116
// The plugin has been built and published to a local registry in the jest globalSetup
1217
// Install the plugin built with the latest source code into the test repo
13-
execSync(`npm install @nxrocks/[email protected]`, {
14-
cwd: projectDirectory,
15-
stdio: 'inherit',
16-
env: process.env,
17-
});
18+
execSync(
19+
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
20+
{
21+
cwd: projectDirectory,
22+
stdio: 'inherit',
23+
env: process.env,
24+
}
25+
);
1826
});
1927

2028
afterAll(() => {
2129
// Cleanup the test project
22-
projectDirectory && rmSync(projectDirectory, {
23-
recursive: true,
24-
force: true,
25-
});
30+
projectDirectory &&
31+
rmSync(projectDirectory, {
32+
recursive: true,
33+
force: true,
34+
});
2635
});
2736

2837
it('should be installed', () => {
2938
// npm ls will fail if the package is not installed properly
30-
execSync('npm ls @nxrocks/nx-melos', {
39+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-melos`, {
3140
cwd: projectDirectory,
3241
stdio: 'inherit',
3342
});

e2e/nx-micronaut-e2e/project.json

+1-23
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,5 @@
55
"sourceRoot": "e2e/nx-micronaut-e2e/tests",
66
"tags": ["e2e"],
77
"implicitDependencies": ["nx-micronaut"],
8-
"targets": {
9-
"e2e": {
10-
"inputs": [
11-
"default",
12-
"^default",
13-
"{workspaceRoot}/jest.preset.js",
14-
{
15-
"externalDependencies": ["jest"]
16-
}
17-
],
18-
"options": {
19-
"passWithNoTests": true,
20-
"runInBand": true
21-
},
22-
"dependsOn": ["^build"],
23-
"configurations": {
24-
"ci": {
25-
"ci": true,
26-
"coverage": true
27-
}
28-
}
29-
}
30-
}
8+
"targets": {}
319
}

e2e/nx-micronaut-e2e/tests/create-nx-micronaut.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
12
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
23
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
34
import { execSync } from 'child_process';
@@ -27,7 +28,7 @@ describe('create-nx-micronaut', () => {
2728
);
2829

2930
// npm ls will fail if the package is not installed properly
30-
execSync('npm ls @nxrocks/nx-micronaut', {
31+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-micronaut`, {
3132
cwd: useNxWrapper
3233
? join(projectDirectory, '/.nx/installation')
3334
: projectDirectory,

e2e/nx-micronaut-e2e/tests/nx-micronaut.spec.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
12
import { uniq } from '@nx/plugin/testing';
23
import {
34
createTestProject,
@@ -20,11 +21,14 @@ describe('nx-micronaut e2e', () => {
2021

2122
// The plugin has been built and published to a local registry in the jest globalSetup
2223
// Install the plugin built with the latest source code into the test repo
23-
execSync(`npm install @nxrocks/[email protected]`, {
24-
cwd: projectDirectory,
25-
stdio: 'inherit',
26-
env: process.env,
27-
});
24+
execSync(
25+
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
26+
{
27+
cwd: projectDirectory,
28+
stdio: 'inherit',
29+
env: process.env,
30+
}
31+
);
2832
});
2933

3034
afterAll(() => {
@@ -38,7 +42,7 @@ describe('nx-micronaut e2e', () => {
3842

3943
it('should be installed', () => {
4044
// npm ls will fail if the package is not installed properly
41-
execSync('npm ls @nxrocks/nx-micronaut', {
45+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-micronaut`, {
4246
cwd: projectDirectory,
4347
stdio: 'inherit',
4448
});

e2e/nx-quarkus-e2e/tests/create-nx-quarkus.spec.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
12
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
23
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
34
import { execSync } from 'child_process';
45
import { rmSync } from 'fs';
56
import { join } from 'path';
67

7-
describe('create-nx-spring-boot', () => {
8+
describe('create-nx-quarkus', () => {
89
let projectDirectory: string;
910

1011
beforeAll(() => {
@@ -22,12 +23,12 @@ describe('create-nx-spring-boot', () => {
2223
${false}
2324
`('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => {
2425
projectDirectory = createCLITestProject(
25-
'create-nx-spring-boot',
26+
'create-nx-quarkus',
2627
`--prjName=bootapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --no-interactive`
2728
);
2829

2930
// npm ls will fail if the package is not installed properly
30-
execSync('npm ls @nxrocks/nx-spring-boot', {
31+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-quarkus`, {
3132
cwd: useNxWrapper
3233
? join(projectDirectory, '/.nx/installation')
3334
: projectDirectory,

e2e/nx-quarkus-e2e/tests/nx-quarkus.spec.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
12
import { uniq } from '@nx/plugin/testing';
23
import {
34
createTestProject,
@@ -21,11 +22,14 @@ describe('nx-quarkus e2e', () => {
2122

2223
// The plugin has been built and published to a local registry in the jest globalSetup
2324
// Install the plugin built with the latest source code into the test repo
24-
execSync(`npm install @nxrocks/[email protected]`, {
25-
cwd: projectDirectory,
26-
stdio: 'inherit',
27-
env: process.env,
28-
});
25+
execSync(
26+
`${getPackageManagerCommand().add} @nxrocks/[email protected]`,
27+
{
28+
cwd: projectDirectory,
29+
stdio: 'inherit',
30+
env: process.env,
31+
}
32+
);
2933
});
3034

3135
afterAll(() => {
@@ -39,7 +43,7 @@ describe('nx-quarkus e2e', () => {
3943

4044
it('should be installed', () => {
4145
// npm ls will fail if the package is not installed properly
42-
execSync('npm ls @nxrocks/nx-quarkus', {
46+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-quarkus`, {
4347
cwd: projectDirectory,
4448
stdio: 'inherit',
4549
});
@@ -83,7 +87,6 @@ describe('nx-quarkus e2e', () => {
8387
`should create a quarkus '$projectType' with given options`,
8488
async ({ projectType }) => {
8589
const prjName = uniq('nx-quarkus');
86-
const prjDir = projectType === 'application' ? 'apps' : 'libs';
8790
const buildSystem = 'MAVEN';
8891
const groupId = 'com.tinesoft';
8992
const artifactId = 'api';

e2e/nx-spring-boot-e2e/tests/create-nx-spring-boot.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
12
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
23
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
34
import { execSync } from 'child_process';
@@ -27,7 +28,7 @@ describe('create-nx-spring-boot', () => {
2728
);
2829

2930
// npm ls will fail if the package is not installed properly
30-
execSync('npm ls @nxrocks/nx-spring-boot', {
31+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-spring-boot`, {
3132
cwd: useNxWrapper
3233
? join(projectDirectory, '/.nx/installation')
3334
: projectDirectory,

e2e/nx-spring-boot-e2e/tests/nx-spring-boot.spec.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
runNxCommandAsync,
1010
tmpProjPath,
1111
} from '@nxrocks/common-jvm/testing';
12-
import { names } from '@nx/devkit';
12+
import { getPackageManagerCommand, names } from '@nx/devkit';
1313

1414
import { lstatSync, rmSync } from 'fs';
1515
import { execSync } from 'child_process';
@@ -22,11 +22,14 @@ describe('nx-spring-boot e2e', () => {
2222

2323
// The plugin has been built and published to a local registry in the jest globalSetup
2424
// Install the plugin built with the latest source code into the test repo
25-
execSync(`npm install @nxrocks/[email protected]`, {
26-
cwd: projectDirectory,
27-
stdio: 'inherit',
28-
env: process.env,
29-
});
25+
execSync(
26+
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
27+
{
28+
cwd: projectDirectory,
29+
stdio: 'inherit',
30+
env: process.env,
31+
}
32+
);
3033
});
3134

3235
afterAll(() => {
@@ -39,7 +42,7 @@ describe('nx-spring-boot e2e', () => {
3942

4043
it('should be installed', () => {
4144
// npm ls will fail if the package is not installed properly
42-
execSync('npm ls @nxrocks/nx-spring-boot', {
45+
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-spring-boot`, {
4346
cwd: projectDirectory,
4447
stdio: 'inherit',
4548
});

e2e/smoke/project.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"sourceRoot": "e2e/smoke/src",
55
"projectType": "application",
6-
"tags": [],
6+
"tags": ["e2e"],
77
"implicitDependencies": [
88
"nx-spring-boot",
99
"nx-quarkus",
1010
"nx-micronaut",
1111
"nx-flutter",
12-
"nx-ktor",
13-
"nx-melos"
12+
"nx-ktor"
1413
],
1514
"targets": {}
1615
}

nx.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
}
1818
},
1919
"version": {
20-
"preVersionCommand": "pnpm dlx nx run-many -t build",
20+
"preVersionCommand": "pnpm nx run-many -t build",
2121
"generatorOptions": {
2222
"packageRoot": "dist/packages/{projectName}",
2323
"currentVersionResolver": "git-tag",
24-
"specifierSource": "conventional-commits"
24+
"specifierSource": "conventional-commits",
25+
"updateDependents": "auto"
2526
}
2627
}
2728
},
@@ -56,7 +57,7 @@
5657
"passWithNoTests": true,
5758
"runInBand": true
5859
},
59-
"dependsOn": ["^build"],
60+
"dependsOn": ["nxrocks:populate-local-registry"],
6061
"configurations": {
6162
"ci": {
6263
"ci": true,
@@ -69,7 +70,7 @@
6970
"passWithNoTests": true,
7071
"runInBand": true
7172
},
72-
"dependsOn": ["^build"],
73+
"dependsOn": ["nxrocks:populate-local-registry"],
7374
"configurations": {
7475
"ci": {
7576
"ci": true,
@@ -162,5 +163,8 @@
162163
"sharedGlobals": ["{workspaceRoot}/.nx/workflows/**/**"]
163164
},
164165
"defaultBase": "develop",
165-
"useLegacyCache": true
166+
"useLegacyCache": true,
167+
"cli": {
168+
"packageManager": "pnpm"
169+
}
166170
}

0 commit comments

Comments
 (0)