Skip to content

Commit 1d02167

Browse files
committed
chore: convert to inferred tasks
1 parent cb4bf57 commit 1d02167

File tree

31 files changed

+296
-389
lines changed

31 files changed

+296
-389
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

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

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

4848
- run: pnpm exec nx-cloud record -- nx format:check
49-
- run: pnpm exec nx affected -t lint test build e2e-ci --parallel=5 --exclude=smoke --codeCoverage
49+
- run: pnpm exec nx affected -t lint test-ci build e2e --parallel=5 --exclude=smoke

.github/workflows/smoke-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
env:
3535
NX_E2E_CI_CACHE_KEY: smoke-gha-${{ matrix.os }}-${{ matrix.node-version }}
3636
NX_RUN_GROUP: ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}
37-
run: pnpm nx test smoke
37+
run: pnpm nx e2e-ci smoke

.verdaccio/config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ logs:
3030

3131
publish:
3232
allow_offline: true # set offline to true to allow publish offline
33+
34+
listen: 0.0.0.0:4873 # listen on all addresses (INADDR_ANY)

e2e/nx-flutter-e2e/project.json

+1-11
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,5 @@
55
"sourceRoot": "e2e/nx-flutter-e2e/tests",
66
"tags": ["e2e"],
77
"implicitDependencies": ["nx-flutter"],
8-
"targets": {
9-
"e2e": {
10-
"executor": "@nx/jest:jest",
11-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
12-
"options": {
13-
"jestConfig": "e2e/nx-flutter-e2e/jest.config.ts",
14-
"runInBand": true
15-
},
16-
"dependsOn": ["^build"]
17-
}
18-
}
8+
"targets": {}
199
}

e2e/nx-ktor-e2e/project.json

+1-11
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,5 @@
55
"sourceRoot": "e2e/nx-ktor-e2e/tests",
66
"tags": ["e2e"],
77
"implicitDependencies": ["nx-ktor"],
8-
"targets": {
9-
"e2e": {
10-
"executor": "@nx/jest:jest",
11-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
12-
"options": {
13-
"jestConfig": "e2e/nx-ktor-e2e/jest.config.ts",
14-
"runInBand": true
15-
},
16-
"dependsOn": ["^build"]
17-
}
18-
}
8+
"targets": {}
199
}

e2e/nx-melos-e2e/project.json

+1-11
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,5 @@
55
"sourceRoot": "e2e/nx-melos-e2e/tests",
66
"tags": ["e2e"],
77
"implicitDependencies": ["nx-melos"],
8-
"targets": {
9-
"e2e": {
10-
"executor": "@nx/jest:jest",
11-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
12-
"options": {
13-
"jestConfig": "e2e/nx-melos-e2e/jest.config.ts",
14-
"runInBand": true
15-
},
16-
"dependsOn": ["^build"]
17-
}
18-
}
8+
"targets": {}
199
}

e2e/nx-micronaut-e2e/project.json

+16-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@
77
"implicitDependencies": ["nx-micronaut"],
88
"targets": {
99
"e2e": {
10-
"executor": "@nx/jest:jest",
11-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
10+
"inputs": [
11+
"default",
12+
"^default",
13+
"{workspaceRoot}/jest.preset.js",
14+
{
15+
"externalDependencies": ["jest"]
16+
}
17+
],
1218
"options": {
13-
"jestConfig": "e2e/nx-micronaut-e2e/jest.config.ts",
19+
"passWithNoTests": true,
1420
"runInBand": true
1521
},
16-
"dependsOn": ["^build"]
22+
"dependsOn": ["^build"],
23+
"configurations": {
24+
"ci": {
25+
"ci": true,
26+
"coverage": true
27+
}
28+
}
1729
}
1830
}
1931
}

e2e/nx-quarkus-e2e/project.json

+1-11
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,5 @@
55
"sourceRoot": "e2e/nx-quarkus-e2e/tests",
66
"tags": ["e2e"],
77
"implicitDependencies": ["nx-quarkus"],
8-
"targets": {
9-
"e2e": {
10-
"executor": "@nx/jest:jest",
11-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
12-
"options": {
13-
"jestConfig": "e2e/nx-quarkus-e2e/jest.config.ts",
14-
"runInBand": true
15-
},
16-
"dependsOn": ["^build"]
17-
}
18-
}
8+
"targets": {}
199
}

