diff --git a/packages/ci/README.md b/packages/ci/README.md index ff2d83b66..6e6c2a986 100644 --- a/packages/ci/README.md +++ b/packages/ci/README.md @@ -103,7 +103,7 @@ Optionally, you can override default options for further customization: | `nxProjectsFilter` | `string \| string[]` | `'--with-target={task}'` | Arguments passed to [`nx show projects`](https://nx.dev/nx-api/nx/documents/show#projects), only relevant for Nx in [monorepo mode](#monorepo-mode) [^2] | | `directory` | `string` | `process.cwd()` | Directory in which Code PushUp CLI should run | | `config` | `string \| null` | `null` [^1] | Path to config file (`--config` option) | -| `silent` | `boolean` | `false` | Toggles if logs from CLI commands are printed | +| `silent` | `boolean` | `false` | Hides logs from CLI commands (erros will be printed) | | `bin` | `string` | `'npx --no-install code-pushup'` | Command for executing Code PushUp CLI | | `detectNewIssues` | `boolean` | `true` | Toggles if new issues should be detected and returned in `newIssues` property | | `logger` | `Logger` | `console` | Logger for reporting progress and encountered problems | diff --git a/packages/ci/src/lib/cli/commands/collect.ts b/packages/ci/src/lib/cli/commands/collect.ts index ae24f66b7..aa873395b 100644 --- a/packages/ci/src/lib/cli/commands/collect.ts +++ b/packages/ci/src/lib/cli/commands/collect.ts @@ -1,22 +1,22 @@ import { DEFAULT_PERSIST_FORMAT } from '@code-pushup/models'; -import { executeProcess } from '@code-pushup/utils'; +import { executeProcess, isVerbose } from '@code-pushup/utils'; import type { CommandContext } from '../context.js'; export async function runCollect({ bin, config, directory, - silent, + observer, }: CommandContext): Promise { - const { stdout } = await executeProcess({ + await executeProcess({ command: bin, args: [ + ...(isVerbose() ? ['--verbose'] : []), + '--no-progress', ...(config ? [`--config=${config}`] : []), ...DEFAULT_PERSIST_FORMAT.map(format => `--persist.format=${format}`), ], cwd: directory, + observer, }); - if (!silent) { - console.info(stdout); - } } diff --git a/packages/ci/src/lib/cli/commands/compare.ts b/packages/ci/src/lib/cli/commands/compare.ts index a28f2126e..4321e8e5a 100644 --- a/packages/ci/src/lib/cli/commands/compare.ts +++ b/packages/ci/src/lib/cli/commands/compare.ts @@ -1,5 +1,5 @@ import { DEFAULT_PERSIST_FORMAT } from '@code-pushup/models'; -import { executeProcess } from '@code-pushup/utils'; +import { executeProcess, isVerbose } from '@code-pushup/utils'; import type { CommandContext } from '../context.js'; type CompareOptions = { @@ -10,12 +10,13 @@ type CompareOptions = { export async function runCompare( { before, after, label }: CompareOptions, - { bin, config, directory, silent }: CommandContext, + { bin, config, directory, observer }: CommandContext, ): Promise { - const { stdout } = await executeProcess({ + await executeProcess({ command: bin, args: [ 'compare', + ...(isVerbose() ? ['--verbose'] : []), `--before=${before}`, `--after=${after}`, ...(label ? [`--label=${label}`] : []), @@ -23,8 +24,6 @@ export async function runCompare( ...DEFAULT_PERSIST_FORMAT.map(format => `--persist.format=${format}`), ], cwd: directory, + observer, }); - if (!silent) { - console.info(stdout); - } } diff --git a/packages/ci/src/lib/cli/commands/merge-diffs.ts b/packages/ci/src/lib/cli/commands/merge-diffs.ts index 1c94954d6..347bfc191 100644 --- a/packages/ci/src/lib/cli/commands/merge-diffs.ts +++ b/packages/ci/src/lib/cli/commands/merge-diffs.ts @@ -3,30 +3,29 @@ import { DEFAULT_PERSIST_FILENAME, DEFAULT_PERSIST_OUTPUT_DIR, } from '@code-pushup/models'; -import { executeProcess } from '@code-pushup/utils'; +import { executeProcess, isVerbose } from '@code-pushup/utils'; import type { CommandContext } from '../context.js'; export async function runMergeDiffs( files: string[], - { bin, config, directory, silent }: CommandContext, + { bin, config, directory, observer }: CommandContext, ): Promise { const outputDir = path.join(directory, DEFAULT_PERSIST_OUTPUT_DIR); const filename = `merged-${DEFAULT_PERSIST_FILENAME}`; - const { stdout } = await executeProcess({ + await executeProcess({ command: bin, args: [ 'merge-diffs', + ...(isVerbose() ? ['--verbose'] : []), ...files.map(file => `--files=${file}`), ...(config ? [`--config=${config}`] : []), `--persist.outputDir=${outputDir}`, `--persist.filename=${filename}`, ], cwd: directory, + observer, }); - if (!silent) { - console.info(stdout); - } return path.join(outputDir, `${filename}-diff.md`); } diff --git a/packages/ci/src/lib/cli/commands/print-config.ts b/packages/ci/src/lib/cli/commands/print-config.ts index a9adf0b98..1f24f9d08 100644 --- a/packages/ci/src/lib/cli/commands/print-config.ts +++ b/packages/ci/src/lib/cli/commands/print-config.ts @@ -3,6 +3,7 @@ import path from 'node:path'; import { executeProcess, generateRandomId, + isVerbose, readJsonFile, stringifyError, } from '@code-pushup/utils'; @@ -12,24 +13,23 @@ export async function runPrintConfig({ bin, config, directory, - silent, + observer, }: CommandContext): Promise { // random file name so command can be run in parallel const outputFile = `code-pushup.${generateRandomId()}.config.json`; const outputPath = path.join(directory, outputFile); - const { stdout } = await executeProcess({ + await executeProcess({ command: bin, args: [ ...(config ? [`--config=${config}`] : []), 'print-config', + ...(isVerbose() ? ['--verbose'] : []), `--output=${outputFile}`, ], cwd: directory, + observer, }); - if (!silent) { - console.info(stdout); - } try { const content = await readJsonFile(outputPath); diff --git a/packages/ci/src/lib/cli/context.ts b/packages/ci/src/lib/cli/context.ts index 82184ee95..dcea856fb 100644 --- a/packages/ci/src/lib/cli/context.ts +++ b/packages/ci/src/lib/cli/context.ts @@ -1,19 +1,20 @@ +import type { ProcessObserver } from '@code-pushup/utils'; +import { createExecutionObserver } from '../create-execution-observer.js'; import type { Settings } from '../models.js'; import type { ProjectConfig } from '../monorepo/index.js'; -export type CommandContext = Pick< - Settings, - 'bin' | 'config' | 'directory' | 'silent' ->; +export type CommandContext = Pick & { + observer?: ProcessObserver; +}; export function createCommandContext( - settings: Settings, + { config, bin, directory, silent }: Settings, project: ProjectConfig | null | undefined, ): CommandContext { return { - bin: project?.bin ?? settings.bin, - directory: project?.directory ?? settings.directory, - config: settings.config, - silent: settings.silent, + bin: project?.bin ?? bin, + directory: project?.directory ?? directory, + config, + observer: createExecutionObserver({ silent }), }; } diff --git a/packages/ci/src/lib/cli/context.unit.test.ts b/packages/ci/src/lib/cli/context.unit.test.ts index c8041648a..7e400b7ac 100644 --- a/packages/ci/src/lib/cli/context.unit.test.ts +++ b/packages/ci/src/lib/cli/context.unit.test.ts @@ -1,6 +1,12 @@ +import { expect } from 'vitest'; import { type CommandContext, createCommandContext } from './context.js'; describe('createCommandContext', () => { + const expectedObserver = expect.objectContaining({ + onStderr: expect.any(Function), + onStdout: expect.any(Function), + }); + it('should pick CLI-related settings in standalone mode', () => { expect( createCommandContext( @@ -25,7 +31,7 @@ describe('createCommandContext', () => { bin: 'npx --no-install code-pushup', directory: '/test', config: null, - silent: false, + observer: expectedObserver, }); }); @@ -57,7 +63,7 @@ describe('createCommandContext', () => { bin: 'yarn code-pushup', directory: '/test/ui', config: null, - silent: false, + observer: expectedObserver, }); }); }); diff --git a/packages/ci/src/lib/create-execution-observer.integration.test.ts b/packages/ci/src/lib/create-execution-observer.integration.test.ts new file mode 100644 index 000000000..547cceff9 --- /dev/null +++ b/packages/ci/src/lib/create-execution-observer.integration.test.ts @@ -0,0 +1,41 @@ +import { expect } from 'vitest'; +import { executeProcess } from '@code-pushup/utils'; +import { createExecutionObserver } from './create-execution-observer.js'; + +describe('createExecutionObserver', () => { + const message = 'This is stdout'; + const error = 'This is stderr'; + + it('should use execute process and use observer to capture stdout message and stderr will be empty', async () => { + const { stdout, stderr } = await executeProcess({ + command: 'node', + args: ['-e', `"console.log('${message}');"`], + observer: createExecutionObserver(), + }); + + expect(stdout).toMatch(message); + expect(stderr).toMatch(''); + }); + + it('should use execute process and use observer to capture stdout message and stderr will be error', async () => { + const { stdout, stderr } = await executeProcess({ + command: 'node', + args: ['-e', `"console.log('${message}'); console.error('${error}');"`], + observer: createExecutionObserver(), + }); + + expect(stdout).toMatch(message); + expect(stderr).toMatch(error); + }); + + it('should use execute process and use observer to capture stderr error and ignore stdout message', async () => { + const { stdout, stderr } = await executeProcess({ + command: 'node', + args: ['-e', `"console.log('${message}'); console.error('${error}');"`], + observer: createExecutionObserver({ silent: true }), + }); + + expect(stdout).toMatch(''); + expect(stderr).toMatch(error); + }); +}); diff --git a/packages/ci/src/lib/create-execution-observer.ts b/packages/ci/src/lib/create-execution-observer.ts new file mode 100644 index 000000000..bb4c0a261 --- /dev/null +++ b/packages/ci/src/lib/create-execution-observer.ts @@ -0,0 +1,20 @@ +import { type ProcessObserver, isVerbose } from '@code-pushup/utils'; + +export function createExecutionObserver( + { + silent, + }: { + silent?: boolean; + } = { silent: false }, +): ProcessObserver { + return { + onStderr: stderr => { + console.warn(stderr); + }, + ...((!silent || isVerbose()) && { + onStdout: stdout => { + console.info(stdout); + }, + }), + }; +} diff --git a/packages/ci/src/lib/create-execution-observer.unit.test.ts b/packages/ci/src/lib/create-execution-observer.unit.test.ts new file mode 100644 index 000000000..86ccb944a --- /dev/null +++ b/packages/ci/src/lib/create-execution-observer.unit.test.ts @@ -0,0 +1,33 @@ +import { expect, vi } from 'vitest'; +import { createExecutionObserver } from './create-execution-observer.js'; + +describe('createExecutionObserver', () => { + it('should create execution observer with default settings', () => { + expect(createExecutionObserver()).toStrictEqual({ + onStderr: expect.any(Function), + onStdout: expect.any(Function), + }); + }); + + it('should create execution observer with silent false settings', () => { + expect(createExecutionObserver({ silent: false })).toStrictEqual({ + onStderr: expect.any(Function), + onStdout: expect.any(Function), + }); + }); + + it('should create execution observer with default silent taking priority over CP_VERBOSE flag', () => { + vi.stubEnv('CP_VERBOSE', 'false'); + + expect(createExecutionObserver()).toStrictEqual({ + onStderr: expect.any(Function), + onStdout: expect.any(Function), + }); + }); + + it('should create execution observer with silent setting', () => { + expect(createExecutionObserver({ silent: true })).toStrictEqual({ + onStderr: expect.any(Function), + }); + }); +}); diff --git a/packages/ci/src/lib/monorepo/handlers/nx.ts b/packages/ci/src/lib/monorepo/handlers/nx.ts index f84df2c1e..eb5db37e9 100644 --- a/packages/ci/src/lib/monorepo/handlers/nx.ts +++ b/packages/ci/src/lib/monorepo/handlers/nx.ts @@ -25,25 +25,23 @@ export const nxHandler: MonorepoToolHandler = { ); }, - async listProjects(options) { + async listProjects({ cwd, task, nxProjectsFilter, observer }) { const { stdout } = await executeProcess({ command: 'npx', args: [ 'nx', 'show', 'projects', - ...toArray(options.nxProjectsFilter).map(arg => - arg.replaceAll('{task}', options.task), - ), + ...toArray(nxProjectsFilter).map(arg => arg.replaceAll('{task}', task)), '--json', ], - cwd: options.cwd, - observer: options.observer, + cwd, + observer, }); const projects = parseProjects(stdout); return projects.toSorted().map(project => ({ name: project, - bin: `npx nx run ${project}:${options.task} --skip-nx-cache --`, + bin: `npx nx run ${project}:${task} --skip-nx-cache --`, })); }, diff --git a/packages/ci/src/lib/monorepo/list-projects.ts b/packages/ci/src/lib/monorepo/list-projects.ts index 1eec0c37c..4868fdac0 100644 --- a/packages/ci/src/lib/monorepo/list-projects.ts +++ b/packages/ci/src/lib/monorepo/list-projects.ts @@ -1,5 +1,6 @@ import { glob } from 'glob'; import path from 'node:path'; +import { createExecutionObserver } from '../create-execution-observer.js'; import type { Logger, Settings } from '../models.js'; import { detectMonorepoTool } from './detect-tool.js'; import { getToolHandler } from './handlers/index.js'; @@ -87,24 +88,19 @@ async function resolveMonorepoTool( return tool; } -function createMonorepoHandlerOptions( - settings: Settings, -): MonorepoHandlerOptions { +function createMonorepoHandlerOptions({ + task, + directory, + parallel, + nxProjectsFilter, + silent, +}: Settings): MonorepoHandlerOptions { return { - task: settings.task, - cwd: settings.directory, - parallel: settings.parallel, - nxProjectsFilter: settings.nxProjectsFilter, - ...(!settings.silent && { - observer: { - onStdout: stdout => { - console.info(stdout); - }, - onStderr: stderr => { - console.warn(stderr); - }, - }, - }), + task, + cwd: directory, + parallel, + nxProjectsFilter, + observer: createExecutionObserver({ silent }), }; } diff --git a/packages/ci/src/lib/run-utils.ts b/packages/ci/src/lib/run-utils.ts index c3a45cf81..b25bb97f6 100644 --- a/packages/ci/src/lib/run-utils.ts +++ b/packages/ci/src/lib/run-utils.ts @@ -1,3 +1,4 @@ +/* eslint-disable max-lines */ import { mkdir, readFile, writeFile } from 'node:fs/promises'; import path from 'node:path'; import type { SimpleGit } from 'simple-git'; @@ -69,6 +70,9 @@ export async function createRunEnv( options: Options | undefined, git: SimpleGit, ): Promise { + // eslint-disable-next-line functional/immutable-data + process.env['CP_VERBOSE'] = options?.silent ? 'false' : 'true'; + const [head, base] = await Promise.all([ normalizeGitRef(refs.head, git), refs.base && normalizeGitRef(refs.base, git), diff --git a/packages/ci/src/lib/run.integration.test.ts b/packages/ci/src/lib/run.integration.test.ts index 07ee4e94f..07e4dc4b5 100644 --- a/packages/ci/src/lib/run.integration.test.ts +++ b/packages/ci/src/lib/run.integration.test.ts @@ -9,7 +9,7 @@ import { import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { type SimpleGit, simpleGit } from 'simple-git'; -import type { MockInstance } from 'vitest'; +import { type MockInstance, expect } from 'vitest'; import type { CoreConfig } from '@code-pushup/models'; import { cleanTestFolder, @@ -82,6 +82,11 @@ describe('runInCI', () => { url: 'https://fake.hosted.git/comments/42', }; + const expectedObserver = expect.objectContaining({ + onStderr: expect.any(Function), + onStdout: expect.any(Function), + }); + let git: SimpleGit; let cwdSpy: MockInstance< @@ -243,13 +248,24 @@ describe('runInCI', () => { expect(utils.executeProcess).toHaveBeenCalledTimes(2); expect(utils.executeProcess).toHaveBeenNthCalledWith(1, { command: options.bin, - args: ['print-config', expect.stringMatching(/^--output=.*\.json$/)], + args: [ + 'print-config', + '--verbose', + expect.stringMatching(/^--output=.*\.json$/), + ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenNthCalledWith(2, { command: options.bin, - args: ['--persist.format=json', '--persist.format=md'], + args: [ + '--verbose', + '--no-progress', + '--persist.format=json', + '--persist.format=md', + ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(logger.error).not.toHaveBeenCalled(); @@ -315,34 +331,58 @@ describe('runInCI', () => { expect(utils.executeProcess).toHaveBeenCalledTimes(5); expect(utils.executeProcess).toHaveBeenNthCalledWith(1, { command: options.bin, - args: ['print-config', expect.stringMatching(/^--output=.*\.json$/)], + args: [ + 'print-config', + '--verbose', + expect.stringMatching(/^--output=.*\.json$/), + ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenNthCalledWith(2, { command: options.bin, - args: ['--persist.format=json', '--persist.format=md'], + args: [ + '--verbose', + '--no-progress', + '--persist.format=json', + '--persist.format=md', + ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenNthCalledWith(3, { command: options.bin, - args: ['print-config', expect.stringMatching(/^--output=.*\.json$/)], + args: [ + 'print-config', + '--verbose', + expect.stringMatching(/^--output=.*\.json$/), + ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenNthCalledWith(4, { command: options.bin, - args: ['--persist.format=json', '--persist.format=md'], + args: [ + '--verbose', + '--no-progress', + '--persist.format=json', + '--persist.format=md', + ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenNthCalledWith(5, { command: options.bin, args: [ 'compare', + '--verbose', `--before=${path.join(outputDir, 'prev-report.json')}`, `--after=${path.join(outputDir, 'curr-report.json')}`, '--persist.format=json', '--persist.format=md', ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(logger.error).not.toHaveBeenCalled(); @@ -391,24 +431,37 @@ describe('runInCI', () => { expect(utils.executeProcess).toHaveBeenCalledTimes(3); expect(utils.executeProcess).toHaveBeenNthCalledWith(1, { command: options.bin, - args: ['print-config', expect.stringMatching(/^--output=.*\.json$/)], + args: [ + 'print-config', + '--verbose', + expect.stringMatching(/^--output=.*\.json$/), + ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenNthCalledWith(2, { command: options.bin, - args: ['--persist.format=json', '--persist.format=md'], + args: [ + '--verbose', + '--no-progress', + '--persist.format=json', + '--persist.format=md', + ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenNthCalledWith(3, { command: options.bin, args: [ 'compare', + '--verbose', `--before=${path.join(outputDir, 'prev-report.json')}`, `--after=${path.join(outputDir, 'curr-report.json')}`, '--persist.format=json', '--persist.format=md', ], cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(logger.error).not.toHaveBeenCalled(); @@ -451,6 +504,7 @@ describe('runInCI', () => { command: options.bin, args: expect.arrayContaining(['compare']), cwd: workDir, + observer: expectedObserver, } satisfies utils.ProcessConfig); }); }); @@ -585,13 +639,24 @@ describe('runInCI', () => { ).toHaveLength(4); // 1 autorun for all projects, 3 print-configs for each project expect(utils.executeProcess).toHaveBeenCalledWith({ command: run, - args: ['print-config', expect.stringMatching(/^--output=.*\.json$/)], + args: [ + 'print-config', + '--verbose', + expect.stringMatching(/^--output=.*\.json$/), + ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: runMany, - args: ['--persist.format=json', '--persist.format=md'], + args: [ + '--verbose', + '--no-progress', + '--persist.format=json', + '--persist.format=md', + ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(logger.error).not.toHaveBeenCalled(); @@ -754,18 +819,30 @@ describe('runInCI', () => { ).toHaveLength(10); expect(utils.executeProcess).toHaveBeenCalledWith({ command: run, - args: ['print-config', expect.stringMatching(/^--output=.*\.json$/)], + args: [ + 'print-config', + '--verbose', + expect.stringMatching(/^--output=.*\.json$/), + ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: runMany, - args: ['--persist.format=json', '--persist.format=md'], + args: [ + '--verbose', + '--no-progress', + '--persist.format=json', + '--persist.format=md', + ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: run, args: [ 'compare', + '--verbose', expect.stringMatching(/^--before=.*prev-report.json$/), expect.stringMatching(/^--after=.*curr-report.json$/), expect.stringMatching(/^--label=\w+$/), @@ -773,11 +850,13 @@ describe('runInCI', () => { '--persist.format=md', ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: run, args: [ 'merge-diffs', + '--verbose', `--files=${path.join(workDir, 'packages/cli/.code-pushup/report-diff.json')}`, `--files=${path.join(workDir, 'packages/core/.code-pushup/report-diff.json')}`, `--files=${path.join(workDir, 'packages/utils/.code-pushup/report-diff.json')}`, @@ -785,6 +864,7 @@ describe('runInCI', () => { '--persist.filename=merged-report', ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(logger.error).not.toHaveBeenCalled(); @@ -834,16 +914,19 @@ describe('runInCI', () => { command: runMany, args: expect.any(Array), cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: run, args: expect.arrayContaining(['compare']), cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: run, args: expect.arrayContaining(['merge-diffs']), cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); }); }); @@ -930,13 +1013,24 @@ describe('runInCI', () => { ).toHaveLength(6); // 3 autoruns and 3 print-configs for each project expect(utils.executeProcess).toHaveBeenCalledWith({ command: options.bin, - args: ['print-config', expect.stringMatching(/^--output=.*\.json$/)], + args: [ + 'print-config', + '--verbose', + expect.stringMatching(/^--output=.*\.json$/), + ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: options.bin, - args: ['--persist.format=json', '--persist.format=md'], + args: [ + '--verbose', + '--no-progress', + '--persist.format=json', + '--persist.format=md', + ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(logger.error).not.toHaveBeenCalled(); @@ -1085,18 +1179,30 @@ describe('runInCI', () => { ).toHaveLength(10); expect(utils.executeProcess).toHaveBeenCalledWith({ command: options.bin, - args: ['print-config', expect.stringMatching(/^--output=.*\.json$/)], + args: [ + 'print-config', + '--verbose', + expect.stringMatching(/^--output=.*\.json$/), + ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: options.bin, - args: ['--persist.format=json', '--persist.format=md'], + args: [ + '--verbose', + '--no-progress', + '--persist.format=json', + '--persist.format=md', + ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: options.bin, args: [ 'compare', + '--verbose', expect.stringMatching(/^--before=.*prev-report.json$/), expect.stringMatching(/^--after=.*curr-report.json$/), expect.stringMatching(/^--label=\w+$/), @@ -1104,11 +1210,13 @@ describe('runInCI', () => { '--persist.format=md', ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(utils.executeProcess).toHaveBeenCalledWith({ command: options.bin, args: [ 'merge-diffs', + '--verbose', `--files=${path.join(workDir, 'backend/api/.code-pushup/report-diff.json')}`, `--files=${path.join(workDir, 'backend/auth/.code-pushup/report-diff.json')}`, `--files=${path.join(workDir, 'frontend/.code-pushup/report-diff.json')}`, @@ -1116,6 +1224,7 @@ describe('runInCI', () => { '--persist.filename=merged-report', ], cwd: expect.stringContaining(workDir), + observer: expectedObserver, } satisfies utils.ProcessConfig); expect(logger.error).not.toHaveBeenCalled();