Sync from deal-sage/deal-sage@83bb6f4c19
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
# a failure: the build should not be blocked by the dashboard being down.
|
||||
set -euo pipefail
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
step_start checks
|
||||
require_env APP_ID CHECKS_JSON DEALSAGE_FUNCTIONS_URL PUBLISH_TOKEN SUPABASE_ANON_KEY
|
||||
git_context
|
||||
CHECKS_DIR="$(cd "$(dirname "$0")/../checks" && pwd)"
|
||||
@@ -28,10 +29,12 @@ post_check() { # id name status required duration_ms summary logfile started fin
|
||||
|
||||
results='[]'
|
||||
required_failed=()
|
||||
advisory_failed=()
|
||||
count="$(jq 'length' <<<"$CHECKS_JSON")"
|
||||
if [ "$count" = 0 ]; then
|
||||
log "No checks declared in .dealsage/app.json"
|
||||
persist_env CHECKS_RESULT_JSON '[]'
|
||||
step_done checks skipped "No checks declared in .dealsage/app.json"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -59,7 +62,9 @@ while IFS= read -r check; do
|
||||
post_check "$id" "$name" "$status" "$required" "$dur" "$summary" "$logf" "$started" "$(iso_now)"
|
||||
results="$(jq -c --arg id "$id" --arg status "$status" --argjson d "$dur" --argjson req "$required" \
|
||||
'. + [{id:$id, status:$status, durationMs:$d, required:$req}]' <<<"$results")"
|
||||
if [ "$status" != passed ] && [ "$required" = true ]; then required_failed+=("$name"); fi
|
||||
if [ "$status" != passed ]; then
|
||||
if [ "$required" = true ]; then required_failed+=("$name"); else advisory_failed+=("$name"); fi
|
||||
fi
|
||||
rm -f "$logf"
|
||||
done < <(jq -c '.[]' <<<"$CHECKS_JSON")
|
||||
|
||||
@@ -68,6 +73,12 @@ summary "### Checks"
|
||||
summary "$(jq -r '.[] | "- \(.id): **\(.status)** (\(.durationMs)ms\(if .required then "" else ", advisory" end))"' <<<"$results")"
|
||||
|
||||
if [ "${#required_failed[@]}" -gt 0 ]; then
|
||||
die "Required check(s) failed: ${required_failed[*]}. The build was not published."
|
||||
fail_build checks_failed "Required check(s) failed: ${required_failed[*]}. The build was not published."
|
||||
fi
|
||||
log "All required checks passed"
|
||||
passed="$(jq '[.[] | select(.status == "passed")] | length' <<<"$results")"
|
||||
note="$passed of $count passed"
|
||||
if [ "${#advisory_failed[@]}" -gt 0 ]; then
|
||||
note="$note ($(printf '%s, ' "${advisory_failed[@]}" | sed 's/, $//') failed, not required)"
|
||||
fi
|
||||
step_done checks passed "$note"
|
||||
|
||||
Reference in New Issue
Block a user