-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentrypoint.sh
executable file
·132 lines (118 loc) · 3.54 KB
/
entrypoint.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
export ALIBABA_CLOUD_ACCESS_KEY_ID=$INPUT_ACCESS_KEY_ID
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=$INPUT_ACCESS_KEY_SECRET
pass_test=1
if [ "$INPUT_TYPE" = "validate" ]; then
for file in $INPUT_TEMPLATES
do
if [[ "$file" == .github* ]]; then
continue
fi
if [[ "$file" == .DS_Store* ]]; then
continue
fi
if [[ "$file" != *.yml ]] && [[ "$file" != *.yaml ]] ; then
continue
fi
echo -e "\n------Testing $file------"
if [[ "$file" != iact3-config/* ]]; then
python -m iact3 validate -t "$file" >> output.txt 2>&1
cat output.txt
if ! grep -q "LegalTemplate" output.txt; then
pass_test=0
fi
rm -rf output.txt
fi
done
if [ $pass_test -eq 1 ]
then
echo "status=success" >> $GITHUB_OUTPUT
exit 0
else
echo "status=fail" >> $GITHUB_OUTPUT
exit 1
fi
fi
declare -a template_prefix_files=()
for file in $INPUT_TEMPLATES
do
if [[ "$file" == .github* ]]; then
continue
fi
if [[ "$file" == .DS_Store* ]]; then
continue
fi
is_test_run=0
echo -e "\n------Testing $file------"
if [[ "$file" == iact3-config/* ]]; then
#config file
template_file_prefix=${file#iact3-config/}
template_file_prefix=${template_file_prefix%.*}
template_file_prefix=${template_file_prefix%.*}
template_file_path=""
if [[ " ${template_prefix_files[@]} " =~ " ${template_file_prefix} " ]]; then
continue
fi
if [ -f ${template_file_prefix}.yml ]; then
template_file_path=${template_file_prefix}.yml
is_test_run=1
echo "iact3 test run -t $template_file_path -c $file"
python -m iact3 test run -t "$template_file_path" -c "$file" > /dev/null
elif [ -f ${template_file_prefix}.yaml ]; then
template_file_path=${template_file_prefix}.yaml
is_test_run=1
echo "iact3 test run -t $template_file_path -c $file"
python -m iact3 test run -t "$template_file_path" -c "$file" > /dev/null
else
echo "$file has no template file. Skip testing."
fi
template_prefix_files+=("$template_file_prefix")
else
#template file
config_file_prefix=iact3-config/${file%.*}.iact3
config_file_path=""
template_file_prefix=${file%.*}
if [[ " ${template_prefix_files[@]} " =~ " ${template_file_prefix} " ]]
then
continue
fi
if [ -f ${config_file_prefix}.yml ]; then
config_file_path=${config_file_prefix}.yml
echo "iact3 test run -t $file -c $config_file_path"
is_test_run=1
python -m iact3 test run -t "$file" -c "$config_file_path" > /dev/null
elif [ -f ${config_file_prefix}.yaml ]; then
config_file_path=${config_file_prefix}.yaml
echo "iact3 test run -t $file -c $config_file_path"
is_test_run=1
python -m iact3 test run -t "$file" -c "$config_file_path" > /dev/null
else
echo "iact3 validate -t $file"
python -m iact3 validate -t "$file" >> output.txt 2>&1
echo $file
cat output.txt
if ! grep -q "LegalTemplate" output.txt; then
pass_test=0
fi
rm -rf output.txt
fi
template_prefix_files+=("$template_file_prefix")
fi
if [ $is_test_run -eq 1 ]; then
test_name=$(basename $template_file_prefix)
test_name="test-${test_name}"
cat iact3_outputs/${test_name}-result.json
test_result=$(jq '.Result' iact3_outputs/${test_name}-result.json)
if [[ $test_result != "\"Success\"" ]]; then
pass_test=0
fi
fi
done
if [ $pass_test -eq 1 ]
then
echo "status=success" >> $GITHUB_OUTPUT
exit 0
else
echo "status=fail" >> $GITHUB_OUTPUT
exit 1
fi