-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI/CD] Implement slack notifications for
test-dbt-installation-*
w…
…orkflows (#69) test-dbt-installation-notify-job-statuses.yml: - Added initial implementation; test-dbt-installation-main.yml: - Enabled schedule trigger; test-dbt-installation-docker.yml: - Added step to dump job status; - Added steps to generate artifact name and upload artifact; - Added step to generate statistics regarding jobs; test-dbt-installation-homebrew.yml: - Main job was renamed; - Added step to dump job status; - Added steps to generate artifact name and upload artifact; - Added step to generate statistics regarding jobs; test-dbt-installation-pip.yml: - Added step to dump job status; - Added steps to generate artifact name and upload artifact; - Added step to generate statistics regarding jobs; test-dbt-installation-sources.yml: - Added step to dump job status; - Added steps to generate artifact name and upload artifact; - Added step to generate statistics regarding jobs;
- Loading branch information
1 parent
be4f866
commit ba5ae9a
Showing
6 changed files
with
314 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
.github/workflows/test-dbt-installation-notify-job-statuses.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# **what?** | ||
# Check dumps of installation test jobs to aggregate statistics | ||
# and send the Slack notification. | ||
|
||
# **why?** | ||
# A consistent way to notify about failed dbt installation test | ||
# and provide additional context for the notification. | ||
|
||
# **when?** | ||
# When dbt installation test failed. | ||
# This reusable workflow can be launched on call by specifying: | ||
# artifact_name - that contains jobs dump | ||
# package_name - dbt adapter/repo/container that was tested | ||
# installation_method - installation method that failed | ||
|
||
name: dbt Installation - Notify Job Statuses In Slack | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
artifact_name: | ||
required: true | ||
type: string | ||
installation_method: | ||
required: true | ||
type: string | ||
package_name: | ||
required: true | ||
type: string | ||
secrets: | ||
SLACK_WEBHOOK_URL: | ||
description: Slack app webhook url | ||
required: true | ||
|
||
jobs: | ||
get-jobs-statuses: | ||
name: "Check Job Statuses" | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
jobs-statuses: ${{ steps.get-job_statistics.outputs.result }} | ||
|
||
steps: | ||
- name: "Download Artifact ${{ inputs.artifact_name }}" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ inputs.version_number }} | ||
path: . | ||
|
||
- name: "[DEBUG] Display Structure Of All Downloaded Files" | ||
run: ls -R | ||
|
||
- name: "Generate Slack Message" | ||
uses: actions/github-script@v6 | ||
id: get-job_statistics | ||
with: | ||
result-encoding: string | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const artifact_folder = './${{ inputs.artifact_name }}' | ||
const JOB_STATUSES_ENUM = { | ||
success: "success", | ||
failure: "failure", | ||
cancelled: "cancelled" | ||
}; | ||
const jobs_statuses = { | ||
failure: [], | ||
success: [], | ||
cancelled: [], | ||
undefined: [] | ||
}; | ||
const files_list = fs.readdirSync(artifact_folder); | ||
core.debug(files_list); | ||
files_list.map(file => { | ||
const buffer = fs.readFileSync(`${artifact_folder}/${file}`); | ||
const jobs_status = buffer.toString().trim().replace(/['"]+/g, ''); | ||
switch (jobs_status) { | ||
case JOB_STATUSES_ENUM.success: | ||
jobs_statuses.success.push(file); | ||
break; | ||
case JOB_STATUSES_ENUM.failure: | ||
jobs_statuses.failure.push(file); | ||
break; | ||
case JOB_STATUSES_ENUM.cancelled: | ||
jobs_statuses.cancelled.push(file); | ||
break; | ||
default: | ||
jobs_statuses.undefined.push(file); | ||
} | ||
}); | ||
const job_statistics = `Test jobs statuses: ${JOB_STATUSES_ENUM.success} - ${jobs_statuses.success.length}, ${JOB_STATUSES_ENUM.failure} - ${jobs_statuses.failure.length}, ${JOB_STATUSES_ENUM.cancelled} - ${jobs_statuses.cancelled.length}, undefined - ${jobs_statuses.undefined.length}.`; | ||
core.debug(job_statistics); | ||
return job_statistics; | ||
slack-notification: | ||
name: "Post Scheduled Run Failures" | ||
needs: get-jobs-statuses | ||
|
||
uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main | ||
with: | ||
status: "failure" | ||
notification_title: "${{ inputs.installation_method }} nightly installation test failed for - ${{ inputs.package_name }}. ${{ needs.get-jobs-statuses.outputs.jobs-statuses }}" | ||
|
||
secrets: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
Oops, something went wrong.