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 Dec 1, 2024
1 parent 921cf37 commit 1ff51b6
Show file tree
Hide file tree
Showing 21 changed files with 252 additions and 129 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: NX_VERBOSE_LOGGING=true pnpm exec nx affected -t lint test build e2e-ci --parallel=5 --exclude=smoke
3 changes: 1 addition & 2 deletions .verdaccio/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ packages:
proxy: npmjs

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

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

listen: 0.0.0.0:4873 # listen on all addresses (INADDR_ANY)
3 changes: 2 additions & 1 deletion e2e/nx-flutter-e2e/tests/create-nx-flutter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
import { createCLITestProject } from '@nxrocks/common/testing';
import { execSync } from 'child_process';
Expand Down Expand Up @@ -27,7 +28,7 @@ describe('create-nx-flutter', () => {
);

// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-flutter', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-flutter`, {
cwd: useNxWrapper
? join(projectDirectory, '/.nx/installation')
: projectDirectory,
Expand Down
3 changes: 2 additions & 1 deletion e2e/nx-ktor-e2e/tests/create-nx-ktor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
import { execSync } from 'child_process';
Expand Down Expand Up @@ -27,7 +28,7 @@ describe('create-nx-ktor', () => {
);

// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-ktor', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-ktor`, {
cwd: useNxWrapper
? join(projectDirectory, '/.nx/installation')
: projectDirectory,
Expand Down
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
24 changes: 1 addition & 23 deletions e2e/nx-micronaut-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,5 @@
"sourceRoot": "e2e/nx-micronaut-e2e/tests",
"tags": ["e2e"],
"implicitDependencies": ["nx-micronaut"],
"targets": {
"e2e": {
"inputs": [
"default",
"^default",
"{workspaceRoot}/jest.preset.js",
{
"externalDependencies": ["jest"]
}
],
"options": {
"passWithNoTests": true,
"runInBand": true
},
"dependsOn": ["^build"],
"configurations": {
"ci": {
"ci": true,
"coverage": true
}
}
}
}
"targets": {}
}
3 changes: 2 additions & 1 deletion e2e/nx-micronaut-e2e/tests/create-nx-micronaut.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
import { execSync } from 'child_process';
Expand Down Expand Up @@ -27,7 +28,7 @@ describe('create-nx-micronaut', () => {
);

// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-micronaut', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-micronaut`, {
cwd: useNxWrapper
? join(projectDirectory, '/.nx/installation')
: projectDirectory,
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
7 changes: 4 additions & 3 deletions e2e/nx-quarkus-e2e/tests/create-nx-quarkus.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
import { execSync } from 'child_process';
import { rmSync } from 'fs';
import { join } from 'path';

describe('create-nx-spring-boot', () => {
describe('create-nx-quarkus', () => {
let projectDirectory: string;

beforeAll(() => {
Expand All @@ -22,12 +23,12 @@ describe('create-nx-spring-boot', () => {
${false}
`('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => {
projectDirectory = createCLITestProject(
'create-nx-spring-boot',
'create-nx-quarkus',
`--prjName=bootapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --no-interactive`
);

// npm ls will fail if the package is not installed properly
execSync('npm ls @nxrocks/nx-spring-boot', {
execSync(`${getPackageManagerCommand().list} @nxrocks/nx-quarkus`, {
cwd: useNxWrapper
? join(projectDirectory, '/.nx/installation')
: projectDirectory,
Expand Down
17 changes: 10 additions & 7 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().add} @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 Expand Up @@ -83,7 +87,6 @@ describe('nx-quarkus e2e', () => {
`should create a quarkus '$projectType' with given options`,
async ({ projectType }) => {
const prjName = uniq('nx-quarkus');
const prjDir = projectType === 'application' ? 'apps' : 'libs';
const buildSystem = 'MAVEN';
const groupId = 'com.tinesoft';
const artifactId = 'api';
Expand Down
3 changes: 2 additions & 1 deletion e2e/nx-spring-boot-e2e/tests/create-nx-spring-boot.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getPackageManagerCommand } from '@nx/devkit';
import { hasNxWrapper, isNxWrapperInstalled } from '@nxrocks/common-cli';
import { createCLITestProject } from '@nxrocks/common-jvm/testing';
import { execSync } from 'child_process';
Expand Down Expand Up @@ -27,7 +28,7 @@ describe('create-nx-spring-boot', () => {
);

// 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: useNxWrapper
? join(projectDirectory, '/.nx/installation')
: projectDirectory,
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": {}
}
14 changes: 9 additions & 5 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
}
},
"version": {
"preVersionCommand": "pnpm dlx nx run-many -t build",
"preVersionCommand": "pnpm nx run-many -t build",
"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 1ff51b6

Please sign in to comment.