-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_checks.sh
executable file
·70 lines (56 loc) · 2.23 KB
/
run_checks.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
#!/bin/bash
if [ "${AWS_PROVIDER_PATH}" = "" ]; then
echo "ERROR: Must set the AWS_PROVIDER_PATH to AWS provider location"
fi
rm ./results/*txt || echo "Nothing to delete"
mkdir results || echo "Results directory already exists"
tests=( ${AWS_PROVIDER_PATH}/awsproviderlint/passes/AWS*/ )
for test_path in ${tests[@]}; do
test=$(basename ${test_path})
echo "Static check: ${test}"
descriptions+=( "awsproviderlint! [${test}](https://github.com/terraform-providers/terraform-provider-aws/tree/master/awsproviderlint/passes/${test})" )
filenames+=( "./results/${test}.txt" )
awsproviderlint -${test} ${AWS_PROVIDER_PATH}/aws &> ${filenames[${#filenames[@]}-1]}
done
tests=( ${TF_PROVIDER_LINT_PATH}/passes/{AT*,R*,S*,V*}/ )
for test_path in ${tests[@]}; do
test=$(basename ${test_path})
echo "Static check: ${test}"
descriptions+=( "tfproviderlint! [${test}](https://github.com/bflad/tfproviderlint/tree/master/passes/${test})" )
filenames+=( "./results/${test}.txt" )
awsproviderlint -${test} ${AWS_PROVIDER_PATH}/aws &> ${filenames[${#filenames[@]}-1]}
done
###################
# get tallies #
###################
talliesFile="./results/tallies.txt"
printf "Tallies\n" > ${talliesFile}
for i in "${!descriptions[@]}"; do
count=$(< "${filenames[$i]}" wc -l)
printf "%s\t%s\n" "$count" "${descriptions[$i]}" >> ${talliesFile}
done
###################
# create readme #
###################
readmeFile="README.md"
cat README_header.md > ${readmeFile}
printf "# %s\n" "Checks" >> ${readmeFile}
lastTitle=""
for i in "${!descriptions[@]}"; do
IFS='!'
read -ra titleDesc <<< "${descriptions[$i]}"
title="${titleDesc[0]}"
description="${titleDesc[1]}"
if [ "${title}" != "${lastTitle}" ]; then
printf "## %s\n\n" "${title}" >> ${readmeFile}
lastTitle="${title}"
fi
count=$(< "${filenames[$i]}" wc -l)
example=$(shuf -n 1 "${filenames[$i]}")
printf "### %s\nCount: %s\n" "${description}" "${count}" >> ${readmeFile}
if (( count > 0 )); then
printf "[List matches](%s)\n\n" "${filenames[$i]}" >> ${readmeFile}
printf "Example: \`%s\`\n\n" "${example}" >> ${readmeFile}
fi
done
printf "\n\n\n[%s](%s)\n" "AWS EC2 Instance Types/Prices" "https://github.com/YakDriver/aws-ec2-instance-types" >> "${readmeFile}"