Skip to content

Commit b77ae29

Browse files
authored
ci configuration (#812)
1 parent 79eab64 commit b77ae29

6 files changed

+123
-2
lines changed

.ci/cloudbuild-tests-go-licenses.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# See cloud-foundation-cicd project
16+
17+
timeout: 1800s
18+
steps:
19+
- id: test-go-licenses
20+
name: "gcr.io/cloud-builders/go:1.18"
21+
entrypoint: /usr/bin/make
22+
args: ["test-go-licenses"]
23+
tags:
24+
- "ci"
25+
options:
26+
machineType: "N1_HIGHCPU_8"

.ci/cloudbuild-tests-integration.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# See cloud-foundation-cicd project
16+
17+
timeout: 3600s
18+
steps:
19+
- id: test-integration
20+
name: "gcr.io/graphite-docker-images/terraform-validator-builder"
21+
entrypoint: /bin/sh
22+
args:
23+
[
24+
"-c",
25+
"mv /terraform/$_TERRAFORM_VERSION /bin/terraform && /usr/bin/make test-integration",
26+
]
27+
env:
28+
- TEST_PROJECT=$_TEST_PROJECT
29+
- TEST_FOLDER_ID=$_TEST_FOLDER
30+
- TEST_ANCESTRY=$_TEST_ANCESTRY
31+
- TEST_ORG_ID=$_TEST_ORG
32+
- TERRAFORM_VERSION=$_TERRAFORM_VERSION
33+
tags:
34+
- "ci"
35+
- "integration"
36+
options:
37+
machineType: "N1_HIGHCPU_8"

.ci/cloudbuild-tests-unit.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# See cloud-foundation-cicd project
16+
17+
timeout: 1800s
18+
steps:
19+
- id: test
20+
name: "gcr.io/cloud-builders/go:1.18"
21+
entrypoint: /usr/bin/make
22+
args: ["test"]
23+
tags:
24+
- "ci"
25+
options:
26+
machineType: "N1_HIGHCPU_8"

Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM golang:1.18
2+
RUN apt-get update && apt-get -y install wget unzip
3+
4+
ENV TERRAFORM_VERSION 0.12.31
5+
ADD install-terraform.sh /install-terraform.sh
6+
RUN ["chmod", "+x", "/install-terraform.sh"]
7+
ENTRYPOINT /install-terraform.sh
8+
9+
ENV GO111MODULE=on
10+
WORKDIR /terraform-google-conversion
11+
COPY . .

Makefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
TERRAFORM_VERSION=0.12.31
2+
13
test:
24
GO111MODULE=on go test -short ./...
35

@@ -10,7 +12,10 @@ test-go-licenses:
1012
cd .. && go version && go install github.com/google/go-licenses@latest
1113
$$(go env GOPATH)/bin/go-licenses check ./...
1214

15+
build-docker:
16+
docker build --build-arg TERRAFORM_VERSION=$(TERRAFORM_VERSION) -f ./Dockerfile -t terraform-google-conversion .
17+
1318
run-docker:
14-
docker run -it -v `pwd`:/terraform-validator -v ${GOOGLE_APPLICATION_CREDENTIALS}:/terraform-validator/credentials.json --entrypoint=/bin/bash --env TEST_PROJECT=${PROJECT_ID} --env TEST_CREDENTIALS=./credentials.json terraform-validator;
19+
docker run -it -v `pwd`:/terraform-google-conversion -v ${GOOGLE_APPLICATION_CREDENTIALS}:/terraform-google-conversion/credentials.json --entrypoint=/bin/bash --env TEST_PROJECT=${PROJECT_ID} --env GOOGLE_APPLICATION_CREDENTIALS=/terraform-google-conversion/credentials.json terraform-google-conversion;
1520

16-
.PHONY: test test-integration test-go-licenses
21+
.PHONY: test test-integration test-go-licenses build-docker run-docker

install-terraform.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
TERRAFORM_BINARY=/terraform/$TERRAFORM_VERSION
5+
if ! test -f "$TERRAFORM_BINARY"; then
6+
echo "Download terraform binary"
7+
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
8+
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip && rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip
9+
mkdir /terraform
10+
mv terraform /terraform/${TERRAFORM_VERSION}
11+
fi
12+
echo setting terraform to version ${TERRAFORM_VERSION}
13+
set x-
14+
mv /terraform/${TERRAFORM_VERSION} /bin/terraform
15+
set x+
16+
terraform version

0 commit comments

Comments
 (0)