Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ingwarr committed Oct 8, 2019
1 parent 1a61547 commit 55bc3c3
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 231 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ test/fixtures/*/terraform.tfvars
terraform.tfstate.d/
*.auto.tfvars
credentials.json
/.idea/
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed

- Fix linter warnings and related makefile bug [#11]
- Standardize integration testing [#11]

## [1.0.0] - 2019-09-24

### Changed
Expand All @@ -20,5 +25,5 @@ project adheres to [Semantic Versioning](http://semver.org/).
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-memorystore/compare/1.0.0...HEAD
[1.0.0]: https://github.com/terraform-google-modules/terraform-google-memorystore/compare/0.1.0...1.0.0
[0.1.0]: https://github.com/terraform-google-modules/terraform-google-memorystore/releases/tag/0.1.0

[#10]: https://github.com/terraform-google-modules/terraform-google-memorystore/pull/10
[#11]: https://github.com/terraform-google-modules/terraform-google-memorystore/pull/11
80 changes: 39 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Make will use bash instead of sh
SHELL := /usr/bin/env bash

# Docker build config variables
Expand All @@ -21,112 +20,111 @@ DOCKER_ORG := gcr.io/cloud-foundation-cicd
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.3.0
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}

all: check_shell check_python check_golang check_terraform test_check_headers check_headers check_trailing_whitespace generate_docs ## Run all linters and update documentation
# All is the first target in the file so it will get picked up when you just run 'make' on its own
.PHONY: all
all: check generate_docs

# Run all available linters
.PHONY: check
check: check_shell check_python check_golang check_terraform check_base_files check_headers check_trailing_whitespace

# The .PHONY directive tells make that this isn't a real target and so
# the presence of a file named 'check_shell' won't cause this target to stop
# working
.PHONY: check_shell
check_shell: ## Lint shell scripts
check_shell:
@source test/make.sh && check_shell

.PHONY: check_python
check_python: ## Lint Python source files
check_python:
@source test/make.sh && check_python

.PHONY: check_golang
check_golang: ## Lint Go source files
check_golang:
@source test/make.sh && golang

.PHONY: check_terraform
check_terraform: ## Lint Terraform source files
@source test/make.sh && check_terraform

.PHONY: check_shebangs
check_shebangs: ## Check that scripts have correct shebangs
@source test/make.sh && check_bash
.PHONY: check_base_files
check_base_files:
@source test/make.sh && basefiles

.PHONY: check_trailing_whitespace
check_trailing_whitespace:
@source test/make.sh && check_trailing_whitespace

.PHONY: test_check_headers
test_check_headers:
@echo "Testing the validity of the header check"
@source test/make.sh && check_headers

.PHONY: check_headers
check_headers: ## Check that source files have appropriate boilerplate
@source test/make.sh && check_headers

# Integration tests
.PHONY: test_integration
test_integration: ## Run integration tests
bundle install
bundle exec kitchen create
bundle exec kitchen converge
bundle exec kitchen converge
bundle exec kitchen verify
bundle exec kitchen destroy
test_integration:
test/ci_integration.sh

.PHONY: generate_docs
generate_docs: ## Update README documentation for Terraform variables and outputs
generate_docs:
@source test/make.sh && generate_docs

# Run docker
.PHONY: docker_run
docker_run: ## Launch a shell within the Docker test environment
docker_run:
docker run --rm -it \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash
/bin/bash -c "source test/ci_integration.sh && setup_environment && exec /bin/bash"

.PHONY: docker_create
docker_create: ## Run `kitchen create` within the Docker test environment
docker_create:
docker run --rm -it \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen create"
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen create"

.PHONY: docker_converge
docker_converge: ## Run `kitchen converge` within the Docker test environment
docker_converge:
docker run --rm -it \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen converge && kitchen converge"
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen converge"

.PHONY: docker_verify
docker_verify: ## Run `kitchen verify` within the Docker test environment
docker_verify:
docker run --rm -it \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen verify"
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen verify"

.PHONY: docker_destroy
docker_destroy: ## Run `kitchen destroy` within the Docker test environment
docker_destroy:
docker run --rm -it \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen destroy"
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen destroy"

.PHONY: test_integration_docker
test_integration_docker: docker_create docker_converge docker_verify docker_destroy ## Run a full integration test cycle
@echo "Running test-kitchen tests in docker"

help: ## Prints help for targets with comments
@grep -E '^[a-zA-Z._-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
test_integration_docker:
docker run --rm -it \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "source test/ci_integration.sh && setup_environment && make test_integration"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module "memorystore" {
| Name | Description |
|------|-------------|
| current\_location\_id | The current zone where the Redis endpoint is placed. |
| host | The IP address of the instance. |
| host | The memorystore instance ID. |
| id | The memorystore instance ID. |
| region | The region the instance lives in. |

Expand Down
61 changes: 0 additions & 61 deletions build/docker/kitchen_terraform/Dockerfile

This file was deleted.

102 changes: 0 additions & 102 deletions build/docker/terraform/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions examples/basic/memorystore.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ provider "google" {
}

module "memorystore" {
source = "git::ssh://git@github.com/terraform-google-modules/terraform-google-memorystore"
source = "../../"
name = "memorystore"
project = "memorystore"
memory_size_gb = "1"
memory_size_gb = 1
}
3 changes: 1 addition & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ output "id" {
}

output "host" {
description = "The IP address of the instance."
description = "The memorystore instance ID."
value = google_redis_instance.default.host
}

Expand All @@ -33,4 +33,3 @@ output "current_location_id" {
description = "The current zone where the Redis endpoint is placed."
value = google_redis_instance.default.current_location_id
}

Loading

0 comments on commit 55bc3c3

Please sign in to comment.