generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure an erroring ingestion produces a slack alert (#335)
* Ensure an erroring ingestion produces a slack alert * test threshold works
- Loading branch information
Showing
1 changed file
with
17 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,8 +80,12 @@ jobs: | |
DATAHUB_GMS_URL: ${{ vars.DATAHUB_GMS_URL }} | ||
DATAHUB_TELEMETRY_ENABLED: false | ||
run: | | ||
time poetry run datahub ingest -c ingestion/cadet.yaml --report-to output.json | ||
FAILURE_COUNT=$(jq '.source.failures | length' output.json) | ||
time poetry run datahub ingest -c ingestion/cadet.yaml --report-to output.json || true | ||
if [ ! -f output.json ]; then | ||
echo "Ingestion output file not found. Failing the job." | ||
exit 1 | ||
fi | ||
FAILURE_COUNT=$(jq '.sink.report.failures | length' output.json) | ||
echo "failure_count=$FAILURE_COUNT" >> $GITHUB_ENV | ||
- name: Notify on unexpected ingestion failures | ||
|
@@ -94,3 +98,14 @@ jobs: | |
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }} | ||
|
||
- name: Notify on ingestion not producing output.json or an unhandled failure | ||
uses: slackapi/[email protected] | ||
if: failure() | ||
with: | ||
payload: | | ||
{ | ||
"text": ":warning: ALERT: DataHub CaDeT metadata ingestion produced no output on ${{inputs.ENVIRONMENT}} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }} |