From 09a260318d675052dfd44ee4952305aeb5092a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 22 Jan 2025 10:52:26 +0100 Subject: [PATCH 1/2] Do not print warning about non-defined outputs in step --- packages/steps/src/BuildStep.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/packages/steps/src/BuildStep.ts b/packages/steps/src/BuildStep.ts index 21a43254..da0b51a9 100644 --- a/packages/steps/src/BuildStep.ts +++ b/packages/steps/src/BuildStep.ts @@ -432,31 +432,20 @@ export class BuildStep extends BuildStepOutputAccessor { private async collectAndValidateOutputsAsync(outputsDir: string): Promise { const files = await fs.readdir(outputsDir); - const nonDefinedOutputIds: string[] = []; for (const outputId of files) { if (!(outputId in this.outputById)) { - nonDefinedOutputIds.push(outputId); const newOutput = new BuildStepOutput(this.ctx.global, { id: outputId, stepDisplayName: this.displayName, required: false, }); - const file = path.join(outputsDir, outputId); - const rawContents = await fs.readFile(file, 'utf-8'); - const value = rawContents.trim(); - newOutput.set(value); this.outputById[outputId] = newOutput; - } else { - const file = path.join(outputsDir, outputId); - const rawContents = await fs.readFile(file, 'utf-8'); - const value = rawContents.trim(); - this.outputById[outputId].set(value); } - } - if (nonDefinedOutputIds.length > 0) { - const idsString = nonDefinedOutputIds.map((i) => `"${i}"`).join(', '); - this.ctx.logger.warn(`Some outputs are not defined in step config: ${idsString}`); + const file = path.join(outputsDir, outputId); + const rawContents = await fs.readFile(file, 'utf-8'); + const value = rawContents.trim(); + this.outputById[outputId].set(value); } const nonSetRequiredOutputIds: string[] = []; From e29ac71c481015a957d04972237b2436644c78e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 22 Jan 2025 10:53:09 +0100 Subject: [PATCH 2/2] Remove test --- .../steps/src/__tests__/BuildStep-test.ts | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/packages/steps/src/__tests__/BuildStep-test.ts b/packages/steps/src/__tests__/BuildStep-test.ts index a1455200..fb592be6 100644 --- a/packages/steps/src/__tests__/BuildStep-test.ts +++ b/packages/steps/src/__tests__/BuildStep-test.ts @@ -480,30 +480,6 @@ describe(BuildStep, () => { expect(abc?.value).toBe('d o m i n i k'); }); - it('prints a warning if some of the outputs set with set-output are not defined in step config', async () => { - const logger = createMockLogger(); - const warnLines: string[] = []; - jest.mocked(logger.warn as any).mockImplementation((line: string) => { - warnLines.push(line); - }); - jest.mocked(logger.child).mockReturnValue(logger); - - (baseStepCtx as any).baseLogger = logger; - - const id = 'test1'; - const command = 'set-output abc 123'; - const displayName = BuildStep.getDisplayName({ id, command }); - - const step = new BuildStep(baseStepCtx, { - id, - command, - displayName, - }); - await step.executeAsync(); - const found = warnLines.find((l) => l.match(/Some outputs are not defined in step config/)); - expect(found).not.toBeUndefined(); - }); - it('throws an error if some required outputs have not been set with set-output in script', async () => { const id = 'test1'; const command = 'echo 123';