build/cloudbuild/build-cloudbuild.yaml (24 lines of code) (raw):
# 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.
# Description: This cloud build is for merging into master and will publish an image
steps:
- name: 'golang'
id: 'Format golang files'
args: ['go', 'fmt', './...']
# We need to set the CLOUDBUILD env var as a signal to skip tests that are
# not passing in Cloud Build yet. See issue #24.
- name: 'golang'
id: 'Run unit tests'
env: ['GO111MODULE=on', 'CLOUDBUILD=on']
args: ['go', 'test', '-v', '-cover', './...']
- name: 'gcr.io/cloud-builders/docker'
id: 'Build proto-builder'
args: ['build', '-t', 'gcv-proto-builder', '-f', './build/proto/Dockerfile', '.']
- name: 'gcr.io/cloud-builders/docker'
id: 'Create proto files'
args: ['run', '-v', '/workspace:/go/src/github.com/GoogleCloudPlatform/config-validator', 'gcv-proto-builder', 'protoc', '-I/proto', '-I./api', '--go_out=plugins=grpc:./pkg/api/validator', './api/validator.proto']
- name: 'gcr.io/cloud-builders/docker'
id: Build config validator container latest
args: ['build', '-t', 'gcr.io/$PROJECT_ID/config-validator:latest', '.']
- name: 'gcr.io/cloud-builders/docker'
id: Build config validator container with short SHA
args: ['build', '-t', 'gcr.io/$PROJECT_ID/config-validator:$SHORT_SHA', '.']
images:
- 'gcr.io/$PROJECT_ID/config-validator:latest'
- 'gcr.io/$PROJECT_ID/config-validator:$SHORT_SHA'
timeout: 3600s