From 36414be368f45312818f9e775218cea1a40caa3c Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Tue, 12 Nov 2024 16:00:31 -0300 Subject: [PATCH 1/7] feat: render test failure counter --- src/utils/deployStages.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utils/deployStages.ts b/src/utils/deployStages.ts index dd2b3da8..09bf4f10 100644 --- a/src/utils/deployStages.ts +++ b/src/utils/deployStages.ts @@ -129,7 +129,7 @@ export class DeployStages { type: 'dynamic-key-value', }, { - label: 'Tests', + label: 'Completed', get: (data): string | undefined => data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestsCompleted ? formatProgress(data?.mdapiDeploy?.numberTestsCompleted, data?.mdapiDeploy?.numberTestsTotal) @@ -137,6 +137,15 @@ export class DeployStages { stage: 'Running Tests', type: 'dynamic-key-value', }, + { + label: 'Failures', + get: (data): string | undefined => + data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors + ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + : undefined, + stage: 'Running Tests', + type: 'dynamic-key-value', + }, { label: 'Members', get: (data): string | undefined => From d95f0a348b1bb789ca81ae0c2b25a3f2360d3b71 Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Wed, 27 Nov 2024 13:25:26 -0300 Subject: [PATCH 2/7] feat: show test failures while polling for status --- src/formatters/testResultsFormatter.ts | 6 ++-- src/utils/deployStages.ts | 42 +++++++++++++++++++++++--- src/utils/types.ts | 4 +++ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/formatters/testResultsFormatter.ts b/src/formatters/testResultsFormatter.ts index c3ae12fb..c675055d 100644 --- a/src/formatters/testResultsFormatter.ts +++ b/src/formatters/testResultsFormatter.ts @@ -18,7 +18,7 @@ import { Successes, } from '@salesforce/source-deploy-retrieve'; import { ensureArray } from '@salesforce/kit'; -import { TestLevel, Verbosity } from '../utils/types.js'; +import { isTruthy, TestLevel, Verbosity } from '../utils/types.js'; import { tableHeader, error, success, check } from '../utils/output.js'; import { coverageOutput } from '../utils/coverage.js'; @@ -45,7 +45,9 @@ export class TestResultsFormatter { return; } - displayVerboseTestFailures(this.result.response); + if (!isTruthy(process.env.CI)) { + displayVerboseTestFailures(this.result.response); + } if (this.verbosity === 'verbose') { displayVerboseTestSuccesses(this.result.response.details.runTestResult?.successes); diff --git a/src/utils/deployStages.ts b/src/utils/deployStages.ts index 09bf4f10..2d7c605c 100644 --- a/src/utils/deployStages.ts +++ b/src/utils/deployStages.ts @@ -4,12 +4,22 @@ * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ +import os from 'node:os'; import { MultiStageOutput } from '@oclif/multi-stage-output'; import { Lifecycle, Messages } from '@salesforce/core'; -import { MetadataApiDeploy, MetadataApiDeployStatus, RequestStatus } from '@salesforce/source-deploy-retrieve'; +import { + Failures, + MetadataApiDeploy, + MetadataApiDeployStatus, + RequestStatus, + Successes, +} from '@salesforce/source-deploy-retrieve'; import { SourceMemberPollingEvent } from '@salesforce/source-tracking'; import terminalLink from 'terminal-link'; +import { ensureArray } from '@salesforce/kit'; +import ansis from 'ansis'; import { getZipFileSize } from './output.js'; +import { isTruthy } from './types.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const mdTransferMessages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'metadata.transfer'); @@ -129,7 +139,7 @@ export class DeployStages { type: 'dynamic-key-value', }, { - label: 'Completed', + label: 'Successful', get: (data): string | undefined => data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestsCompleted ? formatProgress(data?.mdapiDeploy?.numberTestsCompleted, data?.mdapiDeploy?.numberTestsTotal) @@ -138,10 +148,11 @@ export class DeployStages { type: 'dynamic-key-value', }, { - label: 'Failures', + label: 'Failed', get: (data): string | undefined => data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors - ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + + (isTruthy(process.env.CI) ? os.EOL + formatTestFailures(data) : '') : undefined, stage: 'Running Tests', type: 'dynamic-key-value', @@ -241,3 +252,26 @@ export class DeployStages { this.mso.skipTo('Done', data); } } + +function formatTestFailures(data: Data): string { + if (data.mdapiDeploy.details.runTestResult?.failures === undefined) return ''; + const failures = ensureArray(data.mdapiDeploy.details.runTestResult?.failures).sort(testResultSort); + + let output = ''; + + for (const test of failures) { + const testName = ansis.underline(`${test.name}.${test.methodName}`); + output += ` • ${testName}${os.EOL}`; + output += ` message: ${test.message}${os.EOL}`; + if (test.stackTrace) { + const stackTrace = test.stackTrace.replace(/\n/g, `${os.EOL} `); + output += ` stacktrace:${os.EOL} ${stackTrace}${os.EOL}${os.EOL}`; + } + } + + // remove last EOL char + return output.slice(0, -1); +} + +const testResultSort = (a: T, b: T): number => + a.methodName === b.methodName ? a.name.localeCompare(b.name) : a.methodName.localeCompare(b.methodName); diff --git a/src/utils/types.ts b/src/utils/types.ts index e8a7a8c9..10a4ad62 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -124,3 +124,7 @@ export const isFileResponseDeleted = (fileResponse: FileResponseSuccess): boolea fileResponse.state === ComponentStatus.Deleted; export const isDefined = (value?: T): value is T => value !== undefined; + +export function isTruthy(value: string | undefined): boolean { + return value !== '0' && value !== 'false'; +} From ed04d334bc6e7465943bac633aad444d917c7ef2 Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Thu, 28 Nov 2024 18:00:31 -0300 Subject: [PATCH 3/7] fix: improve CI output, handle verbose output --- src/commands/project/delete/source.ts | 1 + src/commands/project/deploy/resume.ts | 1 + src/commands/project/deploy/start.ts | 1 + src/commands/project/deploy/validate.ts | 1 + src/formatters/testResultsFormatter.ts | 11 +++--- src/utils/deployStages.ts | 48 +++++++++++++++++-------- 6 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/commands/project/delete/source.ts b/src/commands/project/delete/source.ts index 103cc03d..d53e5426 100644 --- a/src/commands/project/delete/source.ts +++ b/src/commands/project/delete/source.ts @@ -248,6 +248,7 @@ export class Source extends SfCommand { const stages = new DeployStages({ title: 'Deleting Metadata', jsonEnabled: this.jsonEnabled(), + verbose: this.flags['verbose'], }); const isRest = (await resolveApi()) === API['REST']; diff --git a/src/commands/project/deploy/resume.ts b/src/commands/project/deploy/resume.ts index f24fcd26..143c7cda 100644 --- a/src/commands/project/deploy/resume.ts +++ b/src/commands/project/deploy/resume.ts @@ -134,6 +134,7 @@ export default class DeployMetadataResume extends SfCommand { new DeployStages({ title: 'Resuming Deploy', jsonEnabled: this.jsonEnabled(), + verbose: flags.verbose, }).start( { deploy, diff --git a/src/commands/project/deploy/start.ts b/src/commands/project/deploy/start.ts index e0133378..559bd94e 100644 --- a/src/commands/project/deploy/start.ts +++ b/src/commands/project/deploy/start.ts @@ -250,6 +250,7 @@ export default class DeployMetadata extends SfCommand { this.stages = new DeployStages({ title, jsonEnabled: this.jsonEnabled(), + verbose: flags['verbose'], }); this.deployUrl = buildDeployUrl(flags['target-org'], deploy.id); diff --git a/src/commands/project/deploy/validate.ts b/src/commands/project/deploy/validate.ts index 1f52f422..3bb15b57 100644 --- a/src/commands/project/deploy/validate.ts +++ b/src/commands/project/deploy/validate.ts @@ -211,6 +211,7 @@ export default class DeployMetadataValidate extends SfCommand new DeployStages({ title: 'Validating Deployment', jsonEnabled: this.jsonEnabled(), + verbose: flags.verbose, }).start( { deploy, diff --git a/src/formatters/testResultsFormatter.ts b/src/formatters/testResultsFormatter.ts index c675055d..67513d6f 100644 --- a/src/formatters/testResultsFormatter.ts +++ b/src/formatters/testResultsFormatter.ts @@ -18,9 +18,10 @@ import { Successes, } from '@salesforce/source-deploy-retrieve'; import { ensureArray } from '@salesforce/kit'; -import { isTruthy, TestLevel, Verbosity } from '../utils/types.js'; +import { TestLevel, Verbosity } from '../utils/types.js'; import { tableHeader, error, success, check } from '../utils/output.js'; import { coverageOutput } from '../utils/coverage.js'; +import { isCI } from '../utils/deployStages.js'; const ux = new Ux(); @@ -45,12 +46,14 @@ export class TestResultsFormatter { return; } - if (!isTruthy(process.env.CI)) { + if (!isCI()) { displayVerboseTestFailures(this.result.response); } if (this.verbosity === 'verbose') { - displayVerboseTestSuccesses(this.result.response.details.runTestResult?.successes); + if (!isCI()) { + displayVerboseTestSuccesses(this.result.response.details.runTestResult?.successes); + } displayVerboseTestCoverage(this.result.response.details.runTestResult?.codeCoverage); } @@ -124,7 +127,7 @@ const displayVerboseTestCoverage = (coverage?: CodeCoverage | CodeCoverage[]): v } }; -const testResultSort = (a: T, b: T): number => +export const testResultSort = (a: T, b: T): number => a.methodName === b.methodName ? a.name.localeCompare(b.name) : a.methodName.localeCompare(b.methodName); const coverageSort = (a: CodeCoverage, b: CodeCoverage): number => diff --git a/src/utils/deployStages.ts b/src/utils/deployStages.ts index 2d7c605c..73615e5f 100644 --- a/src/utils/deployStages.ts +++ b/src/utils/deployStages.ts @@ -7,18 +7,13 @@ import os from 'node:os'; import { MultiStageOutput } from '@oclif/multi-stage-output'; import { Lifecycle, Messages } from '@salesforce/core'; -import { - Failures, - MetadataApiDeploy, - MetadataApiDeployStatus, - RequestStatus, - Successes, -} from '@salesforce/source-deploy-retrieve'; +import { MetadataApiDeploy, MetadataApiDeployStatus, RequestStatus } from '@salesforce/source-deploy-retrieve'; import { SourceMemberPollingEvent } from '@salesforce/source-tracking'; import terminalLink from 'terminal-link'; import { ensureArray } from '@salesforce/kit'; import ansis from 'ansis'; -import { getZipFileSize } from './output.js'; +import { testResultSort } from '../formatters/testResultsFormatter.js'; +import { check, getZipFileSize } from './output.js'; import { isTruthy } from './types.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); @@ -27,6 +22,7 @@ const mdTransferMessages = Messages.loadMessages('@salesforce/plugin-deploy-retr type Options = { title: string; jsonEnabled: boolean; + verbose?: boolean; }; type Data = { @@ -58,7 +54,7 @@ function formatProgress(current: number, total: number): string { export class DeployStages { private mso: MultiStageOutput; - public constructor({ title, jsonEnabled }: Options) { + public constructor({ title, jsonEnabled, verbose }: Options) { this.mso = new MultiStageOutput({ title, stages: [ @@ -142,7 +138,8 @@ export class DeployStages { label: 'Successful', get: (data): string | undefined => data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestsCompleted - ? formatProgress(data?.mdapiDeploy?.numberTestsCompleted, data?.mdapiDeploy?.numberTestsTotal) + ? formatProgress(data?.mdapiDeploy?.numberTestsCompleted, data?.mdapiDeploy?.numberTestsTotal) + + (verbose && isCI() ? os.EOL + formatTestSuccesses(data) : '') : undefined, stage: 'Running Tests', type: 'dynamic-key-value', @@ -152,7 +149,7 @@ export class DeployStages { get: (data): string | undefined => data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + - (isTruthy(process.env.CI) ? os.EOL + formatTestFailures(data) : '') + (isCI() ? os.EOL + formatTestFailures(data) : '') : undefined, stage: 'Running Tests', type: 'dynamic-key-value', @@ -253,8 +250,22 @@ export class DeployStages { } } +function formatTestSuccesses(data: Data): string { + const successes = ensureArray(data.mdapiDeploy.details.runTestResult?.successes).sort(testResultSort); + + let output = ''; + + if (successes.length > 0) { + for (const test of successes) { + const testName = ansis.underline(`${test.name}.${test.methodName}`); + output += ` ${check} ${testName}${os.EOL}`; + } + } + + return output; +} + function formatTestFailures(data: Data): string { - if (data.mdapiDeploy.details.runTestResult?.failures === undefined) return ''; const failures = ensureArray(data.mdapiDeploy.details.runTestResult?.failures).sort(testResultSort); let output = ''; @@ -273,5 +284,14 @@ function formatTestFailures(data: Data): string { return output.slice(0, -1); } -const testResultSort = (a: T, b: T): number => - a.methodName === b.methodName ? a.name.localeCompare(b.name) : a.methodName.localeCompare(b.methodName); +export function isCI(): boolean { + if ( + isTruthy(process.env.CI) && + ('CI' in process.env || + 'CONTINUOUS_INTEGRATION' in process.env || + Object.keys(process.env).some((key) => key.startsWith('CI_'))) + ) + return true; + + return false; +} From 7da1bdd4d0f6df227a81272f6c995aea37138f95 Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Mon, 9 Dec 2024 15:05:59 -0300 Subject: [PATCH 4/7] chore: dedup failures on mso --- src/utils/deployStages.ts | 59 +++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/src/utils/deployStages.ts b/src/utils/deployStages.ts index 73615e5f..093c6bff 100644 --- a/src/utils/deployStages.ts +++ b/src/utils/deployStages.ts @@ -7,7 +7,12 @@ import os from 'node:os'; import { MultiStageOutput } from '@oclif/multi-stage-output'; import { Lifecycle, Messages } from '@salesforce/core'; -import { MetadataApiDeploy, MetadataApiDeployStatus, RequestStatus } from '@salesforce/source-deploy-retrieve'; +import { + Failures, + MetadataApiDeploy, + MetadataApiDeployStatus, + RequestStatus, +} from '@salesforce/source-deploy-retrieve'; import { SourceMemberPollingEvent } from '@salesforce/source-tracking'; import terminalLink from 'terminal-link'; import { ensureArray } from '@salesforce/kit'; @@ -53,8 +58,10 @@ function formatProgress(current: number, total: number): string { export class DeployStages { private mso: MultiStageOutput; + private previousFailures: Set; public constructor({ title, jsonEnabled, verbose }: Options) { + this.previousFailures = new Set(); this.mso = new MultiStageOutput({ title, stages: [ @@ -146,11 +153,30 @@ export class DeployStages { }, { label: 'Failed', - get: (data): string | undefined => - data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors - ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + - (isCI() ? os.EOL + formatTestFailures(data) : '') - : undefined, + get: (data): string | undefined => { + let output = + data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors + ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + + (isCI() + ? os.EOL + formatTestFailures(ensureArray(data.mdapiDeploy.details.runTestResult?.failures)) + : '') + : undefined; + + console.log( + // @ts-ignore + `TO RENDER 2: ${data?.mdapiDeploy.details.runTestResult.failures.map((f) => `${f.name}.${f.methodName}`)}` + ); + console.log(data?.mdapiDeploy.numberTestsTotal); + console.log(data?.mdapiDeploy.numberTestErrors); + + if (Array.isArray(data?.mdapiDeploy.details.runTestResult?.failures)) { + data?.mdapiDeploy.details.runTestResult?.failures.forEach((f) => + this.previousFailures.add(`${f.name}.${f.methodName}`) + ); + } + + return output; + }, stage: 'Running Tests', type: 'dynamic-key-value', }, @@ -193,7 +219,22 @@ export class DeployStages { data.numberTestsTotal > 0 && data.numberComponentsDeployed > 0 ) { - this.mso.skipTo('Running Tests', { mdapiDeploy: data, status: mdTransferMessages.getMessage(data?.status) }); + const mdapiDeploy: MetadataApiDeployStatus = { + ...data, + }; + if ( + Array.isArray(mdapiDeploy.details.runTestResult?.failures) && + mdapiDeploy.details.runTestResult?.failures.length > 0 + ) { + mdapiDeploy.details.runTestResult.failures = mdapiDeploy.details.runTestResult?.failures.filter( + (f) => !this.previousFailures.has(`${f.name}.${f.methodName}`) + ); + + console.log( + `TO RENDER 1: ${mdapiDeploy.details.runTestResult.failures.map((f) => `${f.name}.${f.methodName}`)}` + ); + } + this.mso.skipTo('Running Tests', { mdapiDeploy, status: mdTransferMessages.getMessage(data?.status) }); } else if (data.status === RequestStatus.Pending) { this.mso.skipTo('Waiting for the org to respond', { mdapiDeploy: data, @@ -265,8 +306,8 @@ function formatTestSuccesses(data: Data): string { return output; } -function formatTestFailures(data: Data): string { - const failures = ensureArray(data.mdapiDeploy.details.runTestResult?.failures).sort(testResultSort); +function formatTestFailures(failuresData: Failures[]): string { + const failures = failuresData.sort(testResultSort); let output = ''; From fe0ec831f9c826cf477f5b5324885a72b9c63c71 Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Thu, 12 Dec 2024 18:37:32 -0300 Subject: [PATCH 5/7] chore: refactor + skip dups --- src/utils/deployStages.ts | 66 ++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/src/utils/deployStages.ts b/src/utils/deployStages.ts index 093c6bff..8a0c899c 100644 --- a/src/utils/deployStages.ts +++ b/src/utils/deployStages.ts @@ -58,10 +58,14 @@ function formatProgress(current: number, total: number): string { export class DeployStages { private mso: MultiStageOutput; - private previousFailures: Set; + /** + * Set of Apex test failures that were already rendered in the `Running Tests` block. + * This is used in the `Failed` stage block for CI output to ensure test failures aren't duplicated when rendering new failures on polling. + */ + private printedApexTestFailures: Set; public constructor({ title, jsonEnabled, verbose }: Options) { - this.previousFailures = new Set(); + this.printedApexTestFailures = new Set(); this.mso = new MultiStageOutput({ title, stages: [ @@ -154,28 +158,35 @@ export class DeployStages { { label: 'Failed', get: (data): string | undefined => { - let output = - data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors - ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + - (isCI() - ? os.EOL + formatTestFailures(ensureArray(data.mdapiDeploy.details.runTestResult?.failures)) - : '') - : undefined; - - console.log( - // @ts-ignore - `TO RENDER 2: ${data?.mdapiDeploy.details.runTestResult.failures.map((f) => `${f.name}.${f.methodName}`)}` - ); - console.log(data?.mdapiDeploy.numberTestsTotal); - console.log(data?.mdapiDeploy.numberTestErrors); + let testFailures: Failures[] = []; + + // only render new test failures + if (isCI() && Array.isArray(data?.mdapiDeploy.details.runTestResult?.failures)) { + // skip failure counter/progress info if there's no new failures to render. + if ( + this.printedApexTestFailures.size > 0 && + data.mdapiDeploy.numberTestErrors === this.printedApexTestFailures.size + ) { + return undefined; + } + + testFailures = data.mdapiDeploy.details.runTestResult?.failures.filter( + (f) => !this.printedApexTestFailures.has(`${f.name}.${f.methodName}`) + ); - if (Array.isArray(data?.mdapiDeploy.details.runTestResult?.failures)) { data?.mdapiDeploy.details.runTestResult?.failures.forEach((f) => - this.previousFailures.add(`${f.name}.${f.methodName}`) + this.printedApexTestFailures.add(`${f.name}.${f.methodName}`) ); + + return data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors + ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + + (isCI() ? os.EOL + formatTestFailures(testFailures) : '') + : undefined; } - return output; + return data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestErrors + ? formatProgress(data?.mdapiDeploy?.numberTestErrors, data?.mdapiDeploy?.numberTestsTotal) + : undefined; }, stage: 'Running Tests', type: 'dynamic-key-value', @@ -219,22 +230,7 @@ export class DeployStages { data.numberTestsTotal > 0 && data.numberComponentsDeployed > 0 ) { - const mdapiDeploy: MetadataApiDeployStatus = { - ...data, - }; - if ( - Array.isArray(mdapiDeploy.details.runTestResult?.failures) && - mdapiDeploy.details.runTestResult?.failures.length > 0 - ) { - mdapiDeploy.details.runTestResult.failures = mdapiDeploy.details.runTestResult?.failures.filter( - (f) => !this.previousFailures.has(`${f.name}.${f.methodName}`) - ); - - console.log( - `TO RENDER 1: ${mdapiDeploy.details.runTestResult.failures.map((f) => `${f.name}.${f.methodName}`)}` - ); - } - this.mso.skipTo('Running Tests', { mdapiDeploy, status: mdTransferMessages.getMessage(data?.status) }); + this.mso.skipTo('Running Tests', { mdapiDeploy: data, status: mdTransferMessages.getMessage(data?.status) }); } else if (data.status === RequestStatus.Pending) { this.mso.skipTo('Waiting for the org to respond', { mdapiDeploy: data, From fcc83af585eca9fc8f47db48a827a645e7fed116 Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Fri, 13 Dec 2024 15:13:28 -0300 Subject: [PATCH 6/7] chore: remove success on CI output for deploy --- src/commands/project/delete/source.ts | 1 - src/commands/project/deploy/resume.ts | 1 - src/commands/project/deploy/start.ts | 1 - src/commands/project/deploy/validate.ts | 1 - src/utils/deployStages.ts | 24 +++--------------------- 5 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/commands/project/delete/source.ts b/src/commands/project/delete/source.ts index d53e5426..103cc03d 100644 --- a/src/commands/project/delete/source.ts +++ b/src/commands/project/delete/source.ts @@ -248,7 +248,6 @@ export class Source extends SfCommand { const stages = new DeployStages({ title: 'Deleting Metadata', jsonEnabled: this.jsonEnabled(), - verbose: this.flags['verbose'], }); const isRest = (await resolveApi()) === API['REST']; diff --git a/src/commands/project/deploy/resume.ts b/src/commands/project/deploy/resume.ts index 143c7cda..f24fcd26 100644 --- a/src/commands/project/deploy/resume.ts +++ b/src/commands/project/deploy/resume.ts @@ -134,7 +134,6 @@ export default class DeployMetadataResume extends SfCommand { new DeployStages({ title: 'Resuming Deploy', jsonEnabled: this.jsonEnabled(), - verbose: flags.verbose, }).start( { deploy, diff --git a/src/commands/project/deploy/start.ts b/src/commands/project/deploy/start.ts index 559bd94e..e0133378 100644 --- a/src/commands/project/deploy/start.ts +++ b/src/commands/project/deploy/start.ts @@ -250,7 +250,6 @@ export default class DeployMetadata extends SfCommand { this.stages = new DeployStages({ title, jsonEnabled: this.jsonEnabled(), - verbose: flags['verbose'], }); this.deployUrl = buildDeployUrl(flags['target-org'], deploy.id); diff --git a/src/commands/project/deploy/validate.ts b/src/commands/project/deploy/validate.ts index 3bb15b57..1f52f422 100644 --- a/src/commands/project/deploy/validate.ts +++ b/src/commands/project/deploy/validate.ts @@ -211,7 +211,6 @@ export default class DeployMetadataValidate extends SfCommand new DeployStages({ title: 'Validating Deployment', jsonEnabled: this.jsonEnabled(), - verbose: flags.verbose, }).start( { deploy, diff --git a/src/utils/deployStages.ts b/src/utils/deployStages.ts index 8a0c899c..d38acfc3 100644 --- a/src/utils/deployStages.ts +++ b/src/utils/deployStages.ts @@ -15,10 +15,9 @@ import { } from '@salesforce/source-deploy-retrieve'; import { SourceMemberPollingEvent } from '@salesforce/source-tracking'; import terminalLink from 'terminal-link'; -import { ensureArray } from '@salesforce/kit'; import ansis from 'ansis'; import { testResultSort } from '../formatters/testResultsFormatter.js'; -import { check, getZipFileSize } from './output.js'; +import { getZipFileSize } from './output.js'; import { isTruthy } from './types.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); @@ -27,7 +26,6 @@ const mdTransferMessages = Messages.loadMessages('@salesforce/plugin-deploy-retr type Options = { title: string; jsonEnabled: boolean; - verbose?: boolean; }; type Data = { @@ -64,7 +62,7 @@ export class DeployStages { */ private printedApexTestFailures: Set; - public constructor({ title, jsonEnabled, verbose }: Options) { + public constructor({ title, jsonEnabled }: Options) { this.printedApexTestFailures = new Set(); this.mso = new MultiStageOutput({ title, @@ -149,8 +147,7 @@ export class DeployStages { label: 'Successful', get: (data): string | undefined => data?.mdapiDeploy?.numberTestsTotal && data?.mdapiDeploy?.numberTestsCompleted - ? formatProgress(data?.mdapiDeploy?.numberTestsCompleted, data?.mdapiDeploy?.numberTestsTotal) + - (verbose && isCI() ? os.EOL + formatTestSuccesses(data) : '') + ? formatProgress(data?.mdapiDeploy?.numberTestsCompleted, data?.mdapiDeploy?.numberTestsTotal) : undefined, stage: 'Running Tests', type: 'dynamic-key-value', @@ -287,21 +284,6 @@ export class DeployStages { } } -function formatTestSuccesses(data: Data): string { - const successes = ensureArray(data.mdapiDeploy.details.runTestResult?.successes).sort(testResultSort); - - let output = ''; - - if (successes.length > 0) { - for (const test of successes) { - const testName = ansis.underline(`${test.name}.${test.methodName}`); - output += ` ${check} ${testName}${os.EOL}`; - } - } - - return output; -} - function formatTestFailures(failuresData: Failures[]): string { const failures = failuresData.sort(testResultSort); From bf615815bdbfb8762e979eaa77f8965849a89bff Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Fri, 13 Dec 2024 19:09:22 -0300 Subject: [PATCH 7/7] fix: use `alwaysPrintInCI` for test failures block --- src/utils/deployStages.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/deployStages.ts b/src/utils/deployStages.ts index d38acfc3..b63849ed 100644 --- a/src/utils/deployStages.ts +++ b/src/utils/deployStages.ts @@ -154,6 +154,7 @@ export class DeployStages { }, { label: 'Failed', + alwaysPrintInCI: true, get: (data): string | undefined => { let testFailures: Failures[] = [];