Skip to content

Commit 3166645

Browse files
author
John Doe
committed
chore: refine e2e and int test targets
1 parent 822a323 commit 3166645

File tree

23 files changed

+114
-97
lines changed

23 files changed

+114
-97
lines changed

code-pushup.preset.ts

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,16 @@ export const eslintCategories: CategoryConfig[] = [
100100
export function getJsDocsCategories(
101101
config: JsDocsPluginConfig,
102102
): CategoryConfig[] {
103+
const filterOptions =
104+
typeof config === 'string' || Array.isArray(config)
105+
? {}
106+
: { onlyAudits: config.onlyAudits, skipAudits: config.skipAudits };
103107
return [
104108
{
105109
slug: 'docs',
106110
title: 'Documentation',
107111
description: 'Measures how much of your code is **documented**.',
108-
refs: filterGroupsByOnlyAudits(groups, config).map(group => ({
112+
refs: filterGroupsByOnlyAudits(groups, filterOptions).map(group => ({
109113
weight: 1,
110114
type: 'group',
111115
plugin: PLUGIN_SLUG,
@@ -159,12 +163,13 @@ export const jsDocsCoreConfig = (
159163

160164
export const eslintCoreConfigNx = async (
161165
projectName?: string,
166+
options?: { exclude?: string[] },
162167
): Promise<CoreConfig> => ({
163168
plugins: [
164169
await eslintPlugin(
165170
await (projectName
166171
? eslintConfigFromNxProject(projectName)
167-
: eslintConfigFromAllNxProjects()),
172+
: eslintConfigFromAllNxProjects(options)),
168173
),
169174
],
170175
categories: eslintCategories,
@@ -178,13 +183,42 @@ export const typescriptPluginConfig = async (
178183
});
179184

180185
export const coverageCoreConfigNx = async (
181-
projectName?: string,
186+
projectOrConfig?:
187+
| string
188+
| {
189+
projectName: string;
190+
targetNames: string[];
191+
},
192+
options?: { exclude?: string[] },
182193
): Promise<CoreConfig> => {
194+
const projectName =
195+
typeof projectOrConfig === 'string'
196+
? projectOrConfig
197+
: projectOrConfig?.projectName;
198+
const targetNames =
199+
typeof projectOrConfig === 'object' && projectOrConfig?.targetNames?.length
200+
? projectOrConfig.targetNames
201+
: ['unit-test', 'int-test'];
202+
183203
if (projectName) {
184204
throw new Error('coverageCoreConfigNx for single projects not implemented');
185205
}
186-
const targetNames = ['unit-test', 'int-test'];
206+
187207
const targetArgs = ['-t', ...targetNames];
208+
209+
// Compute projects list and apply exclude for efficient run-many execution
210+
const { createProjectGraphAsync } = await import('@nx/devkit');
211+
const { nodes } = await createProjectGraphAsync({ exitOnError: false });
212+
const projectsWithTargets = Object.values(nodes).filter(node =>
213+
targetNames.some(t => node.data.targets && t in node.data.targets),
214+
);
215+
const filteredProjects = options?.exclude?.length
216+
? projectsWithTargets.filter(node => !options.exclude!.includes(node.name))
217+
: projectsWithTargets;
218+
const projectsArg = `--projects=${filteredProjects
219+
.map(p => p.name)
220+
.join(',')}`;
221+
188222
return {
189223
plugins: [
190224
await coveragePlugin({
@@ -194,9 +228,10 @@ export const coverageCoreConfigNx = async (
194228
'nx',
195229
projectName ? `run --project ${projectName}` : 'run-many',
196230
...targetArgs,
231+
projectsArg,
197232
],
198233
},
199-
reports: await getNxCoveragePaths(targetNames),
234+
reports: await getNxCoveragePaths(targetNames, false, options?.exclude),
200235
}),
201236
],
202237
categories: coverageCategories,

e2e/ci-e2e/project.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
"projectType": "application",
66
"targets": {
77
"lint": {},
8-
"e2e": {
9-
"executor": "@nx/vite:test",
10-
"options": {
11-
"configFile": "e2e/ci-e2e/vitest.e2e.config.ts"
12-
}
13-
}
8+
"e2e": {}
149
},
1510
"implicitDependencies": ["cli", "ci"],
1611
"tags": ["scope:tooling", "type:e2e"]

e2e/cli-e2e/project.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"sourceRoot": "e2e/cli-e2e/src",
55
"projectType": "application",
6+
"tags": ["scope:core", "scope:plugin", "type:e2e"],
7+
"implicitDependencies": ["cli"],
68
"targets": {
79
"lint": {},
8-
"e2e": {
9-
"executor": "@nx/vite:test",
10-
"options": {
11-
"configFile": "e2e/cli-e2e/vitest.e2e.config.ts"
12-
}
13-
}
14-
},
15-
"implicitDependencies": ["cli"],
16-
"tags": ["scope:core", "scope:plugin", "type:e2e"]
10+
"e2e": {}
11+
}
1712
}

e2e/create-cli-e2e/project.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"sourceRoot": "examples/create-cli-e2e/src",
55
"projectType": "application",
6+
"tags": ["scope:tooling", "type:e2e"],
7+
"implicitDependencies": ["create-cli"],
68
"targets": {
79
"lint": {},
8-
"e2e": {
9-
"executor": "@nx/vite:test",
10-
"options": {
11-
"keepServerRunning": true,
12-
"configFile": "e2e/create-cli-e2e/vitest.e2e.config.ts"
13-
}
14-
}
15-
},
16-
"implicitDependencies": ["create-cli"],
17-
"tags": ["scope:tooling", "type:e2e"]
10+
"e2e": {}
11+
}
1812
}

e2e/nx-plugin-e2e/project.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"sourceRoot": "e2e/nx-plugin-e2e/src",
55
"projectType": "application",
6+
"tags": ["scope:tooling", "type:e2e"],
7+
"implicitDependencies": ["test-utils", "nx-plugin"],
68
"targets": {
79
"lint": {},
8-
"e2e": {
9-
"executor": "@nx/vite:test",
10-
"options": {
11-
"configFile": "e2e/nx-plugin-e2e/vitest.e2e.config.ts"
12-
}
13-
}
14-
},
15-
"implicitDependencies": ["test-utils", "nx-plugin"],
16-
"tags": ["scope:tooling", "type:e2e"]
10+
"e2e": {}
11+
}
1712
}

e2e/plugin-coverage-e2e/project.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"sourceRoot": "e2e/plugin-coverage-e2e/src",
55
"projectType": "application",
6+
"tags": ["scope:plugin", "type:e2e"],
7+
"implicitDependencies": ["cli", "plugin-coverage"],
68
"targets": {
79
"lint": {},
8-
"e2e": {
9-
"executor": "@nx/vite:test",
10-
"options": {
11-
"configFile": "e2e/plugin-coverage-e2e/vitest.e2e.config.ts"
12-
}
13-
}
14-
},
15-
"implicitDependencies": ["cli", "plugin-coverage"],
16-
"tags": ["scope:plugin", "type:e2e"]
10+
"e2e": {}
11+
}
1712
}

e2e/plugin-eslint-e2e/project.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"sourceRoot": "e2e/plugin-eslint-e2e/src",
55
"projectType": "application",
6+
"tags": ["scope:plugin", "type:e2e"],
7+
"implicitDependencies": ["cli", "plugin-eslint"],
68
"targets": {
79
"lint": {},
8-
"e2e": {
9-
"executor": "@nx/vite:test",
10-
"options": {
11-
"configFile": "e2e/plugin-eslint-e2e/vitest.e2e.config.ts"
12-
}
13-
}
14-
},
15-
"implicitDependencies": ["cli", "plugin-eslint"],
16-
"tags": ["scope:plugin", "type:e2e"]
10+
"e2e": {}
11+
}
1712
}

e2e/plugin-js-packages-e2e/project.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"projectType": "application",
55
"sourceRoot": "e2e/plugin-js-packages-e2e/src",
6+
"tags": ["scope:plugin", "type:e2e"],
67
"implicitDependencies": ["cli", "plugin-js-packages"],
78
"targets": {
89
"lint": {},
9-
"e2e": {
10-
"executor": "@nx/vite:test",
11-
"options": {
12-
"configFile": "e2e/plugin-eslint-e2e/vitest.e2e.config.ts"
13-
}
14-
}
15-
},
16-
"tags": ["scope:plugin", "type:e2e"]
10+
"e2e": {}
11+
}
1712
}

