From 01223b90c2c4e9d1b9374741ff1e8033c391ec39 Mon Sep 17 00:00:00 2001 From: anabellabuckvar <41971124+anabellabuckvar@users.noreply.github.com> Date: Thu, 9 May 2024 16:54:59 -0400 Subject: [PATCH 1/3] DOP-4549 (hotfix) (#1044) * DOP-4549-c hotfix check for empty group * DOP-4549-c add extra error check --- api/controllers/v1/slack.ts | 2 +- api/handlers/slack.ts | 72 +++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/api/controllers/v1/slack.ts b/api/controllers/v1/slack.ts index 3b2f71864..117e8a3db 100644 --- a/api/controllers/v1/slack.ts +++ b/api/controllers/v1/slack.ts @@ -50,7 +50,7 @@ export const DisplayRepoOptions = async (event: APIGatewayEvent): Promise - branchTwo.text.text - .toString() - .replace(/\d+/g, (n) => +n + 100000) - .localeCompare(branchOne.text.text.toString().replace(/\d+/g, (n) => +n + 100000)) - ), - }; - repoOptions.push(repoOption); + const repoOption = { + label: { + type: 'plain_text', + text: repoName, + }, + //sort the options by version number + options: options.sort((branchOne, branchTwo) => + branchTwo.text.text + .toString() + .replace(/\d+/g, (n) => +n + 100000) + .localeCompare(branchOne.text.text.toString().replace(/\d+/g, (n) => +n + 100000)) + ), + }; + repoOptions.push(repoOption); + } } return repoOptions.sort((repoOne, repoTwo) => repoOne.label.text.localeCompare(repoTwo.label.text)); } From 8e9616760064285e974cfe33dc0b0141ad35a1cb Mon Sep 17 00:00:00 2001 From: rayangler <27821750+rayangler@users.noreply.github.com> Date: Thu, 16 May 2024 11:05:40 -0400 Subject: [PATCH 2/3] Bump parser and frontend versions --- Dockerfile | 4 ++-- Dockerfile.local | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 65be09e59..e77c6b1a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,8 @@ RUN cd ./modules/oas-page-builder \ # where repo work will happen FROM ubuntu:20.04 ARG WORK_DIRECTORY=/home/docsworker-xlarge -ARG SNOOTY_PARSER_VERSION=0.16.6 -ARG SNOOTY_FRONTEND_VERSION=0.16.13 +ARG SNOOTY_PARSER_VERSION=0.16.7 +ARG SNOOTY_FRONTEND_VERSION=0.16.14 ARG MUT_VERSION=0.11.2 ARG REDOC_CLI_VERSION=1.2.3 ARG NPM_BASE_64_AUTH diff --git a/Dockerfile.local b/Dockerfile.local index 84646898a..985247dbe 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -1,8 +1,8 @@ FROM arm64v8/ubuntu:20.04 as initial ARG NPM_BASE_64_AUTH ARG NPM_EMAIL -ARG SNOOTY_PARSER_VERSION=0.16.6 -ARG SNOOTY_FRONTEND_VERSION=0.16.13 +ARG SNOOTY_PARSER_VERSION=0.16.7 +ARG SNOOTY_FRONTEND_VERSION=0.16.14 ARG MUT_VERSION=0.11.2 ARG REDOC_CLI_VERSION=1.2.3 ARG NPM_BASE_64_AUTH From 228c1fb45b6a7a127ba4e0bd055c5db12d7378b1 Mon Sep 17 00:00:00 2001 From: Heli Aldridge Date: Thu, 9 May 2024 11:00:03 -0400 Subject: [PATCH 3/3] DOP-4701: Preserve stdout in ShellCommandExecutor --- src/services/commandExecutor.ts | 2 +- .../services/shellCommandExecutor.test.ts | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/services/commandExecutor.ts b/src/services/commandExecutor.ts index 9dc2fe04d..96d31a84d 100644 --- a/src/services/commandExecutor.ts +++ b/src/services/commandExecutor.ts @@ -65,7 +65,7 @@ export class ShellCommandExecutor implements ICommandExecutor { resp.status = CommandExecutorResponseStatus.success; return resp; } catch (error) { - resp.output = ''; + resp.output = (error.stdout || '').trim(); resp.error = error; resp.status = CommandExecutorResponseStatus.failed; } diff --git a/tests/unit/services/shellCommandExecutor.test.ts b/tests/unit/services/shellCommandExecutor.test.ts index 1d2889a82..05ec7d64a 100644 --- a/tests/unit/services/shellCommandExecutor.test.ts +++ b/tests/unit/services/shellCommandExecutor.test.ts @@ -1,6 +1,5 @@ import { ShellCommandExecutor } from '../../../src/services/commandExecutor'; import cp from 'child_process'; -jest.mock('child_process'); describe('ShellCommandExecutor Tests', () => { let commandExecutor: ShellCommandExecutor; @@ -18,15 +17,26 @@ describe('ShellCommandExecutor Tests', () => { }); describe('ShellCommandExecutor Tests', () => { + test('ShellCommandExecutor returns correct output on success', async () => { + const command = ["echo 'stdout output'", "echo 'stderr output' >&2"]; + const resp = await commandExecutor.execute(command); + + expect(resp.error.toString()).toStrictEqual('stderr output\n'); + expect(resp.output).toBe('stdout output'); + expect(resp.status).toBe('success'); + }); + test('ShellCommandExecutor properly throws on system level error', async () => { - cp.exec.mockImplementation((command, options, callback) => { - callback(Error('Test error'), { stdErr: 'invalid command', stdout: 'test_repo_project_snooty_name' }); - }); - const resp = await commandExecutor.execute([]); - expect(resp.error).not.toBe(undefined); - expect(resp.output).toBe(''); + const command = ["echo 'stdout output'", "echo 'stderr output' >&2", 'exit 1']; + const resp = await commandExecutor.execute(command); + + // This is a strange interface, but I'm just here to fix a bug, not change the interface. + // The type of resp.error can be either a string or an Error instance. + expect(resp.error.toString()).toStrictEqual( + "Error: Command failed: echo 'stdout output' && echo 'stderr output' >&2 && exit 1\nstderr output\n" + ); + expect(resp.output).toBe('stdout output'); expect(resp.status).toBe('failed'); - expect(cp.exec).toBeCalledTimes(1); }); }); });