This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
forked from great-expectations/great_expectations_action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_checkpoints.sh
executable file
·80 lines (67 loc) · 2.59 KB
/
run_checkpoints.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
set -e
# Validate That Required Inputs Were Supplied
function check_env() {
if [ -z $(eval echo "\$$1") ]; then
echo "Variable $1 not found. Exiting..."
exit 1
fi
}
check_env "INPUT_CHECKPOINTS"
# Loop through checkpoints
STATUS=0
IFS=','
FAILING_CHECKPOINTS=""
PASSING_CHECKPOINTS=""
for c in $INPUT_CHECKPOINTS;do
echo ""
echo "Validating Checkpoint: ${c}"
if ! great_expectations checkpoint run $c;
then
STATUS=1
if [[ -z "$FAILING_CHECKPOINTS" ]];
then
export FAILING_CHECKPOINTS="${c}"
else
export FAILING_CHECKPOINTS="${FAILING_CHECKPOINTS},${c}"
fi
else
if [[ -z "$PASSING_CHECKPOINTS" ]];
then
export PASSING_CHECKPOINTS="${c}"
else
export PASSING_CHECKPOINTS="${PASSING_CHECKPOINTS},${c}"
fi
fi
done
# Build the ephemeral docs site and read location of site into DOCS_LOC
python /build_gh_action_site.py
DOCS_LOC=`cat _temp_greatexpectations_action_docs_location_dir.txt`
# Emit Failing and Passing Checkpoints as output variables
export FAILING_CHECKPOINTS="${FAILING_CHECKPOINTS}"
echo "::set-output name=FAILING_CHECKPOINTS::${FAILING_CHECKPOINTS}"
echo "::set-output name=PASSING_CHECKPOINTS::${PASSING_CHECKPOINTS}"
# Optionally launch docs on Netlify
if [[ ! -z "$INPUT_NETLIFY_AUTH_TOKEN" ]] && [[ ! -z "$INPUT_NETLIFY_SITE_ID" ]];
then
# Set Inputs to proper environment variable names for Netlify CLI
export NETLIFY_AUTH_TOKEN=$INPUT_NETLIFY_AUTH_TOKEN
export NETLIFY_SITE_ID=$INPUT_NETLIFY_SITE_ID
# Verify Docs Directory
[[ -z "$DOCS_LOC" ]] && { echo "Variable DOCS_LOC is empty" ; exit 1; }
[[ ! -d "$DOCS_LOC" ]] && { echo "Directory specified in variable DOCS_LOC: ${DOCS_LOC} does not exist."; exit 1; }
# Deploy docs site to Netlify, and write out to logs
netlify deploy --dir $DOCS_LOC | tee _netlify_logs.txt
# Parse URL from logs and send to next step
export DOCS_URL=`cat _netlify_logs.txt | awk '/Draft URL: /{print $4}'`
## Verify URL exists and emit it as an output variable
[[ -z "$DOCS_URL" ]] && { echo "Variable DOCS_URL is empty" ; exit 1; }
echo "::set-output name=NETLIFY_DOCS_URL::${DOCS_URL}"
else
echo "Netlify Deploy Skipped."
fi
echo "::set-output name=CHECKPOINT_FAILURE_FLAG::${STATUS}"
# # exit with appropriate status if DEBUG flag is not set.
if [[ -z "$INPUT_DEBUG" ]]; then
exit $STATUS;
fi