Skip to content

Commit

Permalink
test: add more smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khalilou88 committed Nov 18, 2023
1 parent 5c91425 commit 1ec2d39
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/plugin-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ on:
- nx-gradle spring-boot smoke
- nx-maven
- nx-maven micronaut smoke
- nx-maven default smoke
- nx-maven micronaut bom smoke
- nx-maven quarkus smoke
- nx-maven spring-boot smoke
- nx-maven spring-boot bom smoke
os:
type: choice
description: Os
Expand Down
140 changes: 140 additions & 0 deletions testing-projects/jnxplus-smoke/tests/nx-maven/micronaut-bom.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { uniq } from '@nx/plugin/testing';
import { readJson } from 'fs-extra';

import { execSync, ExecSyncOptions } from 'child_process';
import { join } from 'path';

import { dirSync } from 'tmp';

let smokeDirectory: string;
let cleanup: () => void;

const execSyncOptions: () => ExecSyncOptions = () => ({
cwd: join(smokeDirectory, 'test'),
env: {
...process.env,
GIT_COMMITTER_NAME: 'Smoke Test CI',
GIT_COMMITTER_EMAIL: '[email protected]',
GIT_AUTHOR_NAME: 'Smoke Test CI',
GIT_AUTHOR_EMAIL: '[email protected]',
},
stdio: 'inherit',
});

const libsParentProject = uniq('libs-parent-project-');
const appsParentProject = uniq('apps-parent-project-');

const testApp = uniq('test-app-');
const testLib = uniq('test-lib-');

const testApp2 = uniq('test-app2-');
const testLib2 = uniq('test-lib2-');
const testApp3 = uniq('test-app3-');
const testApp4 = uniq('test-app4-');
const testApp5 = uniq('test-app5-');
const testLib5 = uniq('test-lib5-');
const testApp6 = uniq('test-app6-');

describe('nx-maven micronaut bom smoke', () => {
beforeEach(async () => {
({ name: smokeDirectory, removeCallback: cleanup } = dirSync({
unsafeCleanup: true,
}));
});

afterEach(async () => {
cleanup();
});

it('should work', async () => {
execSync(
'npx create-nx-workspace@latest test --preset empty --nxCloud false',
{
cwd: smokeDirectory,
env: process.env,
stdio: 'inherit',
},
);

execSync('git init', execSyncOptions());

execSync('npm i --save-dev @jnxplus/nx-maven', execSyncOptions());

execSync('npx nx generate @jnxplus/nx-maven:init', execSyncOptions());

execSync(
`npx nx generate @jnxplus/nx-maven:parent-project ${libsParentProject} --projectType library --framework micronaut`,
execSyncOptions(),
);

execSync(
`npx nx generate @jnxplus/nx-maven:parent-project ${appsParentProject} --parentProject ${libsParentProject} --framework none`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp} --parentProject ${appsParentProject} --framework micronaut`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:lib ${testLib} --parentProject ${libsParentProject} --projects ${testApp} --framework micronaut`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp2} --parentProject ${appsParentProject} --framework micronaut`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp3} --parentProject ${appsParentProject} --framework micronaut`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp4} --parentProject ${appsParentProject} --framework micronaut`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:lib ${testLib2} --parentProject ${libsParentProject} --projects ${testApp2},${testApp3},${testApp4} --framework micronaut`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp5} --parentProject ${appsParentProject} --framework micronaut --language kotlin`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp6} --parentProject ${appsParentProject} --framework micronaut --language kotlin`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:lib ${testLib5} --parentProject ${libsParentProject} --framework micronaut --language kotlin --projects ${testApp5},${testApp6}`,
execSyncOptions(),
);

execSync(`npx nx test ${testLib}`, execSyncOptions());

execSync(`npx nx run-many --target=build --parallel=1`, execSyncOptions());

execSync(`npx nx graph --file=dep-graph.json`, execSyncOptions());

const depGraphJson = await readJson(
join(smokeDirectory, 'test', 'dep-graph.json'),
);
expect(depGraphJson.graph.nodes[testApp]).toBeDefined();
expect(depGraphJson.graph.nodes[testLib]).toBeDefined();

expect(depGraphJson.graph.dependencies[testApp]).toContainEqual({
type: 'static',
source: testApp,
target: testLib,
});

execSync(`git commit -am "chore: scaffold projects"`, execSyncOptions());
}, 1500000);
});
30 changes: 24 additions & 6 deletions testing-projects/jnxplus-smoke/tests/nx-maven/micronaut.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ const execSyncOptions: () => ExecSyncOptions = () => ({
stdio: 'inherit',
});

const testApp = uniq('test-app');
const testLib = uniq('test-lib');
const testApp = uniq('test-app-');
const testLib = uniq('test-lib-');

const testApp2 = uniq('test-app2');
const testLib2 = uniq('test-lib2');
const testApp3 = uniq('test-app3');
const testApp4 = uniq('test-app4');
const testApp2 = uniq('test-app2-');
const testLib2 = uniq('test-lib2-');
const testApp3 = uniq('test-app3-');
const testApp4 = uniq('test-app4-');
const testApp5 = uniq('test-app5-');
const testLib5 = uniq('test-lib5-');
const testApp6 = uniq('test-app6-');

describe('nx-maven micronaut smoke', () => {
beforeEach(async () => {
Expand Down Expand Up @@ -82,6 +85,21 @@ describe('nx-maven micronaut smoke', () => {
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp5} --framework micronaut --language kotlin`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp6} --framework micronaut --language kotlin`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:lib ${testLib5} --framework micronaut --language kotlin --projects ${testApp5},${testApp6}`,
execSyncOptions(),
);

