Skip to content

Commit

Permalink
test: remove workaround (#714)
Browse files Browse the repository at this point in the history
* test: remove workaround

* build: work in progress

* build: work in progress

---------

Co-authored-by: khalilou88 <[email protected]>
  • Loading branch information
khalilou88 and khalilou88 authored Dec 26, 2023
1 parent f270f70 commit 22d1173
Show file tree
Hide file tree
Showing 19 changed files with 15 additions and 212 deletions.
14 changes: 0 additions & 14 deletions packages/internal/testing/src/lib/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,6 @@ export const getData = async (port = 8080, path = '') => {
return { status: response.status, message: response.data };
};

export function removeTmpFromGitignore() {
const filePath = path.join(process.cwd(), '.gitignore');
const fileContent = fs.readFileSync(filePath, 'utf-8');
const updatedFileContent = fileContent.replace('/tmp', '');
fs.writeFileSync(filePath, updatedFileContent);
}

export function addTmpToGitignore() {
const filePath = path.join(process.cwd(), '.gitignore');
const fileContent = fs.readFileSync(filePath, 'utf-8');
const updatedFileContent = fileContent.concat('\n/tmp');
fs.writeFileSync(filePath, updatedFileContent);
}

export function semver(s: string): {
major: number;
minor: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
addTmpToGitignore,
createTestWorkspace,
removeTmpFromGitignore,
} from '@jnxplus/internal/testing';
import { createTestWorkspace } from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
import {
checkFilesExist,
Expand All @@ -17,8 +13,7 @@ import { rmSync } from 'fs';

describe('nx-gradle gradle-root-directory kotlin dsl e2e', () => {
let workspaceDirectory: string;
const isCI =
process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';

const rootProjectName = uniq('boot-root-project-');

beforeAll(async () => {
Expand All @@ -35,16 +30,9 @@ describe('nx-gradle gradle-root-directory kotlin dsl e2e', () => {
await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --dsl kotlin --rootProjectName ${rootProjectName} --gradleRootDirectory deep/subdir`,
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
addTmpToGitignore,
createTestWorkspace,
removeTmpFromGitignore,
} from '@jnxplus/internal/testing';
import { createTestWorkspace } from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
import {
checkFilesExist,
Expand All @@ -17,8 +13,7 @@ import { rmSync } from 'fs';

describe('nx-gradle gradle-root-directory e2e', () => {
let workspaceDirectory: string;
const isCI =
process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';

const rootProjectName = uniq('boot-root-project-');

beforeAll(async () => {
Expand All @@ -35,16 +30,9 @@ describe('nx-gradle gradle-root-directory e2e', () => {
await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --rootProjectName ${rootProjectName} --gradleRootDirectory nx-gradle`,
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
addTmpToGitignore,
createTestWorkspace,
removeTmpFromGitignore,
} from '@jnxplus/internal/testing';
import { createTestWorkspace } from '@jnxplus/internal/testing';
import {
checkFilesExist,
readJson,
Expand All @@ -14,8 +10,7 @@ import { rmSync } from 'fs';

describe('nx-gradle kt-multiplatform kotlin dsl e2e', () => {
let workspaceDirectory: string;
const isCI =
process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';

const rootProjectName = uniq('boot-root-project-');

beforeAll(async () => {
Expand All @@ -32,16 +27,9 @@ describe('nx-gradle kt-multiplatform kotlin dsl e2e', () => {
await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --dsl kotlin --rootProjectName ${rootProjectName} --preset kotlin-multiplatform`,
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { normalizeName } from '@jnxplus/common';
import {
addTmpToGitignore,
checkFilesDoNotExist,
createTestWorkspace,
getData,
killPorts,
promisifiedTreeKill,
removeTmpFromGitignore,
runNxCommandUntil,
} from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
Expand Down Expand Up @@ -46,16 +44,9 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => {
await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --dsl kotlin --rootProjectName ${rootProjectName} --preset micronaut`,
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { normalizeName } from '@jnxplus/common';
import {
addTmpToGitignore,
checkFilesDoNotExist,
createTestWorkspace,
getData,
killPorts,
promisifiedTreeKill,
removeTmpFromGitignore,
runNxCommandUntil,
} from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
Expand Down Expand Up @@ -46,16 +44,9 @@ describe('nx-gradle micronaut e2e', () => {
await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --rootProjectName ${rootProjectName} --preset micronaut`,
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
16 changes: 2 additions & 14 deletions testing-projects/jnxplus-e2e/tests/nx-gradle/nx-gradle-kt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
addTmpToGitignore,
createTestWorkspace,
removeTmpFromGitignore,
} from '@jnxplus/internal/testing';
import { createTestWorkspace } from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
import {
checkFilesExist,
Expand All @@ -17,8 +13,7 @@ import { rmSync } from 'fs';

describe('nx-gradle all kotlin dsl e2e', () => {
let workspaceDirectory: string;
const isCI =
process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';

const rootProjectName = uniq('boot-root-project-');

beforeAll(async () => {
Expand All @@ -35,16 +30,9 @@ describe('nx-gradle all kotlin dsl e2e', () => {
await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --dsl kotlin --rootProjectName ${rootProjectName}`,
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
16 changes: 2 additions & 14 deletions testing-projects/jnxplus-e2e/tests/nx-gradle/nx-gradle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
addTmpToGitignore,
createTestWorkspace,
removeTmpFromGitignore,
} from '@jnxplus/internal/testing';
import { createTestWorkspace } from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
import {
checkFilesExist,
Expand All @@ -17,8 +13,7 @@ import { rmSync } from 'fs';

describe('nx-gradle all e2e', () => {
let workspaceDirectory: string;
const isCI =
process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';

const rootProjectName = uniq('boot-root-project-');

beforeAll(async () => {
Expand All @@ -35,16 +30,9 @@ describe('nx-gradle all e2e', () => {
await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --rootProjectName ${rootProjectName}`,
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { normalizeName } from '@jnxplus/common';
import {
addJVMMemory,
addTmpToGitignore,
checkFilesDoNotExist,
createTestWorkspace,
getData,
killPorts,
promisifiedTreeKill,
removeTmpFromGitignore,
runNxCommandUntil,
} from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
Expand Down Expand Up @@ -49,16 +47,9 @@ describe('nx-gradle quarkus kotlin dsl e2e', () => {
);

addJVMMemory();

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
9 changes: 0 additions & 9 deletions testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { normalizeName } from '@jnxplus/common';
import {
addJVMMemory,
addTmpToGitignore,
checkFilesDoNotExist,
createTestWorkspace,
getData,
killPorts,
promisifiedTreeKill,
removeTmpFromGitignore,
runNxCommandUntil,
} from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
Expand Down Expand Up @@ -49,16 +47,9 @@ describe('nx-gradle quarkus e2e', () => {
);

addJVMMemory();

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import * as path from 'path';

import { normalizeName } from '@jnxplus/common';
import {
addTmpToGitignore,
checkFilesDoNotExist,
createTestWorkspace,
getData,
killPorts,
promisifiedTreeKill,
removeTmpFromGitignore,
runNxCommandUntil,
} from '@jnxplus/internal/testing';
import { execSync } from 'child_process';
Expand Down Expand Up @@ -47,16 +45,9 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => {
await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --dsl kotlin --rootProjectName ${rootProjectName} --preset spring-boot`,
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { normalizeName } from '@jnxplus/common';
import {
addTmpToGitignore,
checkFilesDoNotExist,
createTestWorkspace,
getData,
killPorts,
promisifiedTreeKill,
removeTmpFromGitignore,
runNxCommandUntil,
} from '@jnxplus/internal/testing';
import { names } from '@nx/devkit';
Expand Down Expand Up @@ -60,16 +58,9 @@ describe('nx-gradle spring-boot e2e', () => {
);

await runNxCommandAsync('generate @jnxplus/nx-checkstyle:init');

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}
// Cleanup the test project
rmSync(workspaceDirectory, {
recursive: true,
Expand Down
Loading

0 comments on commit 22d1173

Please sign in to comment.