add ci (#140)
This commit is contained in:
19
scripts/terrafmt-check.sh
Normal file
19
scripts/terrafmt-check.sh
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "==> Checking documentation terraform blocks are formatted..."
|
||||
files=$(find . -type f -name "*.md" -o -name "*.go" | grep -v -e ".github" -e "-terraform" -e "vendor" -e ".terraform")
|
||||
error=false
|
||||
for f in $files; do
|
||||
terrafmt diff -c -q "$f" || error=true
|
||||
done
|
||||
if ${error}; then
|
||||
echo "------------------------------------------------"
|
||||
echo ""
|
||||
echo "The preceding files contain terraform blocks that are not correctly formatted or contain errors."
|
||||
echo "You can fix this by running make tools and then terrafmt on them."
|
||||
echo ""
|
||||
echo "to easily fix all terraform blocks:"
|
||||
echo "$ make terrafmt"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
16
scripts/terraform-fmt.sh
Normal file
16
scripts/terraform-fmt.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "==> Checking terraform codes are formatted..."
|
||||
error=false
|
||||
terraform fmt -check -recursive || error=true
|
||||
if ${error}; then
|
||||
echo "------------------------------------------------"
|
||||
echo ""
|
||||
echo "The preceding files contain terraform codes that are not correctly formatted or contain errors."
|
||||
echo "You can fix this by running make tools and then tffmt on them."
|
||||
echo ""
|
||||
echo "to easily fix all terraform codes:"
|
||||
echo "$ make tffmt"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
19
scripts/terraform-validate.sh
Normal file
19
scripts/terraform-validate.sh
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
error=false
|
||||
|
||||
folders=$CHANGED_FOLDERS
|
||||
for f in ${folders//,/ }
|
||||
do
|
||||
f=$(echo $f | xargs echo -n)
|
||||
(echo "===> Terraform validating in" /src/$f && cd /src/$f && rm -f .terraform.lock.hcl && rm -rf .terraform && terraform init -upgrade && terraform validate -json | jq -e .valid) || error=true
|
||||
if ${error}; then
|
||||
echo "------------------------------------------------"
|
||||
echo ""
|
||||
echo "Some Terraform codes contain errors."
|
||||
echo "$(cd /src/$f && terraform validate -json)"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
23
scripts/update-test-record.sh
Normal file
23
scripts/update-test-record.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ ! -d "TestRecord" ]; then
|
||||
echo "No TestRecord found, exit"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd TestRecord
|
||||
|
||||
folders=$(find ./ -maxdepth 1 -mindepth 1 -type d)
|
||||
for f in $folders; do
|
||||
d=${f#"./"}
|
||||
|
||||
if [ ! -f ../quickstart/$d/TestRecord.md ]; then
|
||||
touch ../quickstart/$d/TestRecord.md
|
||||
fi
|
||||
|
||||
cat ../quickstart/$d/TestRecord.md >> $d/TestRecord.md.tmp
|
||||
cat $d/TestRecord.md.tmp > ../quickstart/$d/TestRecord.md
|
||||
done
|
||||
|
||||
cd ..
|
||||
git add **/TestRecord.md
|
Reference in New Issue
Block a user