Skip to content

Commit 2ae961a

Browse files
BioPhotonJohn Doe
andauthored
chore: refactor unit-test and int-test targets (#1061)
**This PR includes:** - add `defaultTargets` for `unit-test`, `int-test` - adjust all `unit-test`, `int-test` targets to generate coverage by default - remove `--coverage.enabled` and `--skipNxCache` form CP targets - make CP reuse coverage data from `unit-test`, `int-test` - added `passWithNoTests` to all targets - removes unused `int-test` targets > [!note] > This PR brings the execution time **from 19m down to max 9m** for the whole cp report. 🔥 --------- Co-authored-by: John Doe <john.doe@example.com>
1 parent 82ed623 commit 2ae961a

File tree

30 files changed

+83
-326
lines changed

30 files changed

+83
-326
lines changed

code-pushup.preset.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import eslintPlugin, {
1111
eslintConfigFromNxProject,
1212
} from './packages/plugin-eslint/src/index.js';
1313
import jsPackagesPlugin from './packages/plugin-js-packages/src/index.js';
14-
import jsDocsPlugin, {
15-
JsDocsPluginConfig,
16-
} from './packages/plugin-jsdocs/src/index.js';
14+
import jsDocsPlugin from './packages/plugin-jsdocs/src/index.js';
15+
import type { JsDocsPluginTransformedConfig } from './packages/plugin-jsdocs/src/lib/config.js';
1716
import {
1817
PLUGIN_SLUG,
1918
groups,
@@ -98,7 +97,7 @@ export const eslintCategories: CategoryConfig[] = [
9897
];
9998

10099
export function getJsDocsCategories(
101-
config: JsDocsPluginConfig,
100+
config: JsDocsPluginTransformedConfig,
102101
): CategoryConfig[] {
103102
return [
104103
{
@@ -147,7 +146,7 @@ export const lighthouseCoreConfig = async (
147146
};
148147

149148
export const jsDocsCoreConfig = (
150-
config: JsDocsPluginConfig | string[],
149+
config: JsDocsPluginTransformedConfig | string[],
151150
): CoreConfig => ({
152151
plugins: [
153152
jsDocsPlugin(Array.isArray(config) ? { patterns: config } : config),
@@ -180,28 +179,25 @@ export const typescriptPluginConfig = async (
180179
export const coverageCoreConfigNx = async (
181180
projectName?: string,
182181
): Promise<CoreConfig> => {
183-
if (projectName) {
184-
throw new Error('coverageCoreConfigNx for single projects not implemented');
185-
}
186182
const targetNames = ['unit-test', 'int-test'];
187-
const targetArgs = [
188-
'-t',
189-
...targetNames,
190-
'--coverage.enabled',
191-
'--skipNxCache',
192-
];
183+
const targetArgs = ['-t', ...targetNames];
193184
return {
194185
plugins: [
195186
await coveragePlugin({
196187
coverageToolCommand: {
197188
command: 'npx',
198-
args: [
199-
'nx',
200-
projectName ? `run --project ${projectName}` : 'run-many',
201-
...targetArgs,
202-
],
189+
args: projectName
190+
? ['nx', 'run-many', '-p', projectName, ...targetArgs]
191+
: ['nx', 'run-many', ...targetArgs],
203192
},
204-
reports: await getNxCoveragePaths(targetNames),
193+
reports: projectName
194+
? [
195+
{
196+
pathToProject: `packages/${projectName}`,
197+
resultsPath: `packages/${projectName}/coverage/lcov.info`,
198+
},
199+
]
200+
: await getNxCoveragePaths(targetNames),
205201
}),
206202
],
207203
categories: coverageCategories,

e2e/ci-e2e/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"e2e": {
99
"executor": "@nx/vite:test",
1010
"options": {
11-
"configFile": "e2e/ci-e2e/vitest.e2e.config.ts"
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
1212
}
1313
}
1414
},

e2e/cli-e2e/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"e2e": {
99
"executor": "@nx/vite:test",
1010
"options": {
11-
"configFile": "e2e/cli-e2e/vitest.e2e.config.ts"
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
1212
}
1313
}
1414
},

e2e/create-cli-e2e/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"executor": "@nx/vite:test",
1010
"options": {
1111
"keepServerRunning": true,
12-
"configFile": "e2e/create-cli-e2e/vitest.e2e.config.ts"
12+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
1313
}
1414
}
1515
},

e2e/nx-plugin-e2e/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"e2e": {
99
"executor": "@nx/vite:test",
1010
"options": {
11-
"configFile": "e2e/nx-plugin-e2e/vitest.e2e.config.ts"
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
1212
}
1313
}
1414
},

e2e/plugin-coverage-e2e/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"e2e": {
99
"executor": "@nx/vite:test",
1010
"options": {
11-
"configFile": "e2e/plugin-coverage-e2e/vitest.e2e.config.ts"
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
1212
}
1313
}
1414
},

e2e/plugin-eslint-e2e/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"e2e": {
99
"executor": "@nx/vite:test",
1010
"options": {
11-
"configFile": "e2e/plugin-eslint-e2e/vitest.e2e.config.ts"
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
1212
}
1313
}
1414
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"e2e": {
1010
"executor": "@nx/vite:test",
1111
"options": {
12-
"configFile": "e2e/plugin-eslint-e2e/vitest.e2e.config.ts"
12+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
1313
}
1414
}
1515
},

e2e/plugin-lighthouse-e2e/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"e2e": {
99
"executor": "@nx/vite:test",
1010
"options": {
11-
"configFile": "e2e/plugin-lighthouse-e2e/vitest.e2e.config.ts"
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
1212
}
1313
}
1414
},

examples/plugins/project.json

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,10 @@
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-
},
32-
"int-test": {
33-
"executor": "@nx/vite:test",
34-
"outputs": ["{options.reportsDirectory}"],
35-
"options": {
36-
"configFile": "examples/plugins/vitest.int.config.ts",
37-
"reportsDirectory": "../../coverage/examples-plugins/int-tests"
38-
}
39-
},
7+
"build": {},
8+
"lint": {},
9+
"unit-test": {},
10+
"int-test": {},
4011
"run-collect": {
4112
"command": "npx dist/packages/cli collect --config=examples/plugins/code-pushup.config.ts --persist.format=md",
4213
"dependsOn": [

0 commit comments

Comments
 (0)