Skip to content

Commit bc87966

Browse files
authored
Merge pull request #12 from terraform-google-modules/feature/change-test-org
Add cleanup command and fix CI slightly
2 parents 6c61e1c + f1870cd commit bc87966

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to
99

1010
## [Unreleased]
1111

12+
### Added
13+
14+
- Added continuous integration using Cloud Build. [#11]
15+
1216
## [1.0.0] - 2019-07-19
1317

1418
### Changed
@@ -26,3 +30,4 @@ and this project adheres to
2630
[1.0.0]: https://github.com/terraform-google-modules/terraform-google-kms/releases/tag/v1.0.0
2731

2832
[#3]: https://github.com/terraform-google-modules/terraform-google-kms/pull/3
33+
[#11]: https://github.com/terraform-google-modules/terraform-google-kms/pull/11

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The integration tests are run using [Kitchen][kitchen],
3232
tools are packaged within a Docker image for convenience.
3333

3434
The general strategy for these tests is to verify the behaviour of the
35-
[example modules](./examples), thus ensuring that the root module,
35+
[example modules](./examples/), thus ensuring that the root module,
3636
submodules, and example modules are all functionally correct.
3737

3838
### Test Environment

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ docker_test_prepare:
4141
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
4242
/usr/local/bin/execute_with_credentials.sh prepare_environment
4343

44+
# Cleanup tests within the docker container
45+
.PHONY: docker_test_cleanup
46+
docker_test_cleanup:
47+
docker run --rm -it \
48+
-e SERVICE_ACCOUNT_JSON \
49+
-e TF_VAR_org_id \
50+
-e TF_VAR_folder_id \
51+
-e TF_VAR_billing_account \
52+
-v $(CURDIR):/workspace \
53+
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
54+
/usr/local/bin/execute_with_credentials.sh cleanup_environment
55+
4456
# Execute integration tests within the docker container
4557
.PHONY: docker_test_integration
4658
docker_test_integration:

test/task_helper_functions.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616

1717
# Prepare the setup environment
1818
prepare_environment() {
19-
init_credentials
19+
set -eu
20+
21+
if [[ -z "${SERVICE_ACCOUNT_JSON:-}" ]]; then
22+
echo "Proceeding using application default credentials"
23+
else
24+
init_credentials
25+
fi
2026

2127
cd test/setup/ || exit
2228
terraform init
@@ -27,6 +33,25 @@ prepare_environment() {
2733
cd - || return
2834
}
2935

36+
# Destroy the setup environment
37+
cleanup_environment() {
38+
set -eu
39+
40+
if [[ -z "${SERVICE_ACCOUNT_JSON:-}" ]]; then
41+
echo "Proceeding using application default credentials"
42+
else
43+
init_credentials
44+
fi
45+
46+
cd test/setup/ || exit
47+
terraform init
48+
terraform destroy -auto-approve
49+
./make_source.sh
50+
# shellcheck disable=SC1091
51+
source ../source.sh
52+
cd - || return
53+
}
54+
3055
# Run kitchen tasks with sourced credentials
3156
kitchen_do() {
3257
# shellcheck disable=SC1091

0 commit comments

Comments
 (0)