Skip to content

Commit

Permalink
chore: update e2e tasks, to only populate local registry once for all…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
tinesoft committed Nov 24, 2024
1 parent c7d2db6 commit fdce646
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 105 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

# Connect your workspace on nx.app and uncomment this to enable task distribution.
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e" targets have been requested
- 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"
- 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"

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

- run: pnpm exec nx-cloud record -- nx format:check
- run: pnpm exec nx affected -t lint test-ci build e2e --parallel=5 --exclude=smoke
- run: pnpm exec nx affected -t lint test-ci build e2e-ci --parallel=5 --exclude=smoke
1 change: 0 additions & 1 deletion .verdaccio/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ logs:
publish:
allow_offline: true # set offline to true to allow publish offline

listen: 0.0.0.0:4873 # listen on all addresses (INADDR_ANY)
16 changes: 10 additions & 6 deletions e2e/nx-ktor-e2e/tests/nx-ktor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { uniq } from '@nx/plugin/testing';
import {
createTestProject,
Expand All @@ -19,11 +20,14 @@ describe('nx-ktor e2e', () => {

// The plugin has been built and published to a local registry in the jest globalSetup
// Install the plugin built with the latest source code into the test repo
execSync(`npm install @nxrocks/[email protected]`, {
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
});
execSync(
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
{
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
}
);
});

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

it('should be installed', () => {
// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-ktor', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-ktor`, {
cwd: projectDirectory,
stdio: 'inherit',
});
Expand Down
31 changes: 20 additions & 11 deletions e2e/nx-melos-e2e/tests/nx-melos.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { checkFilesExist, createTestProject, runNxCommandAsync } from '@nxrocks/common/testing';
import { getPackageManagerCommand } from '@nx/devkit';
import {
checkFilesExist,
createTestProject,
runNxCommandAsync,
} from '@nxrocks/common/testing';
import { execSync } from 'child_process';
import { rmSync } from 'fs-extra';

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

// The plugin has been built and published to a local registry in the jest globalSetup
// Install the plugin built with the latest source code into the test repo
execSync(`npm install @nxrocks/[email protected]`, {
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
});
execSync(
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
{
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
}
);
});

afterAll(() => {
// Cleanup the test project
projectDirectory && rmSync(projectDirectory, {
recursive: true,
force: true,
});
projectDirectory &&
rmSync(projectDirectory, {
recursive: true,
force: true,
});
});

it('should be installed', () => {
// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-melos', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-melos`, {
cwd: projectDirectory,
stdio: 'inherit',
});
Expand Down
16 changes: 10 additions & 6 deletions e2e/nx-micronaut-e2e/tests/nx-micronaut.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { uniq } from '@nx/plugin/testing';
import {
createTestProject,
Expand All @@ -20,11 +21,14 @@ describe('nx-micronaut e2e', () => {

// The plugin has been built and published to a local registry in the jest globalSetup
// Install the plugin built with the latest source code into the test repo
execSync(`npm install @nxrocks/[email protected]`, {
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
});
execSync(
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
{
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
}
);
});

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

it('should be installed', () => {
// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-micronaut', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-micronaut`, {
cwd: projectDirectory,
stdio: 'inherit',
});
Expand Down
16 changes: 10 additions & 6 deletions e2e/nx-quarkus-e2e/tests/nx-quarkus.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { uniq } from '@nx/plugin/testing';
import {
createTestProject,
Expand All @@ -21,11 +22,14 @@ describe('nx-quarkus e2e', () => {

// The plugin has been built and published to a local registry in the jest globalSetup
// Install the plugin built with the latest source code into the test repo
execSync(`npm install @nxrocks/[email protected]`, {
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
});
execSync(
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
{
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
}
);
});

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

it('should be installed', () => {
// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-quarkus', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-quarkus`, {
cwd: projectDirectory,
stdio: 'inherit',
});
Expand Down
17 changes: 10 additions & 7 deletions e2e/nx-spring-boot-e2e/tests/nx-spring-boot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
runNxCommandAsync,
tmpProjPath,
} from '@nxrocks/common-jvm/testing';
import { names } from '@nx/devkit';
import { getPackageManagerCommand, names } from '@nx/devkit';

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

// The plugin has been built and published to a local registry in the jest globalSetup
// Install the plugin built with the latest source code into the test repo
execSync(`npm install @nxrocks/[email protected]`, {
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
});
execSync(
`${getPackageManagerCommand().install} @nxrocks/[email protected]`,
{
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
}
);
});

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

it('should be installed', () => {
// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-spring-boot', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-spring-boot`, {
cwd: projectDirectory,
stdio: 'inherit',
});
Expand Down
5 changes: 2 additions & 3 deletions e2e/smoke/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/smoke/src",
"projectType": "application",
"tags": [],
"tags": ["e2e"],
"implicitDependencies": [
"nx-spring-boot",
"nx-quarkus",
"nx-micronaut",
"nx-flutter",
"nx-ktor",
"nx-melos"
"nx-ktor"
],
"targets": {}
}
12 changes: 8 additions & 4 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"generatorOptions": {
"packageRoot": "dist/packages/{projectName}",
"currentVersionResolver": "git-tag",
"specifierSource": "conventional-commits"
"specifierSource": "conventional-commits",
"updateDependents": "auto"
}
}
},
Expand Down Expand Up @@ -56,7 +57,7 @@
"passWithNoTests": true,
"runInBand": true
},
"dependsOn": ["^build"],
"dependsOn": ["nxrocks:populate-local-registry"],
"configurations": {
"ci": {
"ci": true,
Expand All @@ -69,7 +70,7 @@
"passWithNoTests": true,
"runInBand": true
},
"dependsOn": ["^build"],
"dependsOn": ["nxrocks:populate-local-registry"],
"configurations": {
"ci": {
"ci": true,
Expand Down Expand Up @@ -162,5 +163,8 @@
"sharedGlobals": ["{workspaceRoot}/.nx/workflows/**/**"]
},
"defaultBase": "develop",
"useLegacyCache": true
"useLegacyCache": true,
"cli": {
"packageManager": "pnpm"
}
}
Loading

0 comments on commit fdce646

Please sign in to comment.