Skip to content

Commit

Permalink
Add a slack webhook for when nightly tests fail (#1941)
Browse files Browse the repository at this point in the history
## Description

This adds a slack notification when a nightly test fails so that we get
a ping.

## Related Issue

Fixes #N/A

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [X] Other (security config, docs update, etc)

## Checklist before merging

- [X] Test, docs, adr added or updated as needed
- [X] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed

---------

Co-authored-by: razzle <[email protected]>
  • Loading branch information
Racer159 and Noxsios authored Aug 2, 2023
1 parent 6f6bb3d commit a4848f9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 deletions.
45 changes: 45 additions & 0 deletions .github/actions/slack/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: slack
description: "Post a message to slack with the workflow status"

inputs:
slack-webhook-url:
description: 'The webhook URL to use to post to slack'
required: true

runs:
using: composite
steps:
- uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 #v1.24.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "The GitHub Action Workflow **'${{ github.workflow }}'** had a result of: `${{ job.status }}`."
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "View Workflow Run"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click Me",
"emoji": true
},
"value": "click_me_workflow_run",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"action_id": "button-action"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook-url }}
6 changes: 6 additions & 0 deletions .github/workflows/nightly-ecr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ jobs:
- name: Save logs
if: always()
uses: ./.github/actions/save-logs

- name: Send trigger to Slack on workflow failure
if: failure()
uses: ./.github/actions/slack
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
6 changes: 6 additions & 0 deletions .github/workflows/nightly-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ jobs:
- name: Save logs
if: always()
uses: ./.github/actions/save-logs

- name: Send trigger to Slack on workflow failure
if: failure()
uses: ./.github/actions/slack
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
2 changes: 1 addition & 1 deletion src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var rootCmd = &cobra.Command{

exec.ExitOnInterrupt()

// Don't add the logo to the help command
// Don't log the help command
if cmd.Parent() == nil {
config.SkipLogFile = true
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/nightly/ecr_publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestECRPublishing(t *testing.T) {
// Ensure we get a warning when trying to inspect the online published package
stdOut, stdErr, err = e2e.Zarf("package", "inspect", upstreamPackageURL, keyFlag)
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "Zarf is unable to validate the checksums of remote OCI packages.")
require.Contains(t, stdErr, "Checksums validated!")
require.Contains(t, stdErr, "Package signature validated!")

// Ensure we get an error when trying to pull the package without providing the public key
Expand All @@ -77,12 +77,12 @@ func TestECRPublishing(t *testing.T) {
// Ensure we get a warning when trying to inspect the package without providing the public key
stdOut, stdErr, err = e2e.Zarf("package", "inspect", testPackageFileName)
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "The package you are inspecting has been signed but a public key was not provided.")
require.Contains(t, stdErr, "All of the checksums matched!")
require.Contains(t, stdErr, "Checksums validated!")
require.Contains(t, stdErr, "The package was signed but no public key was provided, skipping signature validation")

// Validate that we get no warnings when inspecting the package while providing the public key
stdOut, stdErr, err = e2e.Zarf("package", "inspect", testPackageFileName, keyFlag)
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "All of the checksums matched!")
require.Contains(t, stdErr, "Checksums validated!")
require.Contains(t, stdErr, "Package signature validated!")
}

0 comments on commit a4848f9

Please sign in to comment.