blob: e65991dd296c53a5f09d00aaf1e59ce461401ee1 [file] [log] [blame]
# Copyright 2018 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
#
# http://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.
options:
machineType: 'N1_HIGHCPU_8'
substitutionOption: 'MUST_MATCH'
requestedVerifyOption: VERIFIED
substitutions:
_BUILD_TOOLS_CACHE: 'https://storage.googleapis.com/cos-infra-prod_cloudbuild/cos-tools-cache'
_IMAGE_NAME: cos-customizer
_IMAGE_FOLDER_NAME: cos_customizer
_RUN_PATH: .
steps:
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- '-c'
- |
cat <<EOF | docker build -t bazel -
FROM gcr.io/cloud-builders/bazel
RUN apt-get update && apt-get install -y mtools dosfstools
EOF
- name: 'bazel'
args: ['test', '--remote_cache=${_BUILD_TOOLS_CACHE}', '--google_default_credentials', '--spawn_strategy=standalone','--','...','-//src/pkg/tools/...']
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- '-c'
- |
TAGS=""
if [ "$_BUILD_TYPE" == "presubmit" ]; then
# For presubmit build, we push presubmit-{BUILD_ID} tag.
TAGS="${_BUILD_TYPE}-${_TAG_NAME}"
elif [ "$_BUILD_TYPE" == "official" ]; then
# For official build, we push presubmit-{BUILD_ID} and latest tag.
TAGS="${_BUILD_TYPE}-${_TAG_NAME} latest"
else
echo "Invalid BUILD_TYPE: $_BUILD_TYPE"
exit 1
fi
# Build and tag for gcr-io-dev. BUILD_ID tag is pushed by default.
docker build -f 'src/cmd/${_IMAGE_FOLDER_NAME}/Dockerfile' -t "us-docker.pkg.dev/${_OUTPUT_PROJECT}/gcr-io-dev/${_IMAGE_NAME}:${_TAG_NAME}" "${_RUN_PATH}"
for TAG in $$TAGS; do
docker tag "us-docker.pkg.dev/${_OUTPUT_PROJECT}/gcr-io-dev/${_IMAGE_NAME}:${_TAG_NAME}" "us-docker.pkg.dev/${_OUTPUT_PROJECT}/gcr-io-dev/${_IMAGE_NAME}:$$TAG"
docker push "us-docker.pkg.dev/${_OUTPUT_PROJECT}/gcr-io-dev/${_IMAGE_NAME}:$$TAG"
done
images:
- 'us-docker.pkg.dev/${_OUTPUT_PROJECT}/gcr-io-dev/${_IMAGE_NAME}:${_TAG_NAME}'
# 25 minute timeout; concurrent arm64/amd64 builds take time
timeout: '1500s'