From eaf4915fb6e5ff99bb25e41843aa636dd439f4a2 Mon Sep 17 00:00:00 2001 From: Avishag Israeli Date: Mon, 1 Mar 2021 15:24:32 +0200 Subject: [PATCH] test: wrap pagerduty await in try-catch, remove condition --- test/cli-alert/src/index.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/test/cli-alert/src/index.ts b/test/cli-alert/src/index.ts index d9493ee7ff..6487985055 100644 --- a/test/cli-alert/src/index.ts +++ b/test/cli-alert/src/index.ts @@ -73,21 +73,25 @@ async function discoverConsecutiveFailures( } async function sendPagerDuty() { - await event({ - data: { - // eslint-disable-next-line @typescript-eslint/camelcase - routing_key: PD_ROUTING_KEY, - // eslint-disable-next-line @typescript-eslint/camelcase - event_action: 'trigger', - payload: { - summary: 'CLI Alert. Smoke tests failing', - source: 'Snyk CLI Smoke tests', - severity: 'warning', + try { + const res = await event({ + data: { + // eslint-disable-next-line @typescript-eslint/camelcase + routing_key: PD_ROUTING_KEY, + // eslint-disable-next-line @typescript-eslint/camelcase + event_action: 'trigger', + payload: { + summary: 'CLI Alert. Smoke tests failing', + source: 'Snyk CLI Smoke tests', + severity: 'warning', + }, }, - }, - }) - .then(console.log) - .catch(console.error); + }); + console.log(res); + } catch (err) { + console.error(err); + process.exit(1); + } } async function sendSlackAlert(failedJobs: string[]) { @@ -219,7 +223,7 @@ async function run() { latestWorkflowRuns[1].id, ); - if (!failedWorkflows.length || failedWorkflows.length < 1) { + if (!failedWorkflows.length) { console.log( 'There were no 2 consecutive fails on a job. No need to alert.', );