Skip to content

Commit

Permalink
Add test for Slack announcement [WiP]
Browse files Browse the repository at this point in the history
Added the test checking if the failed workflow gets announced on Slack

See: #13604
  • Loading branch information
radoslawkrzemien committed Jun 30, 2023
1 parent 949f420 commit d51407d
Show file tree
Hide file tree
Showing 4 changed files with 371 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: Announce failed workflow in Slack
if: ${{ failure() }}
if: failure()
uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main
with:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Expand Down
19 changes: 19 additions & 0 deletions workflow_tests/assertions/preDeployAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,24 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul
}
};

const assertUpdateStagingJobFailed = (workflowResult, didFail = false) => {
const steps = [
utils.getStepAssertion(
'Announce failed workflow in Slack',
true,
null,
'UPDATE_STAGING',
'Announcing failed workflow in Slack',
[{key: 'SLACK_WEBHOOK', value: '***'}],
),
];
if (didFail) {
expect(workflowResult).toEqual(expect.arrayContaining(steps));
} else {
expect(workflowResult).not.toEqual(steps);
}
};

module.exports = {
assertLintJobExecuted,
assertTestJobExecuted,
Expand All @@ -475,4 +493,5 @@ module.exports = {
assertSkipDeployJobExecuted,
assertCreateNewVersionJobExecuted,
assertUpdateStagingJobExecuted,
assertUpdateStagingJobFailed,
};
3 changes: 2 additions & 1 deletion workflow_tests/mocks/preDeployMocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.getMockStep(
);
const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.getMockStep(
'Announce failed workflow in Slack',
'Announcing failed workflow in slack',
'Announcing failed workflow in Slack',
'UPDATE_STAGING',
['SLACK_WEBHOOK'],
);
const UPDATE_STAGING_JOB_MOCK_STEPS = [
RUN_TURNSTYLE_MOCK_STEP,
Expand Down
Loading

0 comments on commit d51407d

Please sign in to comment.