Skip to content

Commit

Permalink
feat: improve robustness of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-FFFFFF authored and lonegunmanb committed Feb 27, 2025
1 parent 2d02786 commit b463d21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions avm_scripts/run-terraform-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail

# if $1 is not set, exit
if [ -z "$1" ]; then
Expand All @@ -17,15 +18,15 @@ fi
echo "==> Copy module to temp dir..."
RND="$RANDOM"
TMPDIR="/tmp/avmtester$RND"
cp -r . "$TMPDIR"
cp -r "$(pwd)" "$TMPDIR"
cd "$TMPDIR"

# clean up terraform files
find -type d -name .terraform -print0 | xargs -0 rm -rf
find -type f -name .terraform.lock.hcl -print0 | xargs -0 rm -rf
find -type f -name 'terraform.tfstate*' -print0 | xargs -0 rm -rf

echo "==> Running terraform test in $TESTDIR..."
# clean up terraform files

terraform init -test-directory="$TESTDIR"
terraform init -test-directory=" -test$TESTDIR"
terraform test -test-directory="$TESTDIR"
2 changes: 2 additions & 0 deletions avm_scripts/run-tflint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ run_tflint () {
return 0
}

set -e
echo "==> Copy module to temp dir..."
RND="$RANDOM"
TMPDIR="/tmp/avmtester$RND"
Expand All @@ -67,6 +68,7 @@ cd "$TMPDIR"
find -type d -name .terraform -print0 | xargs -0 rm -rf
find -type f -name .terraform.lock.hcl -print0 | xargs -0 rm -rf
find -type f -name 'terraform.tfstate*' -print0 | xargs -0 rm -rf
set +e

has_error=false

Expand Down

0 comments on commit b463d21

Please sign in to comment.