-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
123 lines (109 loc) · 4.42 KB
/
cloudbuild.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# 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
#
# 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: 21600s
options:
machineType: "N1_HIGHCPU_32"
steps:
# Step: print the bazel version for record
- name: "l.gcr.io/google/bazel"
args: ["version"]
id: "version"
waitFor: ["-"] # wait for nothing - start immediately
# Step: pull the image used to validate YAML configs
- name: "l.gcr.io/google/bazel"
entrypoint: "docker"
args: ["pull", "gcr.io/asci-toolchain/container_release_tools/dependency_update/validators/semantics:latest"]
id: "pull_validator"
waitFor: ["-"] # wait for nothing - start immediately
# Step: copy the bazel project into a separate dir to run repro tests in parallel.
- name: "l.gcr.io/google/bazel"
entrypoint: "sh"
args: ["-c", "cp -a debian11 /repro_test/debian11"]
volumes:
- name: "repro_vol"
path: "/repro_test"
id: "copy-to-reproduce"
waitFor: ["-"] # wait for nothing - start immediately
# Step: build the image
- name: "l.gcr.io/google/bazel"
# Set Bazel output_base to /workspace, which is a mounted directory on Google Cloud Builder.
# This is to make sure Bazel generated files can be accessed by multiple containers.
args: ["--output_base=/workspace/output_base", "run", "//:image"]
# This is needed for GCB to correctly build/test targets in the Bazel project.
dir: "debian11"
id: "container-build"
waitFor: ["version"]
# Step: run structure tests on the new image
# We use container_test rule, which is a Bazel wrapper of container_structure_test.
# https://github.com/bazelbuild/rules_docker/blob/master/contrib/test.bzl
- name: "l.gcr.io/google/bazel"
args: ["--output_base=/workspace/output_base", "test",
"--test_output=errors",
"//:image-test",
"//:configs_test"]
# This is needed for GCB to correctly build/test targets in the Bazel project.
dir: "debian11"
id: "structure-test"
waitFor: ["container-build", "pull_validator"]
# Step: run reproduction test on the new image
- name: "l.gcr.io/google/bazel"
args: ["--output_base=/repro_test/output_base", "test", "//:img_repro_test", "--test_output=errors"]
dir: "/repro_test/debian11"
volumes:
- name: "repro_vol"
path: "/repro_test"
id: "repro-test"
waitFor: ["version", "copy-to-reproduce"]
# Step: tag the image, first as the backup image.
- name: "l.gcr.io/google/bazel"
entrypoint: "docker"
args: ["tag", "bazel:image", "gcr.io/${_IMG_BACKUP_DEST}"]
id: "backup-container-tag"
waitFor: ["structure-test", "repro-test"]
# Step: tag the image again with the final locations.
- name: "l.gcr.io/google/bazel"
entrypoint: "docker"
args: ["tag", "bazel:image", "gcr.io/${_IMG_DEST}"]
id: "container-tag1"
waitFor: ["backup-container-tag"]
- name: "l.gcr.io/google/bazel"
entrypoint: "docker"
args: ["tag", "bazel:image", "us.gcr.io/${_IMG_DEST}"]
id: "container-tag2"
waitFor: ["container-tag1"]
- name: "l.gcr.io/google/bazel"
entrypoint: "docker"
args: ["tag", "bazel:image", "eu.gcr.io/${_IMG_DEST}"]
id: "container-tag3"
waitFor: ["container-tag2"]
- name: "l.gcr.io/google/bazel"
entrypoint: "docker"
args: ["tag", "bazel:image", "asia.gcr.io/${_IMG_DEST}"]
id: "container-tag4"
waitFor: ["container-tag3"]
substitutions:
# Default values for substitution variables.
# These variables are altered in the cloudbuild trigger definition
_IMG_DEST: google-appengine/debian11:latest
_IMG_BACKUP_DEST: asci-toolchain-backup/debian11:latest
# Push the new image and its backup.
# Push by using the `images` field here so they will show up in the build results
# or the GCB Build information page.
# https://cloud.google.com/cloud-build/docs/configuring-builds/store-images-artifacts
images:
- "gcr.io/${_IMG_DEST}"
- "us.gcr.io/${_IMG_DEST}"
- "eu.gcr.io/${_IMG_DEST}"
- "asia.gcr.io/${_IMG_DEST}"
- "gcr.io/${_IMG_BACKUP_DEST}"