Skip to content

Commit

Permalink
test: wrap pagerduty await in try-catch, remove condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Avishag Israeli authored and JackuB committed Mar 1, 2021
1 parent 0576431 commit eaf4915
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions test/cli-alert/src/index.ts
Expand Up @@ -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[]) {
Expand Down Expand Up @@ -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.',
);
Expand Down

0 comments on commit eaf4915

Please sign in to comment.