execSync(`npx nx test ${testLib}`, execSyncOptions());

execSync(`npx nx run-many --target=build --parallel=1`, execSyncOptions());
Expand Down
30 changes: 24 additions & 6 deletions testing-projects/jnxplus-smoke/tests/nx-maven/quarkus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ const execSyncOptions: () => ExecSyncOptions = () => ({
const libsParentProject = uniq('libs-parent-project-');
const appsParentProject = uniq('apps-parent-project-');

const testApp = uniq('test-app');
const testLib = uniq('test-lib');
const testApp = uniq('test-app-');
const testLib = uniq('test-lib-');

const testApp2 = uniq('test-app2');
const testLib2 = uniq('test-lib2');
const testApp3 = uniq('test-app3');
const testApp4 = uniq('test-app4');
const testApp2 = uniq('test-app2-');
const testLib2 = uniq('test-lib2-');
const testApp3 = uniq('test-app3-');
const testApp4 = uniq('test-app4-');
const testApp5 = uniq('test-app5-');
const testLib5 = uniq('test-lib5-');
const testApp6 = uniq('test-app6-');

describe('nx-maven quarkus smoke', () => {
beforeEach(async () => {
Expand Down Expand Up @@ -99,6 +102,21 @@ describe('nx-maven quarkus smoke', () => {
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp5} --parentProject ${appsParentProject} --framework micronaut --language kotlin`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp6} --parentProject ${appsParentProject} --framework micronaut --language kotlin`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:lib ${testLib5} --parentProject ${libsParentProject} --framework micronaut --language kotlin --projects ${testApp5},${testApp6}`,
execSyncOptions(),
);

execSync(`npx nx test ${testLib}`, execSyncOptions());

execSync(`npx nx run-many --target=build --parallel=1`, execSyncOptions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ const libsParentProject = uniq('libs-parent-project-');
const appsParentProject = uniq('apps-parent-project-');

const testApp = uniq('test-app-');
const testLib = uniq('test-lib');
const testLib = uniq('test-lib-');

const testApp2 = uniq('test-app2-');
const testLib2 = uniq('test-lib2-');
const testApp3 = uniq('test-app3-');
const testApp4 = uniq('test-app4-');
const testApp5 = uniq('test-app5-');
const testLib5 = uniq('test-lib5-');
const testApp6 = uniq('test-app6-');

describe('nx-maven default smoke', () => {
describe('nx-maven spring-boot bom smoke', () => {
beforeEach(async () => {
({ name: smokeDirectory, removeCallback: cleanup } = dirSync({
unsafeCleanup: true,
Expand Down Expand Up @@ -80,7 +83,7 @@ describe('nx-maven default smoke', () => {
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp2} --parentProject ${appsParentProject}`,
`npx nx g @jnxplus/nx-maven:application ${testApp2} --parentProject ${appsParentProject} --packaging war`,
execSyncOptions(),
);

Expand All @@ -99,6 +102,21 @@ describe('nx-maven default smoke', () => {
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp5} --parentProject ${appsParentProject} --framework spring-boot --language kotlin`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:application ${testApp6} --parentProject ${appsParentProject} --framework spring-boot --language kotlin --packaging war`,
execSyncOptions(),
);

execSync(
`npx nx g @jnxplus/nx-maven:lib ${testLib5} --parentProject ${libsParentProject} --framework spring-boot --language kotlin --projects ${testApp5},${testApp6}`,
execSyncOptions(),
);

execSync(`npx nx test ${testLib}`, execSyncOptions());

execSync(`npx nx run-many --target=build --parallel=1`, execSyncOptions());
Expand Down
20 changes: 10 additions & 10 deletions testing-projects/jnxplus-smoke/tests/nx-maven/spring-boot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ const execSyncOptions: () => ExecSyncOptions = () => ({
stdio: 'inherit',
});

const testApp = uniq('test-app');
const testLib = uniq('test-lib');

const testApp2 = uniq('test-app2');
const testLib2 = uniq('test-lib2');
const testApp3 = uniq('test-app3');
const testApp4 = uniq('test-app4');
const testApp5 = uniq('test-app5');
const testLib5 = uniq('test-lib5');
const testApp6 = uniq('test-app6');
const testApp = uniq('test-app-');
const testLib = uniq('test-lib-');

const testApp2 = uniq('test-app2-');
const testLib2 = uniq('test-lib2-');
const testApp3 = uniq('test-app3-');
const testApp4 = uniq('test-app4-');
const testApp5 = uniq('test-app5-');
const testLib5 = uniq('test-lib5-');
const testApp6 = uniq('test-app6-');

describe('nx-maven spring-boot smoke', () => {
beforeEach(async () => {
Expand Down

0 comments on commit 1ec2d39

Please sign in to comment.