# 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: 20m
steps:
# Update the GitHub status.
- name: gcr.io/cloudbuild-report/report
  env:
  - REPORT_ID=$BUILD_ID
  - REPORT_PROJECT=$PROJECT_ID
  - REPORT_ORG=GoogleCloudPlatform
  - REPORT_REPO=golang-samples

# Get the credentials for integration tests.
- name: gcr.io/cloud-builders/gsutil
  args: ['cp', 'gs://golang-samples-secrets/golang-samples-tests-4fbf85dd0f24.json', 'key.json']

# Run the tests
- name: gcr.io/$PROJECT_ID/go19
  args: ['bash', 'testing/cloudbuild/run.bash']

# Clean up the workdir.
- name: debian
  args: ['bash', '-c',
    'rm -rf
    gopath/src/github.com/GoogleCloudPlatform/golang-samples
    gopath/pkg/**/github.com/GoogleCloudPlatform/golang-samples'
  ]

# Build the image with newly downloaded deps.
- name: gcr.io/cloudbuild-report/cacher
  env:
  - TAG=gcr.io/$PROJECT_ID/go19
  - BASE=golang:1.7

images: ['gcr.io/$PROJECT_ID/go19']
