Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #79 from kopachevsky/feature/30/ci
Browse files Browse the repository at this point in the history
Implement integration testing for Terraform Validator
  • Loading branch information
morgante authored Oct 25, 2019
2 parents 1206372 + d6248aa commit 1fe01ae
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
36 changes: 36 additions & 0 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

timeout: 3600s
steps:
- id: test
name: 'gcr.io/cloud-builders/go'
entrypoint: /usr/bin/make
args: [test]
- id: build
name: 'gcr.io/cloud-builders/go'
entrypoint: /usr/bin/make
args: [build]
- id: test-integration
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'make test-integration']
env:
- 'TEST_PROJECT=$_TEST_PROJECT'
tags:
- 'ci'
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.1.0'

2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source.sh
credentials.json
1 change: 1 addition & 0 deletions test/tf_generated/0.12/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.tfplan
*.tf
*.tfplan.json
16 changes: 8 additions & 8 deletions test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ func configure(t *testing.T) config {
}

cfg.credentials, ok = os.LookupEnv("TEST_CREDENTIALS")
if !ok {
t.Fatal("missing required env var TEST_CREDENTIALS")
}
// Make credentials path relative to repo root rather than
// test/ dir if it is a relative path.
if !filepath.IsAbs(cfg.credentials) {
cfg.credentials = filepath.Join("..", cfg.credentials)
if ok {
// Make credentials path relative to repo root rather than
// test/ dir if it is a relative path.
if !filepath.IsAbs(cfg.credentials) {
cfg.credentials = filepath.Join("..", cfg.credentials)
}
} else {
t.Log("missing env var TEST_CREDENTIALS, will try to use Application Default Credentials")
}

return cfg
}

Expand Down

0 comments on commit 1fe01ae

Please sign in to comment.