|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
| 15 | +# Please note that this file was generated from [terraform-google-module-template](https://github.com/terraform-google-modules/terraform-google-module-template). |
| 16 | +# Please make sure to contribute relevant changes upstream! |
| 17 | + |
15 | 18 | # Make will use bash instead of sh
|
16 | 19 | SHELL := /usr/bin/env bash
|
17 | 20 |
|
18 |
| -# Docker build config variables |
19 |
| -CREDENTIALS_PATH ?= /cft/workdir/credentials.json |
20 |
| -DOCKER_ORG := gcr.io/cloud-foundation-cicd |
21 |
| -DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.3.0 |
22 |
| -DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM} |
23 |
| - |
24 |
| -# All is the first target in the file so it will get picked up when you just run 'make' on its own |
25 |
| -all: check generate_docs |
26 |
| - |
27 |
| -.PHONY: check |
28 |
| -check: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace |
29 |
| - |
30 |
| - |
31 |
| -# The .PHONY directive tells make that this isn't a real target and so |
32 |
| -# the presence of a file named 'check_shell' won't cause this target to stop |
33 |
| -# working |
34 |
| -.PHONY: check_shell |
35 |
| -check_shell: |
36 |
| - @source test/make.sh && check_shell |
37 |
| - |
38 |
| -.PHONY: check_python |
39 |
| -check_python: |
40 |
| - @source test/make.sh && check_python |
41 |
| - |
42 |
| -.PHONY: check_golang |
43 |
| -check_golang: |
44 |
| - @source test/make.sh && golang |
45 |
| - |
46 |
| -.PHONY: check_terraform |
47 |
| -check_terraform: |
48 |
| - @source test/make.sh && check_terraform |
49 |
| - |
50 |
| -.PHONY: check_docker |
51 |
| -check_docker: |
52 |
| - @source test/make.sh && docker |
53 |
| - |
54 |
| -.PHONY: check_base_files |
55 |
| -check_base_files: |
56 |
| - @source test/make.sh && basefiles |
57 |
| - |
58 |
| -.PHONY: check_trailing_whitespace |
59 |
| -check_trailing_whitespace: |
60 |
| - @source test/make.sh && check_trailing_whitespace |
61 |
| - |
62 |
| -.PHONY: test_check_headers |
63 |
| -test_check_headers: |
64 |
| - @echo "Testing the validity of the header check" |
65 |
| - @python test/test_verify_boilerplate.py |
| 21 | +DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.1.0 |
| 22 | +DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools |
| 23 | +REGISTRY_URL := gcr.io/cloud-foundation-cicd |
66 | 24 |
|
67 |
| -.PHONY: check_headers |
68 |
| -check_headers: |
69 |
| - @source test/make.sh && check_headers |
70 |
| - |
71 |
| -# Integration tests |
72 |
| -.PHONY: test_integration |
73 |
| -test_integration: |
74 |
| - ./test/ci_integration.sh |
75 |
| - |
76 |
| -.PHONY: generate_docs |
77 |
| -generate_docs: |
78 |
| - @source test/make.sh && generate_docs |
79 |
| - |
80 |
| -# Versioning |
81 |
| -.PHONY: version |
82 |
| -version: |
83 |
| - @source helpers/version-repo.sh |
84 |
| - |
85 |
| -# Run docker |
| 25 | +# Enter docker container for local development |
86 | 26 | .PHONY: docker_run
|
87 | 27 | docker_run:
|
88 | 28 | docker run --rm -it \
|
89 |
| - -e PROJECT_ID \ |
90 | 29 | -e SERVICE_ACCOUNT_JSON \
|
91 |
| - -e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \ |
92 |
| - -v $(CURDIR):/cft/workdir \ |
93 |
| - ${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \ |
94 |
| - /bin/bash -c "source test/ci_integration.sh && setup_environment && exec /bin/bash" |
| 30 | + -v $(CURDIR):/workspace \ |
| 31 | + $(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \ |
| 32 | + /bin/bash |
95 | 33 |
|
96 |
| -.PHONY: docker_create |
97 |
| -docker_create: |
| 34 | +# Execute prepare tests within the docker container |
| 35 | +.PHONY: docker_test_prepare |
| 36 | +docker_test_prepare: |
98 | 37 | docker run --rm -it \
|
99 |
| - -e PROJECT_ID \ |
100 | 38 | -e SERVICE_ACCOUNT_JSON \
|
101 |
| - -e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \ |
102 |
| - -v $(CURDIR):/cft/workdir \ |
103 |
| - ${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \ |
104 |
| - /bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen create" |
105 |
| - |
106 |
| -.PHONY: docker_converge |
107 |
| -docker_converge: |
| 39 | + -e TF_VAR_org_id \ |
| 40 | + -e TF_VAR_folder_id \ |
| 41 | + -e TF_VAR_billing_account \ |
| 42 | + -v $(CURDIR):/workspace \ |
| 43 | + $(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \ |
| 44 | + /usr/local/bin/execute_with_credentials.sh prepare_environment |
| 45 | + |
| 46 | +# Clean up test environment within the docker container |
| 47 | +.PHONY: docker_test_cleanup |
| 48 | +docker_test_cleanup: |
108 | 49 | docker run --rm -it \
|
109 |
| - -e PROJECT_ID \ |
110 | 50 | -e SERVICE_ACCOUNT_JSON \
|
111 |
| - -e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \ |
112 |
| - -v $(CURDIR):/cft/workdir \ |
113 |
| - ${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \ |
114 |
| - /bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen converge" |
115 |
| - |
116 |
| -.PHONY: docker_verify |
117 |
| -docker_verify: |
| 51 | + -e TF_VAR_org_id \ |
| 52 | + -e TF_VAR_folder_id \ |
| 53 | + -e TF_VAR_billing_account \ |
| 54 | + -v $(CURDIR):/workspace \ |
| 55 | + $(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \ |
| 56 | + /usr/local/bin/execute_with_credentials.sh cleanup_environment |
| 57 | + |
| 58 | +# Execute integration tests within the docker container |
| 59 | +.PHONY: docker_test_integration |
| 60 | +docker_test_integration: |
118 | 61 | docker run --rm -it \
|
119 |
| - -e PROJECT_ID \ |
120 | 62 | -e SERVICE_ACCOUNT_JSON \
|
121 |
| - -e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \ |
122 |
| - -v $(CURDIR):/cft/workdir \ |
123 |
| - ${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \ |
124 |
| - /bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen verify" |
| 63 | + -v $(CURDIR):/workspace \ |
| 64 | + $(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \ |
| 65 | + /usr/local/bin/test_integration.sh |
125 | 66 |
|
126 |
| -.PHONY: docker_destroy |
127 |
| -docker_destroy: |
| 67 | +# Execute lint tests within the docker container |
| 68 | +.PHONY: docker_test_lint |
| 69 | +docker_test_lint: |
128 | 70 | docker run --rm -it \
|
129 |
| - -e PROJECT_ID \ |
130 |
| - -e SERVICE_ACCOUNT_JSON \ |
131 |
| - -e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \ |
132 |
| - -v $(CURDIR):/cft/workdir \ |
133 |
| - ${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \ |
134 |
| - /bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen destroy" |
| 71 | + -v $(CURDIR):/workspace \ |
| 72 | + $(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \ |
| 73 | + /usr/local/bin/test_lint.sh |
135 | 74 |
|
136 |
| -.PHONY: test_integration_docker |
137 |
| -test_integration_docker: |
| 75 | +# Generate documentation |
| 76 | +.PHONY: docker_generate_docs |
| 77 | +docker_generate_docs: |
138 | 78 | docker run --rm -it \
|
139 |
| - -e PROJECT_ID \ |
140 |
| - -e SERVICE_ACCOUNT_JSON \ |
141 |
| - -e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \ |
142 |
| - -v $(CURDIR):/cft/workdir \ |
143 |
| - ${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \ |
144 |
| - make test_integration |
| 79 | + -v $(CURDIR):/workspace \ |
| 80 | + $(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \ |
| 81 | + /bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs' |
| 82 | + |
| 83 | +# Alias for backwards compatibility |
| 84 | +.PHONY: generate_docs |
| 85 | +generate_docs: docker_generate_docs |
0 commit comments