e2e/nx-spring-boot-e2e/project.json

+1-11
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,5 @@
55
"sourceRoot": "e2e/nx-spring-boot-e2e/tests",
66
"tags": ["e2e"],
77
"implicitDependencies": ["nx-spring-boot"],
8-
"targets": {
9-
"e2e": {
10-
"executor": "@nx/jest:jest",
11-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
12-
"options": {
13-
"jestConfig": "e2e/nx-spring-boot-e2e/jest.config.ts",
14-
"runInBand": true
15-
},
16-
"dependsOn": ["^build"]
17-
}
18-
}
8+
"targets": {}
199
}

e2e/smoke/project.json

+1-10
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,5 @@
1212
"nx-ktor",
1313
"nx-melos"
1414
],
15-
"targets": {
16-
"test": {
17-
"executor": "@nx/jest:jest",
18-
"outputs": ["{workspaceRoot}/coverage/e2e/smoke"],
19-
"options": {
20-
"jestConfig": "e2e/smoke/jest.config.ts"
21-
},
22-
"dependsOn": ["^build"]
23-
}
24-
}
15+
"targets": {}
2516
}

e2e/smoke/tests/smoke.spec.ts

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
import { getPackageManagerCommand } from '@nx/devkit';
2+
import {
3+
createTestProject,
4+
isLocalNxMatchingLatestFeatureVersion,
5+
runNxCommand,
6+
} from '@nxrocks/common/testing';
7+
import { execSync } from 'child_process';
8+
import { rmSync } from 'fs-extra';
9+
10+
process.env.NODE_OPTIONS = '--max-old-space-size=8192'; // to avoid oom error during the tests
11+
12+
let projectDirectory: string;
13+
14+
const execSyncOptions: (cwd?: string) => {
15+
silenceError?: boolean;
16+
env?: NodeJS.ProcessEnv;
17+
cwd?: string;
18+
} = (cwd: string = projectDirectory) => ({
19+
cwd: cwd,
20+
env: {
21+
...process.env,
22+
GIT_COMMITTER_NAME: 'Smoke Test CI',
23+
GIT_COMMITTER_EMAIL: 'no-reply@fake.com',
24+
GIT_AUTHOR_NAME: 'Smoke Test CI',
25+
GIT_AUTHOR_EMAIL: 'no-reply@fake.com',
26+
},
27+
silentError: 'false',
28+
});
29+
30+
const bootapp = 'bootapp';
31+
const bootlib = 'bootlib';
32+
const quarkusapp = 'quarkusapp';
33+
const quarkuslib = 'quarkuslib';
34+
const flutterapp = 'flutterapp';
35+
const flutterlib = 'flutterlib';
36+
const mnApp = 'mnapp';
37+
const krApp = 'krapp';
38+
39+
describe('nxrocks smoke tests', () => {
40+
afterEach(async () => {
41+
if (!process.env.KEEP_SMOKE_TESTS_DIR) {
42+
// Cleanup the test project
43+
projectDirectory &&
44+
rmSync(projectDirectory, {
45+
recursive: true,
46+
force: true,
47+
});
48+
} else {
49+
console.warn(
50+
`Keeping smoke test directory at '${projectDirectory}'. Do not forget to remove it when done!`
51+
);
52+
}
53+
});
54+
55+
it.each`
56+
pkgManager | workspaceVersion | pluginVersion
57+
${'npm'} | ${'latest'} | ${'0.0.0-e2e'}
58+
${'yarn'} | ${'latest'} | ${'0.0.0-e2e'}
59+
${'pnpm'} | ${'latest'} | ${'0.0.0-e2e'}
60+
${'npm'} | ${'local'} | ${'0.0.0-e2e'}
61+
${'yarn'} | ${'local'} | ${'0.0.0-e2e'}
62+
${'pnpm'} | ${'local'} | ${'0.0.0-e2e'}
63+
`(
64+
`should sucessfully run using '$workspaceVersion' Nx workspace, $pluginVersion plugins version and $pkgManager package manager`,
65+
async ({ pkgManager, workspaceVersion, pluginVersion }) => {
66+
if (!process.env.CI && !process.env.FORCE_SMOKE_TESTS) {
67+
console.log(
68+
'Skipping smoke test because not running on CI and FORCE_SMOKE_TESTS is not set'
69+
);
70+
return;
71+
}
72+
73+
if (
74+
workspaceVersion === 'latest' &&
75+
isLocalNxMatchingLatestFeatureVersion()
76+
) {
77+
console.log(
78+
'Skipping current test case because we are already using most recent version of Nx'
79+
);
80+
return;
81+
}
82+
83+
projectDirectory = createTestProject(
84+
pkgManager,
85+
'nxrocks-smoke',
86+
workspaceVersion
87+
);
88+
89+
execSync('git init', execSyncOptions());
90+
91+
const pluginPkgs = [
92+
`@nxrocks/nx-spring-boot@${pluginVersion}`,
93+
`@nxrocks/nx-quarkus@${pluginVersion}`,
94+
`@nxrocks/nx-micronaut@${pluginVersion}`,
95+
`@nxrocks/nx-flutter@${pluginVersion}`,
96+
`@nxrocks/nx-melos@${pluginVersion}`,
97+
`@nxrocks/nx-ktor@${pluginVersion}`,
98+
].join(' ');
99+
100+
execSync(
101+
`${getPackageManagerCommand(pkgManager).addDev} ${pluginPkgs}`,
102+
execSyncOptions(projectDirectory)
103+
);
104+
105+
runNxCommand(
106+
`generate @nxrocks/nx-spring-boot:new ${bootapp} --skip-format=false --projectType application --no-interactive`,
107+
pkgManager,
108+
execSyncOptions()
109+
);
110+
runNxCommand(
111+
`generate @nxrocks/nx-spring-boot:new ${bootlib} --skip-format=false --projectType library --no-interactive`,
112+
pkgManager,
113+
execSyncOptions()
114+
);
115+
116+
runNxCommand(
117+
`generate @nxrocks/nx-quarkus:new ${quarkusapp} --skip-format=false --projectType application --no-interactive`,
118+
pkgManager,
119+
execSyncOptions()
120+
);
121+
runNxCommand(
122+
`generate @nxrocks/nx-quarkus:new ${quarkuslib} --skip-format=false --projectType library --no-interactive`,
123+
pkgManager,
124+
execSyncOptions()
125+
);
126+
127+
runNxCommand(
128+
`generate @nxrocks/nx-micronaut:new ${mnApp} --skip-format=false --no-interactive`,
129+
pkgManager,
130+
execSyncOptions()
131+
);
132+
133+
runNxCommand(
134+
`generate @nxrocks/nx-melos:init --scriptNameSeparator=-`,
135+
pkgManager,
136+
execSyncOptions()
137+
);
138+
139+
runNxCommand(
140+
`generate @nxrocks/nx-ktor:new ${krApp} --skip-format=false --no-interactive`,
141+
pkgManager,
142+
execSyncOptions()
143+
);
144+
145+
runNxCommand(
146+
`generate @nxrocks/nx-flutter:new ${flutterapp} --template app --no-interactive`,
147+
pkgManager,
148+
execSyncOptions()
149+
);
150+
runNxCommand(
151+
`generate @nxrocks/nx-flutter:new ${flutterlib} --template plugin --no-interactive`,
152+
pkgManager,
153+
execSyncOptions()
154+
);
155+
156+
execSync(`git add -A`, execSyncOptions());
157+
execSync(`git commit -am "chore: scaffold projects"`, execSyncOptions());
158+
159+
runNxCommand(`clean ${bootapp}`, pkgManager, execSyncOptions());
160+
runNxCommand(`clean ${bootlib}`, pkgManager, execSyncOptions());
161+
runNxCommand(`clean ${quarkusapp}`, pkgManager, execSyncOptions());
162+
runNxCommand(`clean ${quarkuslib}`, pkgManager, execSyncOptions());
163+
runNxCommand(`clean ${mnApp}`, pkgManager, execSyncOptions());
164+
runNxCommand(`melos-bootstrap`, pkgManager, execSyncOptions());
165+
runNxCommand(`clean ${flutterapp}`, pkgManager, execSyncOptions());
166+
runNxCommand(`clean ${flutterlib}`, pkgManager, execSyncOptions());
167+
runNxCommand(`clean ${krApp}`, pkgManager, execSyncOptions());
168+
169+
expect(true).toBeTruthy();
170+
},
171+
3600000
172+
);
173+
});

0 commit comments

Comments
 (0)