examples/plugins/project.json

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,18 @@
44
"sourceRoot": "examples/plugins/src",
55
"projectType": "library",
66
"targets": {
7-
"build": {
8-
"executor": "@nx/js:tsc",
9-
"outputs": ["{options.outputPath}"],
10-
"options": {
11-
"outputPath": "dist/examples/plugins",
12-
"main": "examples/plugins/src/index.ts",
13-
"tsConfig": "examples/plugins/tsconfig.lib.json",
14-
"assets": ["examples/plugins/*.md"]
15-
}
16-
},
17-
"lint": {
18-
"executor": "@nx/linter:eslint",
19-
"outputs": ["{options.outputFile}"],
20-
"options": {
21-
"lintFilePatterns": ["examples/plugins/**/*.ts"]
22-
}
23-
},
24-
"unit-test": {
25-
"executor": "@nx/vite:test",
26-
"outputs": ["{options.reportsDirectory}"],
27-
"options": {
28-
"configFile": "examples/plugins/vitest.unit.config.ts",
29-
"reportsDirectory": "../../coverage/examples-plugins/unit-tests"
30-
}
31-
},
7+
"build": {},
8+
"lint": {},
9+
"unit-test": {},
3210
"int-test": {
11+
"cache": true,
12+
"outputs": ["{workspaceRoot}/coverage/{projectName}/int-tests/lcov.info"],
3313
"executor": "@nx/vite:test",
34-
"outputs": ["{options.reportsDirectory}"],
3514
"options": {
36-
"configFile": "examples/plugins/vitest.int.config.ts",
37-
"reportsDirectory": "../../coverage/examples-plugins/int-tests"
15+
"configFile": "{projectRoot}/vitest.int.config.ts",
16+
"coverage": {
17+
"enabled": true
18+
}
3819
}
3920
},
4021
"run-collect": {

nx.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
},
1717
"unit-test": {
1818
"cache": true,
19+
"outputs": [
20+
"{workspaceRoot}/coverage/{projectName}/unit-tests/lcov.info"
21+
],
1922
"executor": "@nx/vite:test",
2023
"options": {
2124
"configFile": "{projectRoot}/vitest.unit.config.ts",
@@ -26,6 +29,7 @@
2629
},
2730
"int-test": {
2831
"cache": true,
32+
"outputs": ["{workspaceRoot}/coverage/{projectName}/int-tests/lcov.info"],
2933
"executor": "@nx/vite:test",
3034
"options": {
3135
"configFile": "{projectRoot}/vitest.int.config.ts",
@@ -34,6 +38,13 @@
3438
}
3539
}
3640
},
41+
"e2e": {
42+
"dependsOn": ["^build"],
43+
"executor": "@nx/vite:test",
44+
"options": {
45+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
46+
}
47+
},
3748
"lint": {
3849
"inputs": ["default", "{workspaceRoot}/eslint.config.?(c)js"],
3950
"executor": "@nx/linter:eslint",
@@ -47,9 +58,6 @@
4758
]
4859
}
4960
},
50-
"e2e": {
51-
"dependsOn": ["^build"]
52-
},
5361
"nxv-pkg-install": {
5462
"parallelism": false
5563
},

0 commit comments

Comments
 (0)