Skip to content

Commit

Permalink
Implement exit codes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkgroenen committed Aug 4, 2023
1 parent 116ba03 commit 0b89b3d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ jobs:
data_source: reporting_api__marts
checks: ./testing/checks_p*.yaml
expected_exit_code: 0
- name: failing scan on check
- name: scan with check warnings
data_source: reporting_api__marts
checks: ./testing/checks_fail_on_check.yaml
checks: ./testing/checks_warn.yaml
expected_exit_code: 1
- name: scan with check failures
data_source: reporting_api__marts
checks: ./testing/checks_fail.yaml
expected_exit_code: 2
- name: failing scan on error
- name: scan with errors
data_source: MISSING_DS
checks: ./testing/checks_pass.yaml
expected_exit_code: 1
checks: ./testing/checks_error.yaml
expected_exit_code: 3
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
26 changes: 19 additions & 7 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ runs:
shell: bash

- name: Scan results link
if: env.SCAN_EXIT_CODE == 0 || env.SCAN_EXIT_CODE == 2
if: env.SCAN_EXIT_CODE <= 2
run: |
echo -e "\033[36;1m-----------------------------\033[0m"
echo -e "\033[36;1m View the full scan results -> \033[0m ${{ env.SCAN_CLOUD_LINK }}"
Expand Down Expand Up @@ -151,7 +151,19 @@ runs:
[View the full scan results](${{ env.SCAN_CLOUD_LINK }})
- name: Comment PR on failure with results
- name: Comment PR on warning
uses: thollander/actions-comment-pull-request@8c77f42bbcc27c832a3a5962c8f9a60e34b594f3
continue-on-error: true
if: env.SCAN_EXIT_CODE == 1
with:
message: |
🟠 Soda scan completed with the following results:
${{ steps.table.outputs.table }}
[View the full scan results](${{ env.SCAN_CLOUD_LINK }})
- name: Comment PR on failure
uses: thollander/actions-comment-pull-request@8c77f42bbcc27c832a3a5962c8f9a60e34b594f3
continue-on-error: true
if: env.SCAN_EXIT_CODE == 2
Expand All @@ -163,23 +175,23 @@ runs:
[View the full scan results](${{ env.SCAN_CLOUD_LINK }})
- name: Comment PR on fatal failure
- name: Comment PR on scan errors
uses: thollander/actions-comment-pull-request@8c77f42bbcc27c832a3a5962c8f9a60e34b594f3
continue-on-error: true
if: env.SCAN_EXIT_CODE == 1 || env.SCAN_EXIT_CODE == 3
if: env.SCAN_EXIT_CODE == 3
with:
message: |
🔴 Soda scan failed. Check logs for more details.
🔴 Soda scan failed. Check the logs for more details.
# 6. Post additional message to make it clear scan failed or not
- name: Fail Job if Soda Scan Failed
- name: Fail job if Soda scan failed
shell: bash
if: env.SCAN_EXIT_CODE != 0
run: |
echo -e "\033[31;1;4mSoda Scan failed\033[0m" && exit ${{ env.SCAN_EXIT_CODE }}
- name: Fail Job if Soda Scan Succeeded
- name: Exit job if Soda scan succeeded
shell: bash
if: env.SCAN_EXIT_CODE == 0
run: |
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions testing/checks_warn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
checks for incidents:
- row_count:
warn: when > 0

0 comments on commit 0b89b3d

Please sign in to comment.