diff --git a/.github/workflows/plugin-e2e.yml b/.github/workflows/plugin-e2e.yml index 0aff79ad0..84016b6a7 100644 --- a/.github/workflows/plugin-e2e.yml +++ b/.github/workflows/plugin-e2e.yml @@ -14,6 +14,7 @@ on: - nx-gradle micronaut e2e - nx-gradle micronaut kotlin dsl e2e - nx-gradle all e2e + - nx-gradle version-catalog e2e - nx-gradle all kotlin dsl e2e - nx-gradle quarkus e2e - nx-gradle quarkus kotlin dsl e2e diff --git a/testing-projects/e2e/nx-gradle-catalog-e2e/jest.config.js b/testing-projects/e2e/nx-gradle-catalog-e2e/jest.config.js deleted file mode 100644 index bd6f350d3..000000000 --- a/testing-projects/e2e/nx-gradle-catalog-e2e/jest.config.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - displayName: 'nx-gradle-catalog-e2e', - preset: '../../../jest.preset.js', - globals: {}, - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - }, - ], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: - '../../../coverage/e2e/nx-gradle-catalog-e2e', -}; diff --git a/testing-projects/e2e/nx-gradle-catalog-e2e/project.json b/testing-projects/e2e/nx-gradle-catalog-e2e/project.json deleted file mode 100644 index 691026ae2..000000000 --- a/testing-projects/e2e/nx-gradle-catalog-e2e/project.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "nx-gradle-catalog-e2e", - "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "projectType": "application", - "sourceRoot": "testing-projects/e2e/nx-gradle-catalog-e2e/src", - "targets": { - "e2e": { - "executor": "@nx/jest:jest", - "options": { - "jestConfig": "testing-projects/e2e/nx-gradle-catalog-e2e/jest.config.js", - "runInBand": true - }, - "dependsOn": ["nx-gradle:build"] - } - }, - "tags": [], - "implicitDependencies": ["nx-gradle"] -} diff --git a/testing-projects/e2e/nx-gradle-catalog-e2e/tests/nx-gradle-catalog.spec.ts b/testing-projects/e2e/nx-gradle-catalog-e2e/tests/nx-gradle-catalog.spec.ts deleted file mode 100644 index 3f79a675e..000000000 --- a/testing-projects/e2e/nx-gradle-catalog-e2e/tests/nx-gradle-catalog.spec.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { names, workspaceRoot } from '@nx/devkit'; -import { - checkFilesExist, - cleanup, - readFile, - readJson, - runNxCommandAsync, - tmpProjPath, - uniq, - updateFile, -} from '@nx/plugin/testing'; -import * as fse from 'fs-extra'; -import * as path from 'path'; - -import { checkstyleVersion } from '@jnxplus/common'; -import { - addTmpToGitignore, - patchPackageJson, - patchRootPackageJson, - removeTmpFromGitignore, - runNxNewCommand, - runPackageManagerInstallLinks, -} from '@jnxplus/internal/testing'; - -describe('nx-gradle version-catalog e2e', () => { - const isCI = - process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true'; - const isWin = process.platform === 'win32'; - const isMacOs = process.platform === 'darwin'; - const rootProjectName = uniq('boot-root-project-'); - - beforeAll(async () => { - fse.ensureDirSync(tmpProjPath()); - cleanup(); - runNxNewCommand('', true); - - const pluginName = '@jnxplus/nx-gradle'; - const nxGradleDistAbsolutePath = path.join( - workspaceRoot, - 'dist', - 'packages', - 'nx-gradle' - ); - - const commonDistAbsolutePath = path.join( - workspaceRoot, - 'dist', - 'packages', - 'common' - ); - - const gradleDistAbsolutePath = path.join( - workspaceRoot, - 'dist', - 'packages', - 'gradle' - ); - - patchRootPackageJson(pluginName, nxGradleDistAbsolutePath); - patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath); - patchRootPackageJson('@jnxplus/gradle', gradleDistAbsolutePath); - - patchPackageJson( - gradleDistAbsolutePath, - '@jnxplus/common', - commonDistAbsolutePath - ); - - patchPackageJson( - nxGradleDistAbsolutePath, - '@jnxplus/common', - commonDistAbsolutePath - ); - patchPackageJson( - nxGradleDistAbsolutePath, - '@jnxplus/gradle', - gradleDistAbsolutePath - ); - - runPackageManagerInstallLinks(); - - await runNxCommandAsync( - `generate @jnxplus/nx-gradle:init --dsl kotlin --rootProjectName ${rootProjectName} --preset spring-boot --versionManagement version-catalog` - ); - - if (isCI) { - removeTmpFromGitignore(); - } - }, 120000); - - afterAll(async () => { - if (isCI) { - addTmpToGitignore(); - } - - // `nx reset` kills the daemon, and performs - // some work which can help clean up e2e leftovers - await runNxCommandAsync('reset'); - }); - - it('should set NX_VERBOSE_LOGGING to true', async () => { - expect(process.env['NX_VERBOSE_LOGGING']).toBe('true'); - }, 120000); - - it('should use dsl option when initiating the workspace', async () => { - // Making sure the package.json file contains the @jnxplus/nx-gradle dependency - const packageJson = readJson('package.json'); - expect(packageJson.devDependencies['@jnxplus/nx-gradle']).toBeTruthy(); - - // Making sure the nx.json file contains the @jnxplus/nx-gradle inside the plugins section - const nxJson = readJson('nx.json'); - expect(nxJson.plugins.includes('@jnxplus/nx-gradle')).toBeTruthy(); - - expect(() => - checkFilesExist( - 'gradle/wrapper/gradle-wrapper.jar', - 'gradle/wrapper/gradle-wrapper.properties', - 'gradlew', - 'gradlew.bat', - 'gradle.properties', - 'settings.gradle.kts', - 'tools/linters/checkstyle.xml' - ) - ).not.toThrow(); - - expect(() => - checkFilesExist( - `node_modules/@jnxplus/tools/linters/checkstyle/checkstyle-${checkstyleVersion}-all.jar`, - `node_modules/@jnxplus/tools/linters/ktlint/ktlint` - ) - ).not.toThrow(); - }, 120000); - - it('shoud works', async () => { - const name = uniq('app-'); - - await runNxCommandAsync(`generate @jnxplus/nx-gradle:app ${name}`); - }, 240000); -}); diff --git a/testing-projects/e2e/nx-gradle-catalog-e2e/tsconfig.json b/testing-projects/e2e/nx-gradle-catalog-e2e/tsconfig.json deleted file mode 100644 index b36041a2a..000000000 --- a/testing-projects/e2e/nx-gradle-catalog-e2e/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/testing-projects/e2e/nx-gradle-catalog-e2e/tsconfig.spec.json b/testing-projects/e2e/nx-gradle-catalog-e2e/tsconfig.spec.json deleted file mode 100644 index 5936dfcb1..000000000 --- a/testing-projects/e2e/nx-gradle-catalog-e2e/tsconfig.spec.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] -} diff --git a/testing-projects/jnxplus-e2e/tests/nx-gradle/nx-gradle-catalog.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-gradle/nx-gradle-catalog.spec.ts new file mode 100644 index 000000000..d35cddd2d --- /dev/null +++ b/testing-projects/jnxplus-e2e/tests/nx-gradle/nx-gradle-catalog.spec.ts @@ -0,0 +1,83 @@ +import { + addTmpToGitignore, + createTestWorkspace, + removeTmpFromGitignore, +} from '@jnxplus/internal/testing'; +import { + checkFilesExist, + readJson, + runNxCommandAsync, + uniq, +} from '@nx/plugin/testing'; +import { execSync } from 'child_process'; +import { rmSync } from 'fs'; + +describe('nx-gradle version-catalog e2e', () => { + let workspaceDirectory: string; + const isCI = + process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true'; + const rootProjectName = uniq('root-project-'); + + beforeAll(async () => { + workspaceDirectory = createTestWorkspace(); + + // 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 -D @jnxplus/nx-gradle@e2e`, { + cwd: workspaceDirectory, + stdio: 'inherit', + env: process.env, + }); + + await runNxCommandAsync( + `generate @jnxplus/nx-gradle:init --dsl kotlin --rootProjectName ${rootProjectName} --preset spring-boot --versionManagement version-catalog`, + ); + + if (isCI) { + removeTmpFromGitignore(); + } + }, 120000); + + afterAll(async () => { + if (isCI) { + addTmpToGitignore(); + } + // Cleanup the test project + rmSync(workspaceDirectory, { + recursive: true, + force: true, + }); + }); + + it('should set NX_VERBOSE_LOGGING to true', async () => { + expect(process.env['NX_VERBOSE_LOGGING']).toBe('true'); + }, 120000); + + it('should use dsl option when initiating the workspace', async () => { + // Making sure the package.json file contains the @jnxplus/nx-gradle dependency + const packageJson = readJson('package.json'); + expect(packageJson.devDependencies['@jnxplus/nx-gradle']).toBeTruthy(); + + // Making sure the nx.json file contains the @jnxplus/nx-gradle inside the plugins section + const nxJson = readJson('nx.json'); + expect(nxJson.plugins.includes('@jnxplus/nx-gradle')).toBeTruthy(); + + expect(() => + checkFilesExist( + 'gradle/wrapper/gradle-wrapper.jar', + 'gradle/wrapper/gradle-wrapper.properties', + 'gradlew', + 'gradlew.bat', + 'gradle.properties', + 'settings.gradle.kts', + 'tools/linters/checkstyle.xml', + ), + ).not.toThrow(); + }, 120000); + + it('shoud works', async () => { + const name = uniq('app-'); + + await runNxCommandAsync(`generate @jnxplus/nx-gradle:app ${name}`); + }, 240000); +});