diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d799db29..c2ba2288 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,3 +5,10 @@ lint: - scripts/ci/tfinit.sh - scripts/ci/tflint.sh # - scripts/ci/undeclared-variables.sh + +test: + script: + - scripts/ci/examples/tfbuild.sh + - scripts/ci/examples/tftest.sh + - scripts/ci/examples/tfcleanup.sh + when: manual diff --git a/CHANGELOG.md b/CHANGELOG.md index db9655d5..1b3fe656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ * `gitlab-ha`: Update `Makefile` * `vpc-gateway`: correct module path reference * `legacy`: drop deprecated example - +* `s3-full-access-policy`: setup CI for building and running tests # v0.8.2 diff --git a/examples/s3-full-access-policy/Makefile b/examples/s3-full-access-policy/Makefile index ba843465..85dcfdb0 100644 --- a/examples/s3-full-access-policy/Makefile +++ b/examples/s3-full-access-policy/Makefile @@ -33,7 +33,7 @@ test: # clean up terrform and any other files clean: - @terraform destroy + @terraform destroy -auto-approve @rm -f tf.out @rm -f terraform.tfvars @rm -f terraform.*.backup diff --git a/scripts/ci/examples/tfbuild.sh b/scripts/ci/examples/tfbuild.sh new file mode 100755 index 00000000..80d89467 --- /dev/null +++ b/scripts/ci/examples/tfbuild.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -o nounset +set -o pipefail +set -o errexit + +pushd "$(dirname $(basename "${0}"))/examples/s3-full-access-policy" > /dev/null + +make init && make plan && make apply && make output 1> /dev/null + +popd > /dev/null diff --git a/scripts/ci/examples/tfcleanup.sh b/scripts/ci/examples/tfcleanup.sh new file mode 100755 index 00000000..64cdaec8 --- /dev/null +++ b/scripts/ci/examples/tfcleanup.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -o nounset +set -o pipefail +set -o errexit + +pushd "$(dirname $(basename "${0}"))/examples/s3-full-access-policy" > /dev/null + +make clean 1> /dev/null + +popd > /dev/null diff --git a/scripts/ci/examples/tftest.sh b/scripts/ci/examples/tftest.sh new file mode 100755 index 00000000..2206b21a --- /dev/null +++ b/scripts/ci/examples/tftest.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -o nounset +set -o pipefail +set -o errexit + +pushd "$(dirname $(basename "${0}"))/examples/s3-full-access-policy" > /dev/null + +make test 1> /dev/null + +popd > /dev/null diff --git a/scripts/ci/tfinit.sh b/scripts/ci/tfinit.sh index 2bd95cad..1c7d84fa 100755 --- a/scripts/ci/tfinit.sh +++ b/scripts/ci/tfinit.sh @@ -1,4 +1,4 @@ -#/bin/bash +#!/usr/bin/env bash set -o nounset set -o pipefail @@ -9,3 +9,9 @@ pushd "$(dirname $(basename "${0}"))/tests" > /dev/null terraform init 1> /dev/null popd > /dev/null + +pushd "$(dirname $(basename "${0}"))/examples/s3-full-access-policy" > /dev/null + +terraform init 1> /dev/null + +popd > /dev/null diff --git a/scripts/ci/tflint.sh b/scripts/ci/tflint.sh index beb0e728..4a3f8451 100755 --- a/scripts/ci/tflint.sh +++ b/scripts/ci/tflint.sh @@ -1,4 +1,4 @@ -#/bin/bash +#!/usr/bin/env bash set -o nounset set -o pipefail @@ -7,6 +7,13 @@ set -o errexit pushd "$(dirname "$(basename "${0}")")/tests" > /dev/null terraform init 1> /dev/null 2>&1 || true -tflint --error-with-issues +tflint --error-with-issues + +popd > /dev/null + +pushd "$(dirname $(basename "${0}"))/examples/s3-full-access-policy" > /dev/null + +terraform init 1> /dev/null 2>&1 || true +tflint --error-with-issues popd > /dev/null