Skip to content

Commit f9f4391

Browse files
committed
Merge branch 'main' into ts-plugin-e2e
2 parents b656fb7 + b03db63 commit f9f4391

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1197
-561
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## 0.65.1 (2025-03-11)
2+
3+
### 🩹 Fixes
4+
5+
- update pkgs ([#965](https://github.com/code-pushup/cli/pull/965))
6+
- **ci:** prevent overwriting report artifacts ([3c7fa08f](https://github.com/code-pushup/cli/commit/3c7fa08f))
7+
- **nx-plugin:** adjust upload config handling ([#937](https://github.com/code-pushup/cli/pull/937))
8+
9+
### ❤️ Thank You
10+
11+
- Matěj Chalk
12+
- Michael Hladky @BioPhoton
13+
114
## 0.65.0 (2025-03-05)
215

316
### 🚀 Features

e2e/ci-e2e/tests/basic.e2e.test.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ describe('CI - standalone mode', () => {
4646
).resolves.toEqual({
4747
mode: 'standalone',
4848
files: {
49-
report: {
50-
json: path.join(repo.baseDir, '.code-pushup/report.json'),
51-
md: path.join(repo.baseDir, '.code-pushup/report.md'),
49+
current: {
50+
json: path.join(
51+
repo.baseDir,
52+
'.code-pushup/.ci/.current/report.json',
53+
),
54+
md: path.join(repo.baseDir, '.code-pushup/.ci/.current/report.md'),
5255
},
5356
},
5457
} satisfies RunResult);
5558

5659
const jsonPromise = readFile(
57-
path.join(repo.baseDir, '.code-pushup/report.json'),
60+
path.join(repo.baseDir, '.code-pushup/.ci/.current/report.json'),
5861
'utf8',
5962
);
6063
await expect(jsonPromise).resolves.toBeTruthy();
@@ -103,19 +106,35 @@ describe('CI - standalone mode', () => {
103106
commentId: MOCK_COMMENT.id,
104107
newIssues: [],
105108
files: {
106-
report: {
107-
json: path.join(repo.baseDir, '.code-pushup/report.json'),
108-
md: path.join(repo.baseDir, '.code-pushup/report.md'),
109+
current: {
110+
json: path.join(
111+
repo.baseDir,
112+
'.code-pushup/.ci/.current/report.json',
113+
),
114+
md: path.join(repo.baseDir, '.code-pushup/.ci/.current/report.md'),
109115
},
110-
diff: {
111-
json: path.join(repo.baseDir, '.code-pushup/report-diff.json'),
112-
md: path.join(repo.baseDir, '.code-pushup/report-diff.md'),
116+
previous: {
117+
json: path.join(
118+
repo.baseDir,
119+
'.code-pushup/.ci/.previous/report.json',
120+
),
121+
md: path.join(repo.baseDir, '.code-pushup/.ci/.previous/report.md'),
122+
},
123+
comparison: {
124+
json: path.join(
125+
repo.baseDir,
126+
'.code-pushup/.ci/.comparison/report-diff.json',
127+
),
128+
md: path.join(
129+
repo.baseDir,
130+
'.code-pushup/.ci/.comparison/report-diff.md',
131+
),
113132
},
114133
},
115134
} satisfies RunResult);
116135

117136
const mdPromise = readFile(
118-
path.join(repo.baseDir, '.code-pushup/report-diff.md'),
137+
path.join(repo.baseDir, '.code-pushup/.ci/.comparison/report-diff.md'),
119138
'utf8',
120139
);
121140
await expect(mdPromise).resolves.toBeTruthy();

e2e/ci-e2e/tests/npm-workspaces.e2e.test.ts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ describe('CI - monorepo mode (npm workspaces)', () => {
5252
{
5353
name: '@example/cli',
5454
files: {
55-
report: {
55+
current: {
5656
json: path.join(
5757
repo.baseDir,
58-
'packages/cli/.code-pushup/report.json',
58+
'.code-pushup/.ci/@example/cli/.current/report.json',
5959
),
6060
md: path.join(
6161
repo.baseDir,
62-
'packages/cli/.code-pushup/report.md',
62+
'.code-pushup/.ci/@example/cli/.current/report.md',
6363
),
6464
},
6565
},
@@ -69,7 +69,10 @@ describe('CI - monorepo mode (npm workspaces)', () => {
6969

7070
await expect(
7171
readJsonFile(
72-
path.join(repo.baseDir, 'packages/cli/.code-pushup/report.json'),
72+
path.join(
73+
repo.baseDir,
74+
'.code-pushup/.ci/@example/cli/.current/report.json',
75+
),
7376
),
7477
).resolves.toEqual(
7578
expect.objectContaining({
@@ -120,29 +123,46 @@ describe('CI - monorepo mode (npm workspaces)', () => {
120123
await expect(runInCI(refs, MOCK_API, options, git)).resolves.toEqual({
121124
mode: 'monorepo',
122125
commentId: MOCK_COMMENT.id,
123-
diffPath: path.join(repo.baseDir, '.code-pushup/merged-report-diff.md'),
126+
files: {
127+
comparison: {
128+
md: path.join(
129+
repo.baseDir,
130+
'.code-pushup/.ci/.comparison/report-diff.md',
131+
),
132+
},
133+
},
124134
projects: expect.arrayContaining<ProjectRunResult>([
125135
{
126136
name: '@example/core',
127137
files: {
128-
report: {
138+
current: {
139+
json: path.join(
140+
repo.baseDir,
141+
'.code-pushup/.ci/@example/core/.current/report.json',
142+
),
143+
md: path.join(
144+
repo.baseDir,
145+
'.code-pushup/.ci/@example/core/.current/report.md',
146+
),
147+
},
148+
previous: {
129149
json: path.join(
130150
repo.baseDir,
131-
'packages/core/.code-pushup/report.json',
151+
'.code-pushup/.ci/@example/core/.previous/report.json',
132152
),
133153
md: path.join(
134154
repo.baseDir,
135-
'packages/core/.code-pushup/report.md',
155+
'.code-pushup/.ci/@example/core/.previous/report.md',
136156
),
137157
},
138-
diff: {
158+
comparison: {
139159
json: path.join(
140160
repo.baseDir,
141-
'packages/core/.code-pushup/report-diff.json',
161+
'.code-pushup/.ci/@example/core/.comparison/report-diff.json',
142162
),
143163
md: path.join(
144164
repo.baseDir,
145-
'packages/core/.code-pushup/report-diff.md',
165+
'.code-pushup/.ci/@example/core/.comparison/report-diff.md',
146166
),
147167
},
148168
},
@@ -152,7 +172,7 @@ describe('CI - monorepo mode (npm workspaces)', () => {
152172
} satisfies RunResult);
153173

154174
const mdPromise = readFile(
155-
path.join(repo.baseDir, '.code-pushup/merged-report-diff.md'),
175+
path.join(repo.baseDir, '.code-pushup/.ci/.comparison/report-diff.md'),
156176
'utf8',
157177
);
158178
await expect(mdPromise).resolves.toBeTruthy();

e2e/ci-e2e/tests/nx-monorepo.e2e.test.ts

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ describe('CI - monorepo mode (Nx)', () => {
5353
{
5454
name: 'api',
5555
files: {
56-
report: {
56+
current: {
5757
json: path.join(
5858
repo.baseDir,
59-
'apps/api/.code-pushup/report.json',
59+
'.code-pushup/.ci/api/.current/report.json',
60+
),
61+
md: path.join(
62+
repo.baseDir,
63+
'.code-pushup/.ci/api/.current/report.md',
6064
),
61-
md: path.join(repo.baseDir, 'apps/api/.code-pushup/report.md'),
6265
},
6366
},
6467
},
@@ -67,7 +70,7 @@ describe('CI - monorepo mode (Nx)', () => {
6770

6871
await expect(
6972
readJsonFile(
70-
path.join(repo.baseDir, 'apps/api/.code-pushup/report.json'),
73+
path.join(repo.baseDir, '.code-pushup/.ci/api/.current/report.json'),
7174
),
7275
).resolves.toEqual(
7376
expect.objectContaining({
@@ -85,7 +88,7 @@ describe('CI - monorepo mode (Nx)', () => {
8588
);
8689
await expect(
8790
readJsonFile(
88-
path.join(repo.baseDir, 'libs/ui/.code-pushup/report.json'),
91+
path.join(repo.baseDir, '.code-pushup/.ci/ui/.current/report.json'),
8992
),
9093
).resolves.toEqual(
9194
expect.objectContaining({
@@ -145,26 +148,46 @@ describe('CI - monorepo mode (Nx)', () => {
145148
await expect(runInCI(refs, MOCK_API, options, git)).resolves.toEqual({
146149
mode: 'monorepo',
147150
commentId: MOCK_COMMENT.id,
148-
diffPath: path.join(repo.baseDir, '.code-pushup/merged-report-diff.md'),
151+
files: {
152+
comparison: {
153+
md: path.join(
154+
repo.baseDir,
155+
'.code-pushup/.ci/.comparison/report-diff.md',
156+
),
157+
},
158+
},
149159
projects: expect.arrayContaining<ProjectRunResult>([
150160
{
151161
name: 'web',
152162
files: {
153-
report: {
163+
current: {
164+
json: path.join(
165+
repo.baseDir,
166+
'.code-pushup/.ci/web/.current/report.json',
167+
),
168+
md: path.join(
169+
repo.baseDir,
170+
'.code-pushup/.ci/web/.current/report.md',
171+
),
172+
},
173+
previous: {
154174
json: path.join(
155175
repo.baseDir,
156-
'apps/web/.code-pushup/report.json',
176+
'.code-pushup/.ci/web/.previous/report.json',
177+
),
178+
md: path.join(
179+
repo.baseDir,
180+
'.code-pushup/.ci/web/.previous/report.md',
157181
),
158-
md: path.join(repo.baseDir, 'apps/web/.code-pushup/report.md'),
159182
},
160-
diff: {
183+
comparison: {
161184
json: path.join(
162185
repo.baseDir,
163-
'apps/web/.code-pushup/report-diff.json',
186+
'.code-pushup/.ci/web/.comparison/report-diff.json',
164187
),
165188
md: path.join(
166189
repo.baseDir,
167-
'apps/web/.code-pushup/report-diff.md',
190+
'.code-pushup/.ci/web/.comparison/report-diff.md',
168191
),
169192
},
170193
},
@@ -182,7 +205,7 @@ describe('CI - monorepo mode (Nx)', () => {
182205
} satisfies RunResult);
183206

184207
const mdPromise = readFile(
185-
path.join(repo.baseDir, '.code-pushup/merged-report-diff.md'),
208+
path.join(repo.baseDir, '.code-pushup/.ci/.comparison/report-diff.md'),
186209
'utf8',
187210
);
188211
await expect(mdPromise).resolves.toBeTruthy();

e2e/ci-e2e/vite.config.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
cacheDir: '../../node_modules/.vite/ci-e2e',
77
test: {
88
reporters: ['basic'],
9-
testTimeout: 120_000,
9+
testTimeout: 60_000,
1010
globals: true,
1111
alias: tsconfigPathAliases(),
1212
pool: 'threads',

e2e/cli-e2e/vite.config.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
cacheDir: '../../node_modules/.vite/cli-e2e',
77
test: {
88
reporters: ['basic'],
9-
testTimeout: 120_000,
9+
testTimeout: 20_000,
1010
globals: true,
1111
alias: tsconfigPathAliases(),
1212
pool: 'threads',

e2e/create-cli-e2e/vite.config.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
cacheDir: '../../node_modules/.vite/create-cli-e2e',
77
test: {
88
reporters: ['basic'],
9-
testTimeout: 120_000,
9+
testTimeout: 20_000,
1010
hookTimeout: 20_000,
1111
globals: true,
1212
alias: tsconfigPathAliases(),

e2e/nx-plugin-e2e/tests/executor-cli.e2e.test.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type Tree, updateProjectConfiguration } from '@nx/devkit';
22
import path from 'node:path';
33
import { readProjectConfiguration } from 'nx/src/generators/utils/project-configuration';
4-
import { afterEach, expect } from 'vitest';
4+
import { afterAll, afterEach, beforeEach, expect, vi } from 'vitest';
55
import {
66
type AutorunCommandExecutorOptions,
77
generateCodePushupConfig,
@@ -58,15 +58,31 @@ describe('executor command', () => {
5858
TEST_OUTPUT_DIR,
5959
'executor-cli',
6060
);
61+
const processEnvCP = Object.fromEntries(
62+
Object.entries(process.env).filter(([k]) => k.startsWith('CP_')),
63+
);
64+
65+
/* eslint-disable functional/immutable-data, @typescript-eslint/no-dynamic-delete */
66+
beforeAll(() => {
67+
Object.entries(process.env)
68+
.filter(([k]) => k.startsWith('CP_'))
69+
.forEach(([k]) => delete process.env[k]);
70+
});
6171

6272
beforeEach(async () => {
73+
vi.unstubAllEnvs();
6374
tree = await generateWorkspaceAndProject(project);
6475
});
6576

6677
afterEach(async () => {
6778
await teardownTestFolder(testFileDir);
6879
});
6980

81+
afterAll(() => {
82+
Object.entries(processEnvCP).forEach(([k, v]) => (process.env[k] = v));
83+
});
84+
/* eslint-enable functional/immutable-data, @typescript-eslint/no-dynamic-delete */
85+
7086
it('should execute no specific command by default', async () => {
7187
const cwd = path.join(testFileDir, 'execute-default-command');
7288
await addTargetToWorkspace(tree, { cwd, project });
@@ -100,6 +116,32 @@ describe('executor command', () => {
100116
).rejects.toThrow('');
101117
});
102118

119+
it('should execute print-config executor with api key', async () => {
120+
const cwd = path.join(testFileDir, 'execute-print-config-command');
121+
await addTargetToWorkspace(tree, { cwd, project });
122+
123+
const { stdout, code } = await executeProcess({
124+
command: 'npx',
125+
args: [
126+
'nx',
127+
'run',
128+
`${project}:code-pushup`,
129+
'print-config',
130+
'--upload.apiKey=a123a',
131+
],
132+
cwd,
133+
});
134+
135+
expect(code).toBe(0);
136+
const cleanStdout = removeColorCodes(stdout);
137+
expect(cleanStdout).toContain('nx run my-lib:code-pushup print-config');
138+
expect(cleanStdout).toContain('a123a');
139+
140+
await expect(() =>
141+
readJsonFile(path.join(cwd, '.code-pushup', project, 'report.json')),
142+
).rejects.toThrow('');
143+
});
144+
103145
it('should execute collect executor and merge target and command-line options', async () => {
104146
const cwd = path.join(testFileDir, 'execute-collect-with-merged-options');
105147
await addTargetToWorkspace(

e2e/nx-plugin-e2e/vite.config.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
cacheDir: '../../node_modules/.vite/nx-plugin-e2e',
77
test: {
88
reporters: ['basic'],
9-
testTimeout: 160_000,
9+
testTimeout: 40_000,
1010
globals: true,
1111
alias: tsconfigPathAliases(),
1212
pool: 'threads',

e2e/plugin-coverage-e2e/vite.config.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
cacheDir: '../../node_modules/.vite/plugin-lighthouse-e2e',
77
test: {
88
reporters: ['basic'],
9-
testTimeout: 120_000,
9+
testTimeout: 40_000,
1010
globals: true,
1111
alias: tsconfigPathAliases(),
1212
pool: 'threads',

0 commit comments

Comments
 (0)