blob: 0c094d2a1f3bd5a26d590c661636df71a45c94d6 [file] [log] [blame]
borenetdb182c72016-09-30 12:53:12 -07001// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package main
6
7/*
8 Generate the tasks.json file.
9*/
10
11import (
borenetdb182c72016-09-30 12:53:12 -070012 "encoding/json"
Eric Boren27225492017-02-01 15:56:55 -050013 "flag"
borenetdb182c72016-09-30 12:53:12 -070014 "fmt"
Eric Boren27225492017-02-01 15:56:55 -050015 "io/ioutil"
borenetdb182c72016-09-30 12:53:12 -070016 "os"
17 "path"
Eric Boren7e3a3642017-06-14 15:25:31 -040018 "path/filepath"
Eric Boren27225492017-02-01 15:56:55 -050019 "regexp"
Eric Boren7e3a3642017-06-14 15:25:31 -040020 "runtime"
borenetdb182c72016-09-30 12:53:12 -070021 "sort"
Kevin Lubick32f318b2017-10-17 13:40:52 -040022 "strconv"
borenetdb182c72016-09-30 12:53:12 -070023 "strings"
Eric Boren4b254b92016-11-08 12:55:32 -050024 "time"
borenetdb182c72016-09-30 12:53:12 -070025
Eric Borencb0b98b2018-06-08 08:25:57 -040026 "github.com/golang/glog"
Eric Boren7e3a3642017-06-14 15:25:31 -040027 "go.skia.org/infra/go/sklog"
borenetdb182c72016-09-30 12:53:12 -070028 "go.skia.org/infra/go/util"
29 "go.skia.org/infra/task_scheduler/go/specs"
30)
31
32const (
Kevin Lubick814b1492017-11-29 14:45:14 -050033 BUNDLE_RECIPES_NAME = "Housekeeper-PerCommit-BundleRecipes"
Stephan Altmueller88df8d22018-03-07 14:44:44 -050034 ISOLATE_GCLOUD_LINUX_NAME = "Housekeeper-PerCommit-IsolateGCloudLinux"
35 ISOLATE_GO_LINUX_NAME = "Housekeeper-PerCommit-IsolateGoLinux"
Kevin Lubick814b1492017-11-29 14:45:14 -050036 ISOLATE_SKIMAGE_NAME = "Housekeeper-PerCommit-IsolateSkImage"
37 ISOLATE_SKP_NAME = "Housekeeper-PerCommit-IsolateSKP"
38 ISOLATE_SVG_NAME = "Housekeeper-PerCommit-IsolateSVG"
39 ISOLATE_NDK_LINUX_NAME = "Housekeeper-PerCommit-IsolateAndroidNDKLinux"
Stephan Altmueller2a552172018-02-20 11:40:25 -050040 ISOLATE_SDK_LINUX_NAME = "Housekeeper-PerCommit-IsolateAndroidSDKLinux"
Kevin Lubick814b1492017-11-29 14:45:14 -050041 ISOLATE_WIN_TOOLCHAIN_NAME = "Housekeeper-PerCommit-IsolateWinToolchain"
42 ISOLATE_WIN_VULKAN_SDK_NAME = "Housekeeper-PerCommit-IsolateWinVulkanSDK"
Eric Boren8b3f9e62017-04-04 09:06:16 -040043
Ben Wagner1676ec22018-04-06 17:39:06 -040044 DEFAULT_OS_DEBIAN = "Debian-9.4"
45 DEFAULT_OS_LINUX_GCE = DEFAULT_OS_DEBIAN
Ben Wagner5a9df182018-02-09 11:21:15 -050046 DEFAULT_OS_MAC = "Mac-10.13.3"
Eric Boren170c39c2017-11-15 11:22:57 -050047 DEFAULT_OS_UBUNTU = "Ubuntu-14.04"
48 DEFAULT_OS_WIN = "Windows-2016Server-14393"
borenetdb182c72016-09-30 12:53:12 -070049
Eric Boreneb702382018-04-19 09:36:45 -040050 DEFAULT_PROJECT = "skia"
51
Ben Wagner297e86b2018-05-14 12:38:09 -040052 // Small is a 2-core machine.
53 // TODO(dogben): Would n1-standard-1 or n1-standard-2 be sufficient?
Ben Wagnere99a4b12018-05-04 11:18:01 -040054 MACHINE_TYPE_SMALL = "n1-highmem-2"
Ben Wagner297e86b2018-05-14 12:38:09 -040055 // Medium is a 16-core machine
56 MACHINE_TYPE_MEDIUM = "n1-standard-16"
57 // Large is a 64-core machine. (We use "highcpu" because we don't need more than 57GB memory for
58 // any of our tasks.)
Ben Wagnere99a4b12018-05-04 11:18:01 -040059 MACHINE_TYPE_LARGE = "n1-highcpu-64"
60
Eric Boren9599b0f2018-04-17 15:55:57 -040061 // Swarming output dirs.
62 OUTPUT_NONE = "output_ignored" // This will result in outputs not being isolated.
63 OUTPUT_BUILD = "build"
64 OUTPUT_COVERAGE = "coverage"
65 OUTPUT_TEST = "test"
66 OUTPUT_PERF = "perf"
67
borenetdb182c72016-09-30 12:53:12 -070068 // Name prefix for upload jobs.
69 PREFIX_UPLOAD = "Upload"
Eric Boren9599b0f2018-04-17 15:55:57 -040070
71 SERVICE_ACCOUNT_BOOKMAKER = "skia-bookmaker@skia-swarming-bots.iam.gserviceaccount.com"
72 SERVICE_ACCOUNT_COMPILE = "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
73 SERVICE_ACCOUNT_CT_SKPS = "skia-external-ct-skps@skia-swarming-bots.iam.gserviceaccount.com"
74 SERVICE_ACCOUNT_HOUSEKEEPER = "skia-external-housekeeper@skia-swarming-bots.iam.gserviceaccount.com"
75 SERVICE_ACCOUNT_RECREATE_SKPS = "skia-recreate-skps@skia-swarming-bots.iam.gserviceaccount.com"
76 SERVICE_ACCOUNT_UPDATE_META_CONFIG = "skia-update-meta-config@skia-swarming-bots.iam.gserviceaccount.com"
77 SERVICE_ACCOUNT_UPLOAD_BINARY = "skia-external-binary-uploader@skia-swarming-bots.iam.gserviceaccount.com"
78 SERVICE_ACCOUNT_UPLOAD_CALMBENCH = "skia-external-calmbench-upload@skia-swarming-bots.iam.gserviceaccount.com"
79 SERVICE_ACCOUNT_UPLOAD_COVERAGE = "skia-external-coverage-uploade@skia-swarming-bots.iam.gserviceaccount.com"
80 SERVICE_ACCOUNT_UPLOAD_GM = "skia-external-gm-uploader@skia-swarming-bots.iam.gserviceaccount.com"
81 SERVICE_ACCOUNT_UPLOAD_NANO = "skia-external-nano-uploader@skia-swarming-bots.iam.gserviceaccount.com"
borenetdb182c72016-09-30 12:53:12 -070082)
83
84var (
85 // "Constants"
86
Eric Boren27225492017-02-01 15:56:55 -050087 // Top-level list of all jobs to run at each commit; loaded from
88 // jobs.json.
89 JOBS []string
90
Eric Boren27225492017-02-01 15:56:55 -050091 // General configuration information.
92 CONFIG struct {
Kevin Lubickc795a4c2017-10-09 15:26:19 -040093 GsBucketCoverage string `json:"gs_bucket_coverage"`
94 GsBucketGm string `json:"gs_bucket_gm"`
Stephan Altmüller64cc5762018-08-02 08:51:38 +020095 GoldHashesURL string `json:"gold_hashes_url"`
Kevin Lubickc795a4c2017-10-09 15:26:19 -040096 GsBucketNano string `json:"gs_bucket_nano"`
Yuqian Li2ebf3d12017-10-24 09:43:21 -040097 GsBucketCalm string `json:"gs_bucket_calm"`
Kevin Lubickc795a4c2017-10-09 15:26:19 -040098 NoUpload []string `json:"no_upload"`
99 Pool string `json:"pool"`
borenetdb182c72016-09-30 12:53:12 -0700100 }
101
Eric Boreneb702382018-04-19 09:36:45 -0400102 // alternateProject can be set in an init function to override the default project ID.
103 alternateProject string
104
Ben Wagner053d0462018-04-17 12:45:29 -0400105 // alternateServiceAccount can be set in an init function to override the normal service accounts.
106 // Takes one of SERVICE_ACCOUNT_* constants as an argument and returns the service account that
107 // should be used, or uses sklog.Fatal to indicate a problem.
108 alternateServiceAccount func(serviceAccountEnum string) string
109
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400110 // alternateSwarmDimensions can be set in an init function to override the default swarming bot
111 // dimensions for the given task.
112 alternateSwarmDimensions func(parts map[string]string) []string
113
Eric Borenfd4d60e2017-09-15 10:35:44 -0400114 // internalHardwareLabelFn can be set in an init function to provide an
115 // internal_hardware_label variable to the recipe.
Eric Boren4dc4aaf2017-09-15 14:09:07 -0400116 internalHardwareLabelFn func(parts map[string]string) *int
Eric Boren053d7a42017-09-15 08:35:31 -0400117
borenetdb182c72016-09-30 12:53:12 -0700118 // Defines the structure of job names.
119 jobNameSchema *JobNameSchema
Eric Boren27225492017-02-01 15:56:55 -0500120
Eric Boren5cb5c742018-04-27 13:14:38 -0400121 // Named caches used by tasks.
122 CACHES_GIT = []*specs.Cache{
123 &specs.Cache{
124 Name: "git",
125 Path: "cache/git",
126 },
127 &specs.Cache{
128 Name: "git_cache",
129 Path: "cache/git_cache",
130 },
131 }
132 CACHES_WORKDIR = []*specs.Cache{
133 &specs.Cache{
134 Name: "work",
135 Path: "cache/work",
136 },
137 }
Kevin Lubick30cc00c2018-08-03 10:26:00 -0400138 CACHES_DOCKER = []*specs.Cache{
139 &specs.Cache{
140 Name: "docker",
141 Path: "cache/docker",
142 },
143 }
Ben Wagner702fe012018-06-15 09:19:13 -0400144 // Versions of the following copied from
145 // https://chrome-internal.googlesource.com/infradata/config/+/master/configs/cr-buildbucket/swarming_task_template_canary.json#42
146 // to test the fix for chromium:836196.
147 // (In the future we may want to use versions from
148 // https://chrome-internal.googlesource.com/infradata/config/+/master/configs/cr-buildbucket/swarming_task_template.json#42)
Eric Boren9599b0f2018-04-17 15:55:57 -0400149 // TODO(borenet): Roll these versions automatically!
150 CIPD_PKGS_PYTHON = []*specs.CipdPackage{
151 &specs.CipdPackage{
152 Name: "infra/tools/luci/vpython/${platform}",
153 Path: "cipd_bin_packages",
Eric Borenb33f9eb2018-08-03 10:31:24 -0400154 Version: "git_revision:b6cdec8586c9f8d3d728b1bc0bd4331330ba66fc",
Eric Boren9599b0f2018-04-17 15:55:57 -0400155 },
Eric Borenf4a5fc72017-06-06 08:27:09 -0400156 }
Eric Boren9599b0f2018-04-17 15:55:57 -0400157
Eric Borenaa037522018-06-18 16:02:15 -0400158 CIPD_PKGS_CPYTHON = []*specs.CipdPackage{
159 &specs.CipdPackage{
160 Name: "infra/python/cpython/${platform}",
161 Path: "cipd_bin_packages",
162 Version: "version:2.7.14.chromium14",
163 },
164 }
165
Eric Boren9599b0f2018-04-17 15:55:57 -0400166 CIPD_PKGS_KITCHEN = append([]*specs.CipdPackage{
167 &specs.CipdPackage{
168 Name: "infra/tools/luci/kitchen/${platform}",
169 Path: ".",
Ben Wagner702fe012018-06-15 09:19:13 -0400170 Version: "git_revision:546aae39f1fb9dce9add528e2011afa574535ecd",
Eric Boren9599b0f2018-04-17 15:55:57 -0400171 },
172 &specs.CipdPackage{
Ben Wagnercd7ace22018-06-11 15:48:35 -0400173 Name: "infra/tools/luci-auth/${platform}",
Eric Boren9599b0f2018-04-17 15:55:57 -0400174 Path: "cipd_bin_packages",
Ben Wagnercd7ace22018-06-11 15:48:35 -0400175 Version: "git_revision:e1abc57be62d198b5c2f487bfb2fa2d2eb0e867c",
Eric Boren9599b0f2018-04-17 15:55:57 -0400176 },
177 }, CIPD_PKGS_PYTHON...)
178
179 CIPD_PKGS_GIT = []*specs.CipdPackage{
180 &specs.CipdPackage{
181 Name: "infra/git/${platform}",
182 Path: "cipd_bin_packages",
Eric Borene42cef52018-06-20 07:11:38 -0400183 Version: "version:2.17.1.chromium15",
Eric Boren9599b0f2018-04-17 15:55:57 -0400184 },
185 &specs.CipdPackage{
186 Name: "infra/tools/git/${platform}",
187 Path: "cipd_bin_packages",
Eric Boren3f13bcb2018-06-15 07:39:36 -0400188 Version: "git_revision:0ae21738597e5601ba90372315145fec18582fc4",
Eric Boren9599b0f2018-04-17 15:55:57 -0400189 },
190 &specs.CipdPackage{
191 Name: "infra/tools/luci/git-credential-luci/${platform}",
192 Path: "cipd_bin_packages",
Ben Wagnercd7ace22018-06-11 15:48:35 -0400193 Version: "git_revision:e1abc57be62d198b5c2f487bfb2fa2d2eb0e867c",
Eric Boren9599b0f2018-04-17 15:55:57 -0400194 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000195 }
Eric Borenf4a5fc72017-06-06 08:27:09 -0400196
Eric Boren9599b0f2018-04-17 15:55:57 -0400197 CIPD_PKGS_GSUTIL = []*specs.CipdPackage{
198 &specs.CipdPackage{
199 Name: "infra/gsutil",
200 Path: "cipd_bin_packages",
201 Version: "version:4.28",
202 },
203 }
204
Eric Boren27225492017-02-01 15:56:55 -0500205 // Flags.
Eric Boren1f8be682017-02-07 09:16:30 -0500206 builderNameSchemaFile = flag.String("builder_name_schema", "", "Path to the builder_name_schema.json file. If not specified, uses infra/bots/recipe_modules/builder_name_schema/builder_name_schema.json from this repo.")
207 assetsDir = flag.String("assets_dir", "", "Directory containing assets.")
208 cfgFile = flag.String("cfg_file", "", "JSON file containing general configuration information.")
Eric Boren1f8be682017-02-07 09:16:30 -0500209 jobsFile = flag.String("jobs", "", "JSON file containing jobs to run.")
borenetdb182c72016-09-30 12:53:12 -0700210)
211
Eric Boreneb702382018-04-19 09:36:45 -0400212// Build the LogDog annotation URL.
213func logdogAnnotationUrl() string {
214 project := DEFAULT_PROJECT
215 if alternateProject != "" {
216 project = alternateProject
217 }
218 return fmt.Sprintf("logdog://logs.chromium.org/%s/%s/+/annotations", project, specs.PLACEHOLDER_TASK_ID)
219}
220
Eric Boren9599b0f2018-04-17 15:55:57 -0400221// Create a properties JSON string.
222func props(p map[string]string) string {
223 d := make(map[string]interface{}, len(p)+1)
224 for k, v := range p {
225 d[k] = interface{}(v)
226 }
227 d["$kitchen"] = struct {
228 DevShell bool `json:"devshell"`
229 GitAuth bool `json:"git_auth"`
230 }{
231 DevShell: true,
232 GitAuth: true,
233 }
234
235 j, err := json.Marshal(d)
236 if err != nil {
237 sklog.Fatal(err)
238 }
239 return strings.Replace(string(j), "\\u003c", "<", -1)
240}
241
242// kitchenTask returns a specs.TaskSpec instance which uses Kitchen to run a
243// recipe.
244func kitchenTask(name, recipe, isolate, serviceAccount string, dimensions []string, extraProps map[string]string, outputDir string) *specs.TaskSpec {
245 if serviceAccount != "" && alternateServiceAccount != nil {
246 serviceAccount = alternateServiceAccount(serviceAccount)
247 }
248 cipd := append([]*specs.CipdPackage{}, CIPD_PKGS_KITCHEN...)
Eric Borenaa037522018-06-18 16:02:15 -0400249 if strings.Contains(name, "Win") {
250 cipd = append(cipd, CIPD_PKGS_CPYTHON...)
251 }
Eric Boren9599b0f2018-04-17 15:55:57 -0400252 properties := map[string]string{
253 "buildbucket_build_id": specs.PLACEHOLDER_BUILDBUCKET_BUILD_ID,
254 "buildername": name,
255 "patch_issue": specs.PLACEHOLDER_ISSUE,
Eric Boren2f62de02018-05-03 09:56:48 -0400256 "patch_ref": specs.PLACEHOLDER_PATCH_REF,
Eric Boren9599b0f2018-04-17 15:55:57 -0400257 "patch_repo": specs.PLACEHOLDER_PATCH_REPO,
258 "patch_set": specs.PLACEHOLDER_PATCHSET,
259 "patch_storage": specs.PLACEHOLDER_PATCH_STORAGE,
260 "repository": specs.PLACEHOLDER_REPO,
261 "revision": specs.PLACEHOLDER_REVISION,
262 "swarm_out_dir": outputDir,
263 }
264 for k, v := range extraProps {
265 properties[k] = v
266 }
267 var outputs []string = nil
268 if outputDir != OUTPUT_NONE {
269 outputs = []string{outputDir}
270 }
Eric Boren5cb5c742018-04-27 13:14:38 -0400271 task := &specs.TaskSpec{
272 Caches: []*specs.Cache{
273 &specs.Cache{
274 Name: "vpython",
275 Path: "cache/vpython",
276 },
277 },
Eric Boren9599b0f2018-04-17 15:55:57 -0400278 CipdPackages: cipd,
279 Command: []string{
280 "./kitchen${EXECUTABLE_SUFFIX}", "cook",
281 "-checkout-dir", "recipe_bundle",
282 "-mode", "swarming",
283 "-luci-system-account", "system",
284 "-cache-dir", "cache",
285 "-temp-dir", "tmp",
286 "-known-gerrit-host", "android.googlesource.com",
287 "-known-gerrit-host", "boringssl.googlesource.com",
288 "-known-gerrit-host", "chromium.googlesource.com",
289 "-known-gerrit-host", "dart.googlesource.com",
290 "-known-gerrit-host", "fuchsia.googlesource.com",
291 "-known-gerrit-host", "go.googlesource.com",
292 "-known-gerrit-host", "llvm.googlesource.com",
Eric Boren9599b0f2018-04-17 15:55:57 -0400293 "-known-gerrit-host", "skia.googlesource.com",
294 "-known-gerrit-host", "webrtc.googlesource.com",
295 "-output-result-json", "${ISOLATED_OUTDIR}/build_result_filename",
296 "-workdir", ".",
297 "-recipe", recipe,
298 "-properties", props(properties),
Eric Boreneb702382018-04-19 09:36:45 -0400299 "-logdog-annotation-url", logdogAnnotationUrl(),
Eric Boren9599b0f2018-04-17 15:55:57 -0400300 },
301 Dependencies: []string{BUNDLE_RECIPES_NAME},
302 Dimensions: dimensions,
303 EnvPrefixes: map[string][]string{
304 "PATH": []string{"cipd_bin_packages", "cipd_bin_packages/bin"},
305 "VPYTHON_VIRTUALENV_ROOT": []string{"${cache_dir}/vpython"},
306 },
307 ExtraTags: map[string]string{
Eric Boreneb702382018-04-19 09:36:45 -0400308 "log_location": logdogAnnotationUrl(),
Eric Boren9599b0f2018-04-17 15:55:57 -0400309 },
310 Isolate: relpath(isolate),
311 Outputs: outputs,
Eric Boren9599b0f2018-04-17 15:55:57 -0400312 ServiceAccount: serviceAccount,
313 }
Eric Boren5cb5c742018-04-27 13:14:38 -0400314 timeout(task, time.Hour)
315 return task
Eric Boren9599b0f2018-04-17 15:55:57 -0400316}
317
Eric Borenfd4d60e2017-09-15 10:35:44 -0400318// internalHardwareLabel returns the internal ID for the bot, if any.
Eric Boren4dc4aaf2017-09-15 14:09:07 -0400319func internalHardwareLabel(parts map[string]string) *int {
Eric Borenfd4d60e2017-09-15 10:35:44 -0400320 if internalHardwareLabelFn != nil {
321 return internalHardwareLabelFn(parts)
Eric Boren053d7a42017-09-15 08:35:31 -0400322 }
323 return nil
324}
325
Eric Boren27225492017-02-01 15:56:55 -0500326// linuxGceDimensions are the Swarming dimensions for Linux GCE
327// instances.
Ben Wagnere99a4b12018-05-04 11:18:01 -0400328func linuxGceDimensions(machineType string) []string {
Eric Boren27225492017-02-01 15:56:55 -0500329 return []string{
Ben Wagner4c9842e2017-09-25 12:56:53 -0400330 // Specify CPU to avoid running builds on bots with a more unique CPU.
331 "cpu:x86-64-Haswell_GCE",
Eric Boren27225492017-02-01 15:56:55 -0500332 "gpu:none",
Ben Wagner82a33422018-04-26 18:02:23 -0400333 // Currently all Linux GCE tasks run on 16-CPU machines.
Ben Wagnere99a4b12018-05-04 11:18:01 -0400334 fmt.Sprintf("machine_type:%s", machineType),
Eric Boren170c39c2017-11-15 11:22:57 -0500335 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE),
Eric Boren27225492017-02-01 15:56:55 -0500336 fmt.Sprintf("pool:%s", CONFIG.Pool),
337 }
338}
339
borenetdb182c72016-09-30 12:53:12 -0700340// deriveCompileTaskName returns the name of a compile task based on the given
341// job name.
342func deriveCompileTaskName(jobName string, parts map[string]string) string {
Ravi Mistryd4731e92018-01-02 14:54:43 -0500343 if strings.Contains(jobName, "Bookmaker") {
Ravi Mistryedc4f3e2017-12-08 12:58:20 -0500344 return "Build-Debian9-GCC-x86_64-Release"
345 } else if parts["role"] == "Housekeeper" {
Eric Borenbb198fb2017-06-28 11:45:54 -0400346 return "Build-Debian9-GCC-x86_64-Release-Shared"
Yuqian Li4a577af2018-01-05 11:13:43 -0500347 } else if parts["role"] == "Test" || parts["role"] == "Perf" || parts["role"] == "Calmbench" {
borenetdb182c72016-09-30 12:53:12 -0700348 task_os := parts["os"]
Ben Wagner988d15e2017-04-27 13:08:50 -0400349 ec := []string{}
350 if val := parts["extra_config"]; val != "" {
351 ec = strings.Split(val, "_")
Robert Phillips65eb4fb2018-05-31 13:27:52 -0400352 ignore := []string{"Skpbench", "AbandonGpuContext", "PreAbandonGpuContext", "Valgrind", "ReleaseAndAbandonGpuContext", "CCPR", "FSAA", "FAAA", "FDAA", "NativeFonts", "GDI", "NoGPUThreads", "ProcDump", "DDL1", "DDL3", "T8888", "DDLTotal", "DDLRecord", "9x9"}
Ben Wagner988d15e2017-04-27 13:08:50 -0400353 keep := make([]string, 0, len(ec))
354 for _, part := range ec {
355 if !util.In(part, ignore) {
356 keep = append(keep, part)
357 }
358 }
359 ec = keep
Eric Boren6ec17e32017-04-26 14:25:29 -0400360 }
borenetdb182c72016-09-30 12:53:12 -0700361 if task_os == "Android" {
Ben Wagner988d15e2017-04-27 13:08:50 -0400362 if !util.In("Android", ec) {
363 ec = append([]string{"Android"}, ec...)
borenetdb182c72016-09-30 12:53:12 -0700364 }
Eric Borenbb198fb2017-06-28 11:45:54 -0400365 task_os = "Debian9"
Kevin Lubickdcd2a902017-03-08 14:01:01 -0500366 } else if task_os == "Chromecast" {
Eric Borenbb198fb2017-06-28 11:45:54 -0400367 task_os = "Debian9"
Ben Wagner988d15e2017-04-27 13:08:50 -0400368 ec = append([]string{"Chromecast"}, ec...)
Kevin Lubickcb6f3982017-04-07 10:04:08 -0400369 } else if strings.Contains(task_os, "ChromeOS") {
Kevin Lubickb718fbb2017-11-02 09:34:08 -0400370 ec = append([]string{"Chromebook", "GLES"}, ec...)
Eric Borenbb198fb2017-06-28 11:45:54 -0400371 task_os = "Debian9"
borenetdb182c72016-09-30 12:53:12 -0700372 } else if task_os == "iOS" {
Ben Wagner988d15e2017-04-27 13:08:50 -0400373 ec = append([]string{task_os}, ec...)
borenetdb182c72016-09-30 12:53:12 -0700374 task_os = "Mac"
375 } else if strings.Contains(task_os, "Win") {
376 task_os = "Win"
Eric Borenbb198fb2017-06-28 11:45:54 -0400377 } else if strings.Contains(task_os, "Ubuntu") || strings.Contains(task_os, "Debian") {
378 task_os = "Debian9"
borenetdb182c72016-09-30 12:53:12 -0700379 }
Eric Boren50831302016-11-18 13:10:51 -0500380 jobNameMap := map[string]string{
borenetdb182c72016-09-30 12:53:12 -0700381 "role": "Build",
382 "os": task_os,
383 "compiler": parts["compiler"],
384 "target_arch": parts["arch"],
385 "configuration": parts["configuration"],
Eric Boren50831302016-11-18 13:10:51 -0500386 }
Eric Borene8b38ab2018-06-08 12:37:53 -0400387 if strings.Contains(jobName, "-CT_") {
388 ec = []string{"Static"}
389 }
Ben Wagner988d15e2017-04-27 13:08:50 -0400390 if len(ec) > 0 {
391 jobNameMap["extra_config"] = strings.Join(ec, "_")
Eric Boren50831302016-11-18 13:10:51 -0500392 }
393 name, err := jobNameSchema.MakeJobName(jobNameMap)
borenetdb182c72016-09-30 12:53:12 -0700394 if err != nil {
395 glog.Fatal(err)
396 }
397 return name
398 } else {
399 return jobName
400 }
401}
402
403// swarmDimensions generates swarming bot dimensions for the given task.
404func swarmDimensions(parts map[string]string) []string {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400405 if alternateSwarmDimensions != nil {
406 return alternateSwarmDimensions(parts)
407 }
408 return defaultSwarmDimensions(parts)
409}
410
411// defaultSwarmDimensions generates default swarming bot dimensions for the given task.
412func defaultSwarmDimensions(parts map[string]string) []string {
borenetdb182c72016-09-30 12:53:12 -0700413 d := map[string]string{
Eric Boren27225492017-02-01 15:56:55 -0500414 "pool": CONFIG.Pool,
borenetdb182c72016-09-30 12:53:12 -0700415 }
416 if os, ok := parts["os"]; ok {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400417 d["os"], ok = map[string]string{
Kevin Lubick291547d2017-03-21 09:25:34 -0400418 "Android": "Android",
419 "Chromecast": "Android",
Kevin Lubickcb6f3982017-04-07 10:04:08 -0400420 "ChromeOS": "ChromeOS",
Eric Borenbb198fb2017-06-28 11:45:54 -0400421 "Debian9": DEFAULT_OS_DEBIAN,
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500422 "Mac": DEFAULT_OS_MAC,
Eric Borenbb198fb2017-06-28 11:45:54 -0400423 "Ubuntu14": DEFAULT_OS_UBUNTU,
Eric Boren810c2b62017-07-11 08:11:15 -0400424 "Ubuntu17": "Ubuntu-17.04",
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500425 "Win": DEFAULT_OS_WIN,
Ben Wagner0954a192018-07-11 17:33:52 -0400426 "Win10": "Windows-10-17134.165",
Kevin Lubick291547d2017-03-21 09:25:34 -0400427 "Win2k8": "Windows-2008ServerR2-SP1",
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500428 "Win2016": DEFAULT_OS_WIN,
Ben Wagner56738d82017-04-18 15:38:15 -0400429 "Win7": "Windows-7-SP1",
Kevin Lubick291547d2017-03-21 09:25:34 -0400430 "Win8": "Windows-8.1-SP0",
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400431 "iOS": "iOS-10.3.1",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500432 }[os]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400433 if !ok {
434 glog.Fatalf("Entry %q not found in OS mapping.", os)
435 }
Ben Wagnerbc989202018-02-28 14:22:27 -0500436 if os == "Win10" && parts["model"] == "Golo" {
Ben Wagnerf6148b62018-03-15 13:53:25 -0400437 // ChOps-owned machines have Windows 10 v1709, but a slightly different version than Skolo.
438 d["os"] = "Windows-10-16299.309"
Ben Wagnerb3c90fc2018-02-23 11:17:03 -0500439 }
Ben Wagnere1c37a72018-04-24 16:59:48 -0400440 if d["os"] == DEFAULT_OS_WIN {
441 // TODO(dogben): Temporarily add image dimension during upgrade.
Ben Wagner7a879622018-07-18 10:14:23 -0400442 d["image"] = "windows-server-2016-dc-v20180710"
Ben Wagnere1c37a72018-04-24 16:59:48 -0400443 }
Ben Wagner78077d12018-07-27 16:28:43 -0400444 // TODO(dogben): Most Mac bots are on 10.13.6. Mac builders are stuck on
445 // 10.13.3 for now because of unresolved issues with building iOS and
446 // MoltenVK. MacMini7.1 are stuck on 10.13.3 because they run *SAN, which
447 // (currently) needs to have an XCode installed that matches the XCode of
448 // the builder.
449 if d["os"] == DEFAULT_OS_MAC && !(parts["model"] == "MacMini7.1" || parts["role"] == "Build") {
Ben Wagner42974b72018-07-10 16:29:53 -0400450 d["os"] = "Mac-10.13.6"
Ben Wagner418ff4a2018-06-20 16:12:16 -0400451 }
borenetdb182c72016-09-30 12:53:12 -0700452 } else {
Eric Borenbb198fb2017-06-28 11:45:54 -0400453 d["os"] = DEFAULT_OS_DEBIAN
borenetdb182c72016-09-30 12:53:12 -0700454 }
Yuqian Liab246cb2017-11-02 13:48:23 -0400455 if parts["role"] == "Test" || parts["role"] == "Perf" || parts["role"] == "Calmbench" {
Kevin Lubick291547d2017-03-21 09:25:34 -0400456 if strings.Contains(parts["os"], "Android") || strings.Contains(parts["os"], "Chromecast") {
borenetdb182c72016-09-30 12:53:12 -0700457 // For Android, the device type is a better dimension
458 // than CPU or GPU.
Ben Wagner36682782017-06-14 10:01:45 -0400459 deviceInfo, ok := map[string][]string{
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400460 "AndroidOne": {"sprout", "MOB30Q"},
Kevin Lubickc2f3e8d2018-01-24 15:48:26 -0500461 "Chorizo": {"chorizo", "1.30_109591"},
Ben Wagner0762bdf2017-11-28 09:41:48 -0500462 "GalaxyS6": {"zerofltetmo", "NRD90M_G920TUVU5FQK1"},
Ben Wagnerc72c9482018-06-11 13:48:44 -0400463 "GalaxyS7_G930FD": {"herolte", "R16NW_G930FXXU2EREM"}, // This is Oreo.
Ben Wagner8d8f45d2018-06-04 17:32:04 -0400464 "MotoG4": {"athene", "NPJS25.93-14.7-8"},
Ben Wagneree3123c2017-12-06 16:29:04 -0500465 "NVIDIA_Shield": {"foster", "NRD90M_1915764_848"},
Ben Wagneree3123c2017-12-06 16:29:04 -0500466 "Nexus5": {"hammerhead", "M4B30Z_3437181"},
Ben Wagnereb549c82017-11-17 08:59:44 -0500467 "Nexus5x": {"bullhead", "OPR6.170623.023"},
Ben Wagneree3123c2017-12-06 16:29:04 -0500468 "Nexus7": {"grouper", "LMY47V_1836172"}, // 2012 Nexus 7
Ben Wagner2a510c92018-04-11 12:36:56 -0400469 "NexusPlayer": {"fugu", "OPR2.170623.027"},
Ben Wagner3de510a2018-05-22 15:50:07 -0400470 "Pixel": {"sailfish", "OPM4.171019.016.B1"},
471 "Pixel2XL": {"taimen", "OPM4.171019.016.B1"},
Ben Wagner36682782017-06-14 10:01:45 -0400472 }[parts["model"]]
Eric Boren27225492017-02-01 15:56:55 -0500473 if !ok {
Ben Wagner36682782017-06-14 10:01:45 -0400474 glog.Fatalf("Entry %q not found in Android mapping.", parts["model"])
Eric Boren27225492017-02-01 15:56:55 -0500475 }
Eric Boren4b254b92016-11-08 12:55:32 -0500476 d["device_type"] = deviceInfo[0]
477 d["device_os"] = deviceInfo[1]
borenetdb182c72016-09-30 12:53:12 -0700478 } else if strings.Contains(parts["os"], "iOS") {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400479 device, ok := map[string]string{
Eric Boren792079c2016-11-09 14:03:20 -0500480 "iPadMini4": "iPad5,1",
Stephan Altmueller63e843d2017-04-25 11:38:38 -0400481 "iPhone6": "iPhone7,2",
482 "iPhone7": "iPhone9,1",
483 "iPadPro": "iPad6,3",
borenetdb182c72016-09-30 12:53:12 -0700484 }[parts["model"]]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400485 if !ok {
486 glog.Fatalf("Entry %q not found in iOS mapping.", parts["model"])
487 }
488 d["device"] = device
Ben Wagnerd26e4462018-05-22 10:46:15 -0400489 } else if strings.Contains(parts["extra_config"], "SwiftShader") {
490 if parts["model"] != "GCE" || d["os"] != DEFAULT_OS_DEBIAN || parts["cpu_or_gpu_value"] != "SwiftShader" {
491 glog.Fatalf("Please update defaultSwarmDimensions for SwiftShader %s %s %s.", parts["os"], parts["model"], parts["cpu_or_gpu_value"])
492 }
493 d["cpu"] = "x86-64-Haswell_GCE"
494 d["os"] = DEFAULT_OS_LINUX_GCE
495 d["machine_type"] = MACHINE_TYPE_SMALL
borenetdb182c72016-09-30 12:53:12 -0700496 } else if parts["cpu_or_gpu"] == "CPU" {
Ben Wagner4c9842e2017-09-25 12:56:53 -0400497 modelMapping, ok := map[string]map[string]string{
498 "AVX": {
499 "MacMini7.1": "x86-64-E5-2697_v2",
500 "Golo": "x86-64-E5-2670",
501 },
502 "AVX2": {
Ben Wagner85fb42a2017-11-07 16:57:37 -0500503 "GCE": "x86-64-Haswell_GCE",
Mike Klein9a01a212017-11-03 12:19:54 -0400504 "NUC5i7RYH": "x86-64-i7-5557U",
Ben Wagner4c9842e2017-09-25 12:56:53 -0400505 },
Ben Wagnerb268d232017-09-28 16:38:34 -0400506 "AVX512": {
507 "GCE": "x86-64-Skylake_GCE",
508 },
borenetdb182c72016-09-30 12:53:12 -0700509 }[parts["cpu_or_gpu_value"]]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400510 if !ok {
511 glog.Fatalf("Entry %q not found in CPU mapping.", parts["cpu_or_gpu_value"])
512 }
Ben Wagner4c9842e2017-09-25 12:56:53 -0400513 cpu, ok := modelMapping[parts["model"]]
514 if !ok {
515 glog.Fatalf("Entry %q not found in %q model mapping.", parts["model"], parts["cpu_or_gpu_value"])
borenetdb182c72016-09-30 12:53:12 -0700516 }
Ben Wagner4c9842e2017-09-25 12:56:53 -0400517 d["cpu"] = cpu
Eric Boren170c39c2017-11-15 11:22:57 -0500518 if parts["model"] == "GCE" && d["os"] == DEFAULT_OS_DEBIAN {
519 d["os"] = DEFAULT_OS_LINUX_GCE
520 }
Ben Wagnere99a4b12018-05-04 11:18:01 -0400521 if parts["model"] == "GCE" && d["cpu"] == "x86-64-Haswell_GCE" {
Ben Wagner27d5a362018-05-09 15:37:34 -0400522 // Coverage gets slower with more cores.
523 if strings.Contains(parts["extra_config"], "Coverage") {
Ben Wagner297e86b2018-05-14 12:38:09 -0400524 d["machine_type"] = MACHINE_TYPE_SMALL
525 } else {
526 d["machine_type"] = MACHINE_TYPE_MEDIUM
Ben Wagner27d5a362018-05-09 15:37:34 -0400527 }
Ben Wagnerf53e6c92017-12-14 13:15:01 -0500528 }
borenetdb182c72016-09-30 12:53:12 -0700529 } else {
Ben Wagner1d060782017-06-14 10:34:18 -0400530 if strings.Contains(parts["os"], "Win") {
531 gpu, ok := map[string]string{
Ben Wagnerf6148b62018-03-15 13:53:25 -0400532 "GT610": "10de:104a-23.21.13.9101",
Ben Wagner96ee1192018-02-28 17:30:19 -0500533 "GTX1070": "10de:1ba1-23.21.13.9101",
534 "GTX660": "10de:11c0-23.21.13.9101",
535 "GTX960": "10de:1401-23.21.13.9101",
Ben Wagner90e88aa2018-02-26 23:38:52 -0500536 "IntelHD4400": "8086:0a16-20.19.15.4835",
Ben Wagner300cf062018-04-11 11:29:59 -0400537 "IntelIris540": "8086:1926-23.20.16.4982",
Ben Wagner90e88aa2018-02-26 23:38:52 -0500538 "IntelIris6100": "8086:162b-20.19.15.4835",
Ben Wagnerf8f18392018-04-24 18:17:02 -0400539 "RadeonHD7770": "1002:683d-23.20.15033.5003",
540 "RadeonR9M470X": "1002:6646-23.20.15033.5003",
Ben Wagnerf6148b62018-03-15 13:53:25 -0400541 "QuadroP400": "10de:1cb3-23.21.13.9103",
Ben Wagner1d060782017-06-14 10:34:18 -0400542 }[parts["cpu_or_gpu_value"]]
543 if !ok {
544 glog.Fatalf("Entry %q not found in Win GPU mapping.", parts["cpu_or_gpu_value"])
545 }
546 d["gpu"] = gpu
Ben Wagner08435892017-02-18 23:28:26 -0500547
Ben Wagner4b1df022017-06-15 12:28:04 -0400548 // Specify cpu dimension for NUCs and ShuttleCs. We temporarily have two
549 // types of machines with a GTX960.
550 cpu, ok := map[string]string{
551 "NUC6i7KYK": "x86-64-i7-6770HQ",
552 "ShuttleC": "x86-64-i7-6700K",
Ben Wagner1d060782017-06-14 10:34:18 -0400553 }[parts["model"]]
554 if ok {
Ben Wagner4b1df022017-06-15 12:28:04 -0400555 d["cpu"] = cpu
Ben Wagner1d060782017-06-14 10:34:18 -0400556 }
Eric Borenbb198fb2017-06-28 11:45:54 -0400557 } else if strings.Contains(parts["os"], "Ubuntu") || strings.Contains(parts["os"], "Debian") {
Ben Wagner1d060782017-06-14 10:34:18 -0400558 gpu, ok := map[string]string{
Ben Wagner1d060782017-06-14 10:34:18 -0400559 // Intel drivers come from CIPD, so no need to specify the version here.
560 "IntelBayTrail": "8086:0f31",
561 "IntelHD2000": "8086:0102",
562 "IntelHD405": "8086:22b1",
Ben Wagnerab10c822017-12-19 15:14:12 -0500563 "IntelIris640": "8086:5926",
Ben Wagnerc274ec42017-08-03 22:29:22 -0400564 "QuadroP400": "10de:1cb3-384.59",
Ben Wagner1d060782017-06-14 10:34:18 -0400565 }[parts["cpu_or_gpu_value"]]
566 if !ok {
567 glog.Fatalf("Entry %q not found in Ubuntu GPU mapping.", parts["cpu_or_gpu_value"])
568 }
569 d["gpu"] = gpu
570 } else if strings.Contains(parts["os"], "Mac") {
571 gpu, ok := map[string]string{
Ben Wagner1d8726f2018-02-02 14:47:31 -0500572 "IntelHD6000": "8086:1626",
Ben Wagnerdf430052018-02-08 16:57:04 -0500573 "IntelHD615": "8086:591e",
Ben Wagnercc4221b2017-08-17 17:29:04 -0400574 "IntelIris5100": "8086:0a2e",
Ben Wagnereeeb3282018-05-15 16:45:42 -0400575 "RadeonHD8870M": "1002:6821-4.0.20-3.2.8",
Ben Wagner1d060782017-06-14 10:34:18 -0400576 }[parts["cpu_or_gpu_value"]]
577 if !ok {
578 glog.Fatalf("Entry %q not found in Mac GPU mapping.", parts["cpu_or_gpu_value"])
579 }
580 d["gpu"] = gpu
Ben Wagnere7b8fea2018-02-09 10:29:09 -0500581 // Yuck. We have two different types of MacMini7,1 with the same GPU but different CPUs.
582 if parts["cpu_or_gpu_value"] == "IntelIris5100" {
583 // Run all tasks on Golo machines for now.
584 d["cpu"] = "x86-64-i7-4578U"
585 }
Ben Wagner1d060782017-06-14 10:34:18 -0400586 } else if strings.Contains(parts["os"], "ChromeOS") {
Kevin Lubick64ca6be2017-12-04 15:43:31 -0500587 version, ok := map[string]string{
Kevin Lubickff8387f2018-05-01 10:43:35 -0400588 "MaliT604": "10575.22.0",
Kevin Lubicke114e592018-05-01 08:53:52 -0400589 "MaliT764": "10575.22.0",
Kevin Lubicke467d4e2018-05-01 13:12:58 -0400590 "MaliT860": "10575.22.0",
591 "PowerVRGX6250": "10575.22.0",
592 "TegraK1": "10575.22.0",
593 "IntelHDGraphics615": "10575.22.0",
Ben Wagner1d060782017-06-14 10:34:18 -0400594 }[parts["cpu_or_gpu_value"]]
595 if !ok {
596 glog.Fatalf("Entry %q not found in ChromeOS GPU mapping.", parts["cpu_or_gpu_value"])
597 }
Kevin Lubick64ca6be2017-12-04 15:43:31 -0500598 d["gpu"] = parts["cpu_or_gpu_value"]
599 d["release_version"] = version
Ben Wagner1d060782017-06-14 10:34:18 -0400600 } else {
601 glog.Fatalf("Unknown GPU mapping for OS %q.", parts["os"])
Ben Wagner08435892017-02-18 23:28:26 -0500602 }
borenetdb182c72016-09-30 12:53:12 -0700603 }
604 } else {
605 d["gpu"] = "none"
Eric Borenbb198fb2017-06-28 11:45:54 -0400606 if d["os"] == DEFAULT_OS_DEBIAN {
Ben Wagnere99a4b12018-05-04 11:18:01 -0400607 // Use many-core machines for Build tasks.
608 return linuxGceDimensions(MACHINE_TYPE_LARGE)
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500609 } else if d["os"] == DEFAULT_OS_WIN {
610 // Windows CPU bots.
Ben Wagnera78f1bc2017-09-26 18:19:56 -0400611 d["cpu"] = "x86-64-Haswell_GCE"
Ben Wagnere99a4b12018-05-04 11:18:01 -0400612 // Use many-core machines for Build tasks.
613 d["machine_type"] = MACHINE_TYPE_LARGE
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500614 } else if d["os"] == DEFAULT_OS_MAC {
615 // Mac CPU bots.
Ben Wagnera78f1bc2017-09-26 18:19:56 -0400616 d["cpu"] = "x86-64-E5-2697_v2"
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400617 }
borenetdb182c72016-09-30 12:53:12 -0700618 }
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400619
borenetdb182c72016-09-30 12:53:12 -0700620 rv := make([]string, 0, len(d))
621 for k, v := range d {
622 rv = append(rv, fmt.Sprintf("%s:%s", k, v))
623 }
624 sort.Strings(rv)
625 return rv
626}
627
Eric Boren7e3a3642017-06-14 15:25:31 -0400628// relpath returns the relative path to the given file from the config file.
629func relpath(f string) string {
630 _, filename, _, _ := runtime.Caller(0)
631 dir := path.Dir(filename)
632 rel := dir
633 if *cfgFile != "" {
634 rel = path.Dir(*cfgFile)
635 }
636 rv, err := filepath.Rel(rel, path.Join(dir, f))
637 if err != nil {
638 sklog.Fatal(err)
639 }
640 return rv
641}
642
Eric Boren8b3f9e62017-04-04 09:06:16 -0400643// bundleRecipes generates the task to bundle and isolate the recipes.
644func bundleRecipes(b *specs.TasksCfgBuilder) string {
Eric Boren63924422018-06-21 09:02:30 -0400645 pkgs := append([]*specs.CipdPackage{}, CIPD_PKGS_GIT...)
646 pkgs = append(pkgs, CIPD_PKGS_PYTHON...)
Eric Boren8b3f9e62017-04-04 09:06:16 -0400647 b.MustAddTask(BUNDLE_RECIPES_NAME, &specs.TaskSpec{
Eric Boren63924422018-06-21 09:02:30 -0400648 CipdPackages: pkgs,
Eric Boren9599b0f2018-04-17 15:55:57 -0400649 Command: []string{
650 "/bin/bash", "skia/infra/bots/bundle_recipes.sh", specs.PLACEHOLDER_ISOLATED_OUTDIR,
Eric Boren8b3f9e62017-04-04 09:06:16 -0400651 },
Ben Wagnere99a4b12018-05-04 11:18:01 -0400652 Dimensions: linuxGceDimensions(MACHINE_TYPE_SMALL),
Eric Boren9599b0f2018-04-17 15:55:57 -0400653 EnvPrefixes: map[string][]string{
654 "PATH": []string{"cipd_bin_packages", "cipd_bin_packages/bin"},
655 },
Ben Wagnerc062b6b2018-07-24 17:10:46 -0400656 Isolate: relpath("swarm_recipe.isolate"),
Eric Boren8b3f9e62017-04-04 09:06:16 -0400657 })
658 return BUNDLE_RECIPES_NAME
659}
660
Kevin Lubick07072942017-05-11 13:35:23 -0400661type isolateAssetCfg struct {
Eric Boren9599b0f2018-04-17 15:55:57 -0400662 cipdPkg string
663 path string
Kevin Lubick07072942017-05-11 13:35:23 -0400664}
665
666var ISOLATE_ASSET_MAPPING = map[string]isolateAssetCfg{
Stephan Altmueller88df8d22018-03-07 14:44:44 -0500667 ISOLATE_GCLOUD_LINUX_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400668 cipdPkg: "gcloud_linux",
669 path: "gcloud_linux",
Stephan Altmueller88df8d22018-03-07 14:44:44 -0500670 },
671 ISOLATE_GO_LINUX_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400672 cipdPkg: "go",
673 path: "go",
Stephan Altmueller88df8d22018-03-07 14:44:44 -0500674 },
Kevin Lubick07072942017-05-11 13:35:23 -0400675 ISOLATE_SKIMAGE_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400676 cipdPkg: "skimage",
677 path: "skimage",
Kevin Lubick07072942017-05-11 13:35:23 -0400678 },
679 ISOLATE_SKP_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400680 cipdPkg: "skp",
681 path: "skp",
Kevin Lubick07072942017-05-11 13:35:23 -0400682 },
683 ISOLATE_SVG_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400684 cipdPkg: "svg",
685 path: "svg",
Kevin Lubick07072942017-05-11 13:35:23 -0400686 },
Kevin Lubick814b1492017-11-29 14:45:14 -0500687 ISOLATE_NDK_LINUX_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400688 cipdPkg: "android_ndk_linux",
689 path: "android_ndk_linux",
Kevin Lubick814b1492017-11-29 14:45:14 -0500690 },
Stephan Altmueller2a552172018-02-20 11:40:25 -0500691 ISOLATE_SDK_LINUX_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400692 cipdPkg: "android_sdk_linux",
693 path: "android_sdk_linux",
Stephan Altmueller2a552172018-02-20 11:40:25 -0500694 },
Kevin Lubick814b1492017-11-29 14:45:14 -0500695 ISOLATE_WIN_TOOLCHAIN_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400696 cipdPkg: "win_toolchain",
697 path: "t",
Kevin Lubick814b1492017-11-29 14:45:14 -0500698 },
699 ISOLATE_WIN_VULKAN_SDK_NAME: {
Eric Boren9599b0f2018-04-17 15:55:57 -0400700 cipdPkg: "win_vulkan_sdk",
701 path: "win_vulkan_sdk",
Kevin Lubick814b1492017-11-29 14:45:14 -0500702 },
Kevin Lubick07072942017-05-11 13:35:23 -0400703}
704
Eric Boren9599b0f2018-04-17 15:55:57 -0400705// isolateCIPDAsset generates a task to isolate the given CIPD asset.
Kevin Lubick07072942017-05-11 13:35:23 -0400706func isolateCIPDAsset(b *specs.TasksCfgBuilder, name string) string {
Eric Boren9599b0f2018-04-17 15:55:57 -0400707 asset := ISOLATE_ASSET_MAPPING[name]
Kevin Lubick07072942017-05-11 13:35:23 -0400708 b.MustAddTask(name, &specs.TaskSpec{
709 CipdPackages: []*specs.CipdPackage{
Eric Boren9599b0f2018-04-17 15:55:57 -0400710 b.MustGetCipdPackageFromAsset(asset.cipdPkg),
Kevin Lubick07072942017-05-11 13:35:23 -0400711 },
Eric Boren9599b0f2018-04-17 15:55:57 -0400712 Command: []string{"/bin/cp", "-rL", asset.path, "${ISOLATED_OUTDIR}"},
Ben Wagnere99a4b12018-05-04 11:18:01 -0400713 Dimensions: linuxGceDimensions(MACHINE_TYPE_SMALL),
Eric Boren9599b0f2018-04-17 15:55:57 -0400714 Isolate: relpath("empty.isolate"),
Kevin Lubick07072942017-05-11 13:35:23 -0400715 })
716 return name
717}
718
Kevin Lubick90189522017-05-15 08:30:27 -0400719// getIsolatedCIPDDeps returns the slice of Isolate_* tasks a given task needs.
720// This allows us to save time on I/O bound bots, like the RPIs.
721func getIsolatedCIPDDeps(parts map[string]string) []string {
722 deps := []string{}
Kevin Lubick07072942017-05-11 13:35:23 -0400723 // Only do this on the RPIs for now. Other, faster machines shouldn't see much
724 // benefit and we don't need the extra complexity, for now
Kevin Lubick90189522017-05-15 08:30:27 -0400725 rpiOS := []string{"Android", "ChromeOS", "iOS"}
726
727 if o := parts["os"]; strings.Contains(o, "Chromecast") {
728 // Chromecasts don't have enough disk space to fit all of the content,
729 // so we do a subset of the skps.
730 deps = append(deps, ISOLATE_SKP_NAME)
731 } else if e := parts["extra_config"]; strings.Contains(e, "Skpbench") {
732 // Skpbench only needs skps
733 deps = append(deps, ISOLATE_SKP_NAME)
734 } else if util.In(o, rpiOS) {
735 deps = append(deps, ISOLATE_SKP_NAME)
736 deps = append(deps, ISOLATE_SVG_NAME)
737 deps = append(deps, ISOLATE_SKIMAGE_NAME)
738 }
739
740 return deps
Kevin Lubick07072942017-05-11 13:35:23 -0400741}
742
Eric Boren5cb5c742018-04-27 13:14:38 -0400743// usesGit adds attributes to tasks which use git.
744func usesGit(t *specs.TaskSpec, name string) {
745 t.Caches = append(t.Caches, CACHES_GIT...)
746 if !strings.Contains(name, "NoDEPS") {
747 t.Caches = append(t.Caches, CACHES_WORKDIR...)
748 }
749 t.CipdPackages = append(t.CipdPackages, CIPD_PKGS_GIT...)
750}
751
Kevin Lubick30cc00c2018-08-03 10:26:00 -0400752// usesDocker adds attributes to tasks which use docker.
753func usesDocker(t *specs.TaskSpec, name string) {
754 // currently, just the WASM (using EMCC) builder uses Docker.
755 if strings.Contains(name, "EMCC") {
756 t.Caches = append(t.Caches, CACHES_DOCKER...)
757 }
758}
759
Eric Boren5cb5c742018-04-27 13:14:38 -0400760// timeout sets the timeout(s) for this task.
761func timeout(task *specs.TaskSpec, timeout time.Duration) {
762 task.ExecutionTimeout = timeout
763 task.IoTimeout = timeout // With kitchen, step logs don't count toward IoTimeout.
764}
765
borenetdb182c72016-09-30 12:53:12 -0700766// compile generates a compile task. Returns the name of the last task in the
767// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700768func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string {
Eric Boren9599b0f2018-04-17 15:55:57 -0400769 task := kitchenTask(name, "compile", "swarm_recipe.isolate", SERVICE_ACCOUNT_COMPILE, swarmDimensions(parts), nil, OUTPUT_BUILD)
Eric Boren5cb5c742018-04-27 13:14:38 -0400770 usesGit(task, name)
Kevin Lubick30cc00c2018-08-03 10:26:00 -0400771 usesDocker(task, name)
borenetdb182c72016-09-30 12:53:12 -0700772
773 // Android bots require a toolchain.
774 if strings.Contains(name, "Android") {
Ravi Mistry5e967422018-02-01 13:38:13 -0500775 if parts["extra_config"] == "Android_Framework" {
776 // Do not need a toolchain when building the
777 // Android Framework.
778 } else if strings.Contains(name, "Mac") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400779 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("android_ndk_darwin"))
Mike Klein86c2c0f2016-11-02 13:13:16 -0400780 } else if strings.Contains(name, "Win") {
Mike Kleine9215f02016-11-02 15:44:26 -0400781 pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows")
782 pkg.Path = "n"
Eric Boren9599b0f2018-04-17 15:55:57 -0400783 task.CipdPackages = append(task.CipdPackages, pkg)
borenetdb182c72016-09-30 12:53:12 -0700784 } else {
Eric Boren9599b0f2018-04-17 15:55:57 -0400785 task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_NDK_LINUX_NAME))
Stephan Altmueller88df8d22018-03-07 14:44:44 -0500786 if strings.Contains(name, "SKQP") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400787 task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_SDK_LINUX_NAME), isolateCIPDAsset(b, ISOLATE_GO_LINUX_NAME))
Stephan Altmueller88df8d22018-03-07 14:44:44 -0500788 }
borenetdb182c72016-09-30 12:53:12 -0700789 }
Kevin Lubickdcd2a902017-03-08 14:01:01 -0500790 } else if strings.Contains(name, "Chromecast") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400791 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("cast_toolchain"))
792 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("chromebook_arm_gles"))
Kevin Lubick261ea192017-04-05 07:32:45 -0400793 } else if strings.Contains(name, "Chromebook") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400794 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("clang_linux"))
Kevin Lubickb718fbb2017-11-02 09:34:08 -0400795 if parts["target_arch"] == "x86_64" {
Eric Boren9599b0f2018-04-17 15:55:57 -0400796 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("chromebook_x86_64_gles"))
Kevin Lubickb718fbb2017-11-02 09:34:08 -0400797 } else if parts["target_arch"] == "arm" {
Eric Boren9599b0f2018-04-17 15:55:57 -0400798 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("armhf_sysroot"))
799 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("chromebook_arm_gles"))
Kevin Lubickb718fbb2017-11-02 09:34:08 -0400800 }
Eric Boren5cb5c742018-04-27 13:14:38 -0400801 } else if strings.Contains(name, "CommandBuffer") {
802 timeout(task, 2*time.Hour)
Eric Borenbb198fb2017-06-28 11:45:54 -0400803 } else if strings.Contains(name, "Debian") {
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500804 if strings.Contains(name, "Clang") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400805 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("clang_linux"))
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500806 }
807 if strings.Contains(name, "Vulkan") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400808 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500809 }
Ben Wagner9bd736b2018-04-04 15:35:01 -0400810 if parts["target_arch"] == "mips64el" || parts["target_arch"] == "loongson3a" {
811 if parts["compiler"] != "GCC" {
812 glog.Fatalf("mips64el toolchain is GCC, but compiler is %q in %q", parts["compiler"], name)
813 }
Eric Boren9599b0f2018-04-17 15:55:57 -0400814 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("mips64el_toolchain_linux"))
Ben Wagner9bd736b2018-04-04 15:35:01 -0400815 }
Ben Wagnerbbdee1b2018-04-19 17:53:03 -0400816 if strings.Contains(name, "SwiftShader") {
817 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("cmake_linux"))
818 }
Ben Wagner55a7d222018-06-28 20:41:04 -0400819 if strings.Contains(name, "OpenCL") {
820 task.CipdPackages = append(task.CipdPackages,
821 b.MustGetCipdPackageFromAsset("opencl_headers"),
822 b.MustGetCipdPackageFromAsset("opencl_ocl_icd_linux"),
823 )
824 }
Mike Klein27dcee12016-11-09 16:31:42 -0500825 } else if strings.Contains(name, "Win") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400826 task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_WIN_TOOLCHAIN_NAME))
Mike Klein8e3c42b2017-07-31 14:57:20 -0400827 if strings.Contains(name, "Clang") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400828 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("clang_win"))
Mike Klein8e3c42b2017-07-31 14:57:20 -0400829 }
borenetdb182c72016-09-30 12:53:12 -0700830 if strings.Contains(name, "Vulkan") {
Eric Boren9599b0f2018-04-17 15:55:57 -0400831 task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_WIN_VULKAN_SDK_NAME))
borenetdb182c72016-09-30 12:53:12 -0700832 }
833 }
834
Chris Dalton2b937f52018-05-17 10:17:10 -0600835 if strings.Contains(name, "MoltenVK") {
836 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("moltenvk"))
837 }
838
Ben Wagneradeb75d2018-04-19 21:48:55 -0400839 task.MaxAttempts = 1
840
Eric Borenbd2e1f12018-04-17 11:28:46 +0000841 // Add the task.
Eric Boren9599b0f2018-04-17 15:55:57 -0400842 b.MustAddTask(name, task)
843
Eric Boren8615fe52016-12-12 14:30:12 -0500844 // All compile tasks are runnable as their own Job. Assert that the Job
845 // is listed in JOBS.
846 if !util.In(name, JOBS) {
847 glog.Fatalf("Job %q is missing from the JOBS list!", name)
848 }
Ravi Mistry6f136222017-12-12 17:08:24 -0500849
850 // Upload the skiaserve binary only for Linux Android compile bots.
851 // See skbug.com/7399 for context.
852 if parts["configuration"] == "Release" &&
853 parts["extra_config"] == "Android" &&
854 !strings.Contains(parts["os"], "Win") &&
855 !strings.Contains(parts["os"], "Mac") {
856 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
Ben Wagnere99a4b12018-05-04 11:18:01 -0400857 task := kitchenTask(uploadName, "upload_skiaserve", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_BINARY, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE)
Eric Boren9599b0f2018-04-17 15:55:57 -0400858 task.Dependencies = append(task.Dependencies, name)
859 b.MustAddTask(uploadName, task)
Ravi Mistry6f136222017-12-12 17:08:24 -0500860 return uploadName
861 }
862
borenetdb182c72016-09-30 12:53:12 -0700863 return name
864}
865
866// recreateSKPs generates a RecreateSKPs task. Returns the name of the last
867// task in the generated chain of tasks, which the Job should add as a
868// dependency.
Eric Boren27688612018-04-16 13:21:01 +0000869func recreateSKPs(b *specs.TasksCfgBuilder, name string) string {
Ravi Mistry5a12d052018-05-15 17:19:42 -0400870 dims := []string{
871 "pool:SkiaCT",
872 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE),
873 }
874 task := kitchenTask(name, "recreate_skps", "swarm_recipe.isolate", SERVICE_ACCOUNT_RECREATE_SKPS, dims, nil, OUTPUT_NONE)
Eric Borene7950e32018-04-26 08:49:38 -0400875 task.CipdPackages = append(task.CipdPackages, CIPD_PKGS_GIT...)
Eric Boren9599b0f2018-04-17 15:55:57 -0400876 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("go"))
Eric Boren5cb5c742018-04-27 13:14:38 -0400877 timeout(task, 4*time.Hour)
Eric Boren9599b0f2018-04-17 15:55:57 -0400878 b.MustAddTask(name, task)
borenetdb182c72016-09-30 12:53:12 -0700879 return name
880}
881
882// ctSKPs generates a CT SKPs task. Returns the name of the last task in the
883// generated chain of tasks, which the Job should add as a dependency.
Eric Borene8b38ab2018-06-08 12:37:53 -0400884func ctSKPs(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
Eric Boren9599b0f2018-04-17 15:55:57 -0400885 dims := []string{
886 "pool:SkiaCT",
887 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE),
888 }
Eric Borene8b38ab2018-06-08 12:37:53 -0400889 task := kitchenTask(name, "ct_skps", "swarm_recipe.isolate", SERVICE_ACCOUNT_CT_SKPS, dims, nil, OUTPUT_NONE)
Eric Boren5cb5c742018-04-27 13:14:38 -0400890 usesGit(task, name)
Eric Boren9599b0f2018-04-17 15:55:57 -0400891 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("clang_linux"))
Eric Borene8b38ab2018-06-08 12:37:53 -0400892 task.Dependencies = append(task.Dependencies, compileTaskName)
Eric Boren5cb5c742018-04-27 13:14:38 -0400893 timeout(task, 24*time.Hour)
Ben Wagneradeb75d2018-04-19 21:48:55 -0400894 task.MaxAttempts = 1
Eric Boren9599b0f2018-04-17 15:55:57 -0400895 b.MustAddTask(name, task)
borenetdb182c72016-09-30 12:53:12 -0700896 return name
897}
898
Eric Borenf7928b42017-07-28 07:35:28 -0400899// checkGeneratedFiles verifies that no generated SKSL files have been edited
900// by hand.
Eric Boren27688612018-04-16 13:21:01 +0000901func checkGeneratedFiles(b *specs.TasksCfgBuilder, name string) string {
Ben Wagnere99a4b12018-05-04 11:18:01 -0400902 task := kitchenTask(name, "check_generated_files", "swarm_recipe.isolate", SERVICE_ACCOUNT_COMPILE, linuxGceDimensions(MACHINE_TYPE_LARGE), nil, OUTPUT_NONE)
Eric Boren5cb5c742018-04-27 13:14:38 -0400903 task.Caches = append(task.Caches, CACHES_WORKDIR...)
Eric Boren9599b0f2018-04-17 15:55:57 -0400904 b.MustAddTask(name, task)
Eric Borenf7928b42017-07-28 07:35:28 -0400905 return name
906}
907
borenetdb182c72016-09-30 12:53:12 -0700908// housekeeper generates a Housekeeper task. Returns the name of the last task
909// in the generated chain of tasks, which the Job should add as a dependency.
Eric Boren27688612018-04-16 13:21:01 +0000910func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
Ben Wagnere99a4b12018-05-04 11:18:01 -0400911 task := kitchenTask(name, "housekeeper", "swarm_recipe.isolate", SERVICE_ACCOUNT_HOUSEKEEPER, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE)
Eric Boren5cb5c742018-04-27 13:14:38 -0400912 usesGit(task, name)
Eric Boren9599b0f2018-04-17 15:55:57 -0400913 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("go"))
914 task.Dependencies = append(task.Dependencies, compileTaskName)
915 b.MustAddTask(name, task)
borenetdb182c72016-09-30 12:53:12 -0700916 return name
917}
918
Ravi Mistryedc4f3e2017-12-08 12:58:20 -0500919// bookmaker generates a Bookmaker task. Returns the name of the last task
920// in the generated chain of tasks, which the Job should add as a dependency.
921func bookmaker(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
Ben Wagnere99a4b12018-05-04 11:18:01 -0400922 task := kitchenTask(name, "bookmaker", "swarm_recipe.isolate", SERVICE_ACCOUNT_BOOKMAKER, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE)
Eric Boren5cb5c742018-04-27 13:14:38 -0400923 task.Caches = append(task.Caches, CACHES_WORKDIR...)
Eric Borene7950e32018-04-26 08:49:38 -0400924 task.CipdPackages = append(task.CipdPackages, CIPD_PKGS_GIT...)
Eric Boren9599b0f2018-04-17 15:55:57 -0400925 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("go"))
926 task.Dependencies = append(task.Dependencies, compileTaskName)
Eric Boren5cb5c742018-04-27 13:14:38 -0400927 timeout(task, 2*time.Hour)
Eric Boren9599b0f2018-04-17 15:55:57 -0400928 b.MustAddTask(name, task)
Ravi Mistryedc4f3e2017-12-08 12:58:20 -0500929 return name
930}
931
Ravi Mistry5e967422018-02-01 13:38:13 -0500932// androidFrameworkCompile generates an Android Framework Compile task. Returns
933// the name of the last task in the generated chain of tasks, which the Job
934// should add as a dependency.
935func androidFrameworkCompile(b *specs.TasksCfgBuilder, name string) string {
Ben Wagnere99a4b12018-05-04 11:18:01 -0400936 task := kitchenTask(name, "android_compile", "swarm_recipe.isolate", SERVICE_ACCOUNT_COMPILE, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE)
Ben Wagneradeb75d2018-04-19 21:48:55 -0400937 task.MaxAttempts = 1
Eric Boren5cb5c742018-04-27 13:14:38 -0400938 timeout(task, time.Hour)
Eric Boren9599b0f2018-04-17 15:55:57 -0400939 b.MustAddTask(name, task)
Ravi Mistry5e967422018-02-01 13:38:13 -0500940 return name
941}
942
borenet2dbbfa52016-10-14 06:32:09 -0700943// infra generates an infra_tests task. Returns the name of the last task in the
944// generated chain of tasks, which the Job should add as a dependency.
Eric Boren27688612018-04-16 13:21:01 +0000945func infra(b *specs.TasksCfgBuilder, name string) string {
Ben Wagnere99a4b12018-05-04 11:18:01 -0400946 task := kitchenTask(name, "infra", "swarm_recipe.isolate", SERVICE_ACCOUNT_COMPILE, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE)
Eric Boren5cb5c742018-04-27 13:14:38 -0400947 usesGit(task, name)
Eric Boren9599b0f2018-04-17 15:55:57 -0400948 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("go"))
949 b.MustAddTask(name, task)
borenet2dbbfa52016-10-14 06:32:09 -0700950 return name
951}
952
Yuqian Li4a577af2018-01-05 11:13:43 -0500953func getParentRevisionName(compileTaskName string, parts map[string]string) string {
954 if parts["extra_config"] == "" {
955 return compileTaskName + "-ParentRevision"
956 } else {
957 return compileTaskName + "_ParentRevision"
958 }
959}
960
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400961// calmbench generates a calmbench task. Returns the name of the last task in the
962// generated chain of tasks, which the Job should add as a dependency.
Eric Boren9599b0f2018-04-17 15:55:57 -0400963func calmbench(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName, compileParentName string) string {
964 task := kitchenTask(name, "calmbench", "calmbench.isolate", "", swarmDimensions(parts), nil, OUTPUT_PERF)
Eric Boren5cb5c742018-04-27 13:14:38 -0400965 usesGit(task, name)
Eric Boren9599b0f2018-04-17 15:55:57 -0400966 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("go"))
967 task.Dependencies = append(task.Dependencies, compileTaskName, compileParentName, ISOLATE_SKP_NAME, ISOLATE_SVG_NAME)
Ben Wagneradeb75d2018-04-19 21:48:55 -0400968 task.MaxAttempts = 1
Eric Boren9599b0f2018-04-17 15:55:57 -0400969 b.MustAddTask(name, task)
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400970
Yuqian Li2ebf3d12017-10-24 09:43:21 -0400971 // Upload results if necessary.
972 if strings.Contains(name, "Release") && doUpload(name) {
973 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
Eric Boren9599b0f2018-04-17 15:55:57 -0400974 extraProps := map[string]string{
975 "gs_bucket": CONFIG.GsBucketCalm,
976 }
Ben Wagnere99a4b12018-05-04 11:18:01 -0400977 uploadTask := kitchenTask(name, "upload_calmbench_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_CALMBENCH, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE)
Eric Boren9599b0f2018-04-17 15:55:57 -0400978 uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...)
979 uploadTask.Dependencies = append(uploadTask.Dependencies, name)
980 b.MustAddTask(uploadName, uploadTask)
Yuqian Li2ebf3d12017-10-24 09:43:21 -0400981 return uploadName
982 }
983
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400984 return name
985}
986
borenetdb182c72016-09-30 12:53:12 -0700987// doUpload indicates whether the given Job should upload its results.
988func doUpload(name string) bool {
Eric Boren27225492017-02-01 15:56:55 -0500989 for _, s := range CONFIG.NoUpload {
990 m, err := regexp.MatchString(s, name)
991 if err != nil {
992 glog.Fatal(err)
993 }
994 if m {
borenetdb182c72016-09-30 12:53:12 -0700995 return false
996 }
997 }
998 return true
999}
1000
1001// test generates a Test task. Returns the name of the last task in the
1002// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -07001003func test(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Stephan Altmueller88df8d22018-03-07 14:44:44 -05001004 recipe := "test"
Stephan Altmueller88df8d22018-03-07 14:44:44 -05001005 if strings.Contains(name, "SKQP") {
1006 recipe = "skqp_test"
Ben Wagnera5e70302018-06-28 17:43:08 -04001007 } else if strings.Contains(name, "OpenCL") {
1008 // TODO(dogben): Longer term we may not want this to be called a "Test" task, but until we start
1009 // running hs_bench or kx, it will be easier to fit into the current job name schema.
1010 recipe = "compute_test"
Stephan Altmueller88df8d22018-03-07 14:44:44 -05001011 }
Stephan Altmüller64cc5762018-08-02 08:51:38 +02001012 extraProps := map[string]string{
1013 "gold_hashes_url": CONFIG.GoldHashesURL,
1014 }
Eric Boreneb702382018-04-19 09:36:45 -04001015 iid := internalHardwareLabel(parts)
1016 if iid != nil {
1017 extraProps["internal_hardware_label"] = strconv.Itoa(*iid)
1018 }
Eric Borene9a67002018-04-24 13:12:05 -04001019 task := kitchenTask(name, recipe, "test_skia_bundled.isolate", "", swarmDimensions(parts), extraProps, OUTPUT_TEST)
Eric Boren9599b0f2018-04-17 15:55:57 -04001020 task.CipdPackages = append(task.CipdPackages, pkgs...)
Eric Boren8c172ba2018-07-19 13:27:49 -04001021 if strings.Contains(name, "Lottie") {
1022 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("lottie-samples"))
1023 }
Eric Boren9599b0f2018-04-17 15:55:57 -04001024 task.Dependencies = append(task.Dependencies, compileTaskName)
1025 if strings.Contains(name, "Android_ASAN") {
1026 task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_NDK_LINUX_NAME))
Eric Boren9d78afd2017-12-07 14:54:05 +00001027 }
Eric Boren9599b0f2018-04-17 15:55:57 -04001028 if strings.Contains(name, "SKQP") {
1029 task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_GCLOUD_LINUX_NAME))
Eric Boren8b3f9e62017-04-04 09:06:16 -04001030 }
Kevin Lubick90189522017-05-15 08:30:27 -04001031 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
Eric Boren9599b0f2018-04-17 15:55:57 -04001032 task.Dependencies = append(task.Dependencies, deps...)
Kevin Lubick07072942017-05-11 13:35:23 -04001033 }
Eric Boren9599b0f2018-04-17 15:55:57 -04001034 task.Expiration = 20 * time.Hour
Eric Boren9599b0f2018-04-17 15:55:57 -04001035 task.MaxAttempts = 1
Eric Boren5cb5c742018-04-27 13:14:38 -04001036 timeout(task, 4*time.Hour)
Eric Boren4b254b92016-11-08 12:55:32 -05001037 if strings.Contains(parts["extra_config"], "Valgrind") {
Eric Boren5cb5c742018-04-27 13:14:38 -04001038 timeout(task, 9*time.Hour)
Eric Boren9599b0f2018-04-17 15:55:57 -04001039 task.Expiration = 48 * time.Hour
Eric Boren9599b0f2018-04-17 15:55:57 -04001040 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind"))
1041 task.Dimensions = append(task.Dimensions, "valgrind:1")
Eric Boren4b254b92016-11-08 12:55:32 -05001042 } else if strings.Contains(parts["extra_config"], "MSAN") {
Eric Boren5cb5c742018-04-27 13:14:38 -04001043 timeout(task, 9*time.Hour)
Ben Wagnera6b2ba22017-06-08 10:34:17 -04001044 } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" {
1045 // skia:6737
Eric Boren5cb5c742018-04-27 13:14:38 -04001046 timeout(task, 6*time.Hour)
Eric Boren4b254b92016-11-08 12:55:32 -05001047 }
Eric Boren9599b0f2018-04-17 15:55:57 -04001048 b.MustAddTask(name, task)
Eric Boren4b254b92016-11-08 12:55:32 -05001049
Kevin Lubickc795a4c2017-10-09 15:26:19 -04001050 // Upload results if necessary. TODO(kjlubick): If we do coverage analysis at the same
1051 // time as normal tests (which would be nice), cfg.json needs to have Coverage removed.
borenetdb182c72016-09-30 12:53:12 -07001052 if doUpload(name) {
1053 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
Eric Boren9599b0f2018-04-17 15:55:57 -04001054 extraProps := map[string]string{
1055 "gs_bucket": CONFIG.GsBucketGm,
1056 }
Ben Wagnere99a4b12018-05-04 11:18:01 -04001057 uploadTask := kitchenTask(name, "upload_dm_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_GM, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE)
Eric Boren9599b0f2018-04-17 15:55:57 -04001058 uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...)
1059 uploadTask.Dependencies = append(uploadTask.Dependencies, name)
1060 b.MustAddTask(uploadName, uploadTask)
borenetdb182c72016-09-30 12:53:12 -07001061 return uploadName
Kevin Lubick32f318b2017-10-17 13:40:52 -04001062 }
1063
1064 return name
1065}
1066
1067func coverage(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
1068 shards := 1
1069 deps := []string{}
1070
1071 tf := parts["test_filter"]
1072 if strings.Contains(tf, "Shard") {
1073 // Expected Shard_NN
1074 shardstr := strings.Split(tf, "_")[1]
1075 var err error
1076 shards, err = strconv.Atoi(shardstr)
1077 if err != nil {
1078 glog.Fatalf("Expected int for number of shards %q in %s: %s", shardstr, name, err)
1079 }
1080 }
1081 for i := 0; i < shards; i++ {
1082 n := strings.Replace(name, tf, fmt.Sprintf("shard_%02d_%02d", i, shards), 1)
Eric Boren9599b0f2018-04-17 15:55:57 -04001083 task := kitchenTask(n, "test", "test_skia_bundled.isolate", "", swarmDimensions(parts), nil, OUTPUT_COVERAGE)
1084 task.CipdPackages = append(task.CipdPackages, pkgs...)
1085 task.Dependencies = append(task.Dependencies, compileTaskName)
Eric Boren5cb5c742018-04-27 13:14:38 -04001086
Eric Boren9599b0f2018-04-17 15:55:57 -04001087 task.Expiration = 20 * time.Hour
Eric Boren9599b0f2018-04-17 15:55:57 -04001088 task.MaxAttempts = 1
Eric Boren5cb5c742018-04-27 13:14:38 -04001089 timeout(task, 4*time.Hour)
Eric Borenbd2e1f12018-04-17 11:28:46 +00001090 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
Eric Boren9599b0f2018-04-17 15:55:57 -04001091 task.Dependencies = append(task.Dependencies, deps...)
Eric Borenbd2e1f12018-04-17 11:28:46 +00001092 }
Eric Boren9599b0f2018-04-17 15:55:57 -04001093 b.MustAddTask(n, task)
Kevin Lubick32f318b2017-10-17 13:40:52 -04001094 deps = append(deps, n)
borenetdb182c72016-09-30 12:53:12 -07001095 }
Kevin Lubickc795a4c2017-10-09 15:26:19 -04001096
Kevin Lubick32f318b2017-10-17 13:40:52 -04001097 uploadName := fmt.Sprintf("%s%s%s", "Upload", jobNameSchema.Sep, name)
Eric Boren9599b0f2018-04-17 15:55:57 -04001098 extraProps := map[string]string{
1099 "gs_bucket": CONFIG.GsBucketCoverage,
1100 }
Ben Wagner27d5a362018-05-09 15:37:34 -04001101 // Use MACHINE_TYPE_LARGE because this does a bunch of computation before upload.
1102 uploadTask := kitchenTask(uploadName, "upload_coverage_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_COVERAGE, linuxGceDimensions(MACHINE_TYPE_LARGE), extraProps, OUTPUT_NONE)
Eric Boren5cb5c742018-04-27 13:14:38 -04001103 usesGit(uploadTask, uploadName)
Eric Boren9599b0f2018-04-17 15:55:57 -04001104 uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...)
Kevin Lubick32f318b2017-10-17 13:40:52 -04001105 // We need clang_linux to get access to the llvm-profdata and llvm-cov binaries
1106 // which are used to deal with the raw coverage data output by the Test step.
Eric Boren9599b0f2018-04-17 15:55:57 -04001107 uploadTask.CipdPackages = append(uploadTask.CipdPackages, b.MustGetCipdPackageFromAsset("clang_linux"))
1108 uploadTask.CipdPackages = append(uploadTask.CipdPackages, pkgs...)
1109 // A dependency on compileTaskName makes the TaskScheduler link the
1110 // isolated output of the compile step to the input of the upload step,
1111 // which gives us access to the instrumented binary. The binary is
1112 // needed to figure out symbol names and line numbers.
1113 uploadTask.Dependencies = append(uploadTask.Dependencies, compileTaskName)
1114 uploadTask.Dependencies = append(uploadTask.Dependencies, deps...)
1115 b.MustAddTask(uploadName, uploadTask)
Kevin Lubick32f318b2017-10-17 13:40:52 -04001116 return uploadName
borenetdb182c72016-09-30 12:53:12 -07001117}
1118
1119// perf generates a Perf task. Returns the name of the last task in the
1120// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -07001121func perf(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Eric Boren768f52f2017-04-10 08:14:33 -04001122 recipe := "perf"
Eric Boren9599b0f2018-04-17 15:55:57 -04001123 isolate := relpath("perf_skia_bundled.isolate")
Kevin Lubickb03b5ac2016-11-14 13:42:27 -05001124 if strings.Contains(parts["extra_config"], "Skpbench") {
Eric Boren768f52f2017-04-10 08:14:33 -04001125 recipe = "skpbench"
Eric Boren9599b0f2018-04-17 15:55:57 -04001126 isolate = relpath("skpbench_skia_bundled.isolate")
Kevin Lubickb03b5ac2016-11-14 13:42:27 -05001127 }
Eric Boren9599b0f2018-04-17 15:55:57 -04001128 task := kitchenTask(name, recipe, isolate, "", swarmDimensions(parts), nil, OUTPUT_PERF)
1129 task.CipdPackages = append(task.CipdPackages, pkgs...)
1130 task.Dependencies = append(task.Dependencies, compileTaskName)
Eric Boren9599b0f2018-04-17 15:55:57 -04001131 task.Expiration = 20 * time.Hour
Eric Boren9599b0f2018-04-17 15:55:57 -04001132 task.MaxAttempts = 1
Eric Boren5cb5c742018-04-27 13:14:38 -04001133 timeout(task, 4*time.Hour)
Kevin Lubick90189522017-05-15 08:30:27 -04001134 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
Eric Boren9599b0f2018-04-17 15:55:57 -04001135 task.Dependencies = append(task.Dependencies, deps...)
Kevin Lubick90189522017-05-15 08:30:27 -04001136 }
1137
Eric Boren4b254b92016-11-08 12:55:32 -05001138 if strings.Contains(parts["extra_config"], "Valgrind") {
Eric Boren5cb5c742018-04-27 13:14:38 -04001139 timeout(task, 9*time.Hour)
Eric Boren9599b0f2018-04-17 15:55:57 -04001140 task.Expiration = 48 * time.Hour
Eric Boren9599b0f2018-04-17 15:55:57 -04001141 task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind"))
1142 task.Dimensions = append(task.Dimensions, "valgrind:1")
Eric Boren4b254b92016-11-08 12:55:32 -05001143 } else if strings.Contains(parts["extra_config"], "MSAN") {
Eric Boren5cb5c742018-04-27 13:14:38 -04001144 timeout(task, 9*time.Hour)
Ben Wagnera6b2ba22017-06-08 10:34:17 -04001145 } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" {
1146 // skia:6737
Eric Boren5cb5c742018-04-27 13:14:38 -04001147 timeout(task, 6*time.Hour)
Eric Boren4b254b92016-11-08 12:55:32 -05001148 }
Eric Borenfd4d60e2017-09-15 10:35:44 -04001149 iid := internalHardwareLabel(parts)
Eric Boren053d7a42017-09-15 08:35:31 -04001150 if iid != nil {
Eric Boren9599b0f2018-04-17 15:55:57 -04001151 task.Command = append(task.Command, fmt.Sprintf("internal_hardware_label=%d", *iid))
Eric Boren053d7a42017-09-15 08:35:31 -04001152 }
Eric Boren9599b0f2018-04-17 15:55:57 -04001153 b.MustAddTask(name, task)
Eric Boren4b254b92016-11-08 12:55:32 -05001154
borenetdb182c72016-09-30 12:53:12 -07001155 // Upload results if necessary.
1156 if strings.Contains(name, "Release") && doUpload(name) {
1157 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
Eric Boren9599b0f2018-04-17 15:55:57 -04001158 extraProps := map[string]string{
1159 "gs_bucket": CONFIG.GsBucketNano,
1160 }
Ben Wagnere99a4b12018-05-04 11:18:01 -04001161 uploadTask := kitchenTask(name, "upload_nano_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_NANO, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE)
Eric Boren9599b0f2018-04-17 15:55:57 -04001162 uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...)
1163 uploadTask.Dependencies = append(uploadTask.Dependencies, name)
1164 b.MustAddTask(uploadName, uploadTask)
borenetdb182c72016-09-30 12:53:12 -07001165 return uploadName
1166 }
1167 return name
1168}
1169
Eric Borenb66099b2018-04-25 15:09:22 -04001170// Run the presubmit.
1171func presubmit(b *specs.TasksCfgBuilder, name string) string {
1172 extraProps := map[string]string{
1173 "category": "cq",
1174 "patch_gerrit_url": "https://skia-review.googlesource.com",
1175 "patch_project": "skia",
Eric Boren2f62de02018-05-03 09:56:48 -04001176 "patch_ref": specs.PLACEHOLDER_PATCH_REF,
Eric Borenb66099b2018-04-25 15:09:22 -04001177 "reason": "CQ",
1178 "repo_name": "skia",
1179 }
Ben Wagner297e86b2018-05-14 12:38:09 -04001180 // Use MACHINE_TYPE_LARGE because it seems to save time versus MEDIUM and we want presubmit to be
1181 // fast.
Ben Wagnere99a4b12018-05-04 11:18:01 -04001182 task := kitchenTask(name, "run_presubmit", "empty.isolate", SERVICE_ACCOUNT_COMPILE, linuxGceDimensions(MACHINE_TYPE_LARGE), extraProps, OUTPUT_NONE)
Eric Borenb66099b2018-04-25 15:09:22 -04001183
1184 replaceArg := func(key, value string) {
1185 found := false
1186 for idx, arg := range task.Command {
1187 if arg == key {
1188 task.Command[idx+1] = value
1189 found = true
1190 }
1191 }
1192 if !found {
1193 task.Command = append(task.Command, key, value)
1194 }
1195 }
1196 replaceArg("-repository", "https://chromium.googlesource.com/chromium/tools/build")
1197 replaceArg("-revision", "HEAD")
Eric Boren5cb5c742018-04-27 13:14:38 -04001198 usesGit(task, name)
Eric Borenb66099b2018-04-25 15:09:22 -04001199 task.Dependencies = []string{} // No bundled recipes for this one.
1200 b.MustAddTask(name, task)
1201 return name
1202}
1203
borenetdb182c72016-09-30 12:53:12 -07001204// process generates tasks and jobs for the given job name.
boreneted20a702016-10-20 11:04:31 -07001205func process(b *specs.TasksCfgBuilder, name string) {
Ben Wagnerc062b6b2018-07-24 17:10:46 -04001206 var priority float64 // Leave as default for most jobs.
borenetdb182c72016-09-30 12:53:12 -07001207 deps := []string{}
1208
Eric Boren8b3f9e62017-04-04 09:06:16 -04001209 // Bundle Recipes.
1210 if name == BUNDLE_RECIPES_NAME {
1211 deps = append(deps, bundleRecipes(b))
1212 }
1213
Kevin Lubick07072942017-05-11 13:35:23 -04001214 // Isolate CIPD assets.
Kevin Lubick07072942017-05-11 13:35:23 -04001215 if _, ok := ISOLATE_ASSET_MAPPING[name]; ok {
1216 deps = append(deps, isolateCIPDAsset(b, name))
1217 }
1218
borenetdb182c72016-09-30 12:53:12 -07001219 parts, err := jobNameSchema.ParseJobName(name)
1220 if err != nil {
1221 glog.Fatal(err)
1222 }
1223
1224 // RecreateSKPs.
1225 if strings.Contains(name, "RecreateSKPs") {
Eric Boren27688612018-04-16 13:21:01 +00001226 deps = append(deps, recreateSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -07001227 }
1228
borenet2dbbfa52016-10-14 06:32:09 -07001229 // Infra tests.
1230 if name == "Housekeeper-PerCommit-InfraTests" {
Eric Boren27688612018-04-16 13:21:01 +00001231 deps = append(deps, infra(b, name))
borenet2dbbfa52016-10-14 06:32:09 -07001232 }
1233
borenetdb182c72016-09-30 12:53:12 -07001234 // Compile bots.
1235 if parts["role"] == "Build" {
Ravi Mistry5e967422018-02-01 13:38:13 -05001236 if parts["extra_config"] == "Android_Framework" {
1237 // Android Framework compile tasks use a different recipe.
1238 deps = append(deps, androidFrameworkCompile(b, name))
1239 } else {
1240 deps = append(deps, compile(b, name, parts))
1241 }
borenetdb182c72016-09-30 12:53:12 -07001242 }
1243
Eric Borenf5a90e82016-11-15 15:18:20 -05001244 // Most remaining bots need a compile task.
borenetdb182c72016-09-30 12:53:12 -07001245 compileTaskName := deriveCompileTaskName(name, parts)
borenet52383432016-10-17 10:17:53 -07001246 compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName)
1247 if err != nil {
1248 glog.Fatal(err)
1249 }
Yuqian Li4a577af2018-01-05 11:13:43 -05001250 compileParentName := getParentRevisionName(compileTaskName, compileTaskParts)
1251 compileParentParts, err := jobNameSchema.ParseJobName(compileParentName)
1252 if err != nil {
1253 glog.Fatal(err)
1254 }
1255
Eric Boren628e78b2016-11-17 11:33:27 -05001256 // These bots do not need a compile task.
Yuqian Li4a577af2018-01-05 11:13:43 -05001257 if parts["role"] != "Build" &&
Eric Borenb8ab7f72017-04-10 11:00:09 -04001258 name != "Housekeeper-PerCommit-BundleRecipes" &&
Eric Borenf5a90e82016-11-15 15:18:20 -05001259 name != "Housekeeper-PerCommit-InfraTests" &&
Eric Borenf7928b42017-07-28 07:35:28 -04001260 name != "Housekeeper-PerCommit-CheckGeneratedFiles" &&
Eric Borenb66099b2018-04-25 15:09:22 -04001261 name != "Housekeeper-OnDemand-Presubmit" &&
Ravi Mistry5e967422018-02-01 13:38:13 -05001262 !strings.Contains(name, "Android_Framework") &&
Eric Boren71b762f2016-11-30 14:05:16 -05001263 !strings.Contains(name, "RecreateSKPs") &&
Ben Wagner50b84682017-06-12 13:03:29 -04001264 !strings.Contains(name, "-CT_") &&
1265 !strings.Contains(name, "Housekeeper-PerCommit-Isolate") {
boreneted20a702016-10-20 11:04:31 -07001266 compile(b, compileTaskName, compileTaskParts)
Ben Wagner4c39c0d2018-01-10 11:14:52 -05001267 if parts["role"] == "Calmbench" {
Yuqian Li4a577af2018-01-05 11:13:43 -05001268 compile(b, compileParentName, compileParentParts)
1269 }
borenet52383432016-10-17 10:17:53 -07001270 }
borenetdb182c72016-09-30 12:53:12 -07001271
Eric Borene8b38ab2018-06-08 12:37:53 -04001272 // CT bots.
1273 if strings.Contains(name, "-CT_") {
1274 deps = append(deps, ctSKPs(b, name, compileTaskName))
1275 }
1276
Eric Borenf7928b42017-07-28 07:35:28 -04001277 // Housekeepers.
Eric Boren22f5ef72016-12-02 11:01:33 -05001278 if name == "Housekeeper-PerCommit" {
Eric Boren27688612018-04-16 13:21:01 +00001279 deps = append(deps, housekeeper(b, name, compileTaskName))
borenetdb182c72016-09-30 12:53:12 -07001280 }
Eric Borenf7928b42017-07-28 07:35:28 -04001281 if name == "Housekeeper-PerCommit-CheckGeneratedFiles" {
Eric Boren27688612018-04-16 13:21:01 +00001282 deps = append(deps, checkGeneratedFiles(b, name))
Eric Borenf7928b42017-07-28 07:35:28 -04001283 }
Eric Borenb66099b2018-04-25 15:09:22 -04001284 if name == "Housekeeper-OnDemand-Presubmit" {
Ben Wagnerc062b6b2018-07-24 17:10:46 -04001285 priority = 1
Eric Borenb66099b2018-04-25 15:09:22 -04001286 deps = append(deps, presubmit(b, name))
1287 }
Ravi Mistryd4731e92018-01-02 14:54:43 -05001288 if strings.Contains(name, "Bookmaker") {
Ravi Mistryedc4f3e2017-12-08 12:58:20 -05001289 deps = append(deps, bookmaker(b, name, compileTaskName))
1290 }
borenetdb182c72016-09-30 12:53:12 -07001291
1292 // Common assets needed by the remaining bots.
Kevin Lubick07072942017-05-11 13:35:23 -04001293
1294 pkgs := []*specs.CipdPackage{}
1295
Kevin Lubick90189522017-05-15 08:30:27 -04001296 if deps := getIsolatedCIPDDeps(parts); len(deps) == 0 {
Kevin Lubick07072942017-05-11 13:35:23 -04001297 pkgs = []*specs.CipdPackage{
1298 b.MustGetCipdPackageFromAsset("skimage"),
1299 b.MustGetCipdPackageFromAsset("skp"),
1300 b.MustGetCipdPackageFromAsset("svg"),
1301 }
borenetdb182c72016-09-30 12:53:12 -07001302 }
Kevin Lubick90189522017-05-15 08:30:27 -04001303
Ben Wagner5655ba42017-10-02 10:48:32 -04001304 if strings.Contains(name, "Ubuntu") || strings.Contains(name, "Debian") {
1305 if strings.Contains(name, "SAN") {
1306 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
1307 }
Kevin Lubick35115eb2017-02-17 10:25:34 -05001308 if strings.Contains(name, "Vulkan") {
1309 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
1310 }
Ben Wagner5655ba42017-10-02 10:48:32 -04001311 if strings.Contains(name, "Intel") && strings.Contains(name, "GPU") {
1312 if strings.Contains(name, "Release") {
1313 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_release"))
1314 } else {
1315 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_debug"))
1316 }
Kevin Lubick0a51b482017-02-06 12:45:29 -05001317 }
Ben Wagnera5e70302018-06-28 17:43:08 -04001318 if strings.Contains(name, "OpenCL") {
1319 pkgs = append(pkgs,
1320 b.MustGetCipdPackageFromAsset("opencl_ocl_icd_linux"),
1321 b.MustGetCipdPackageFromAsset("opencl_intel_neo_linux"),
1322 )
1323 }
Kevin Lubick0a51b482017-02-06 12:45:29 -05001324 }
Ben Wagner299b8822018-03-09 13:42:56 -05001325 if strings.Contains(name, "ProcDump") {
1326 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("procdump_win"))
1327 }
borenetdb182c72016-09-30 12:53:12 -07001328
1329 // Test bots.
Kevin Lubick32f318b2017-10-17 13:40:52 -04001330 if parts["role"] == "Test" {
1331 if strings.Contains(parts["extra_config"], "Coverage") {
1332 deps = append(deps, coverage(b, name, parts, compileTaskName, pkgs))
1333 } else if !strings.Contains(name, "-CT_") {
1334 deps = append(deps, test(b, name, parts, compileTaskName, pkgs))
1335 }
1336
borenetdb182c72016-09-30 12:53:12 -07001337 }
1338
1339 // Perf bots.
Eric Boren71b762f2016-11-30 14:05:16 -05001340 if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -07001341 deps = append(deps, perf(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -07001342 }
1343
Yuqian Li4a577af2018-01-05 11:13:43 -05001344 // Calmbench bots.
1345 if parts["role"] == "Calmbench" {
1346 deps = append(deps, calmbench(b, name, parts, compileTaskName, compileParentName))
1347 }
1348
borenetdb182c72016-09-30 12:53:12 -07001349 // Add the Job spec.
Eric Borenf5a90e82016-11-15 15:18:20 -05001350 j := &specs.JobSpec{
Ben Wagnerc062b6b2018-07-24 17:10:46 -04001351 Priority: priority,
borenetdb182c72016-09-30 12:53:12 -07001352 TaskSpecs: deps,
Eric Borenba937a42017-07-31 10:41:15 -04001353 Trigger: specs.TRIGGER_ANY_BRANCH,
Eric Borenf5a90e82016-11-15 15:18:20 -05001354 }
Eric Borenba937a42017-07-31 10:41:15 -04001355 if strings.Contains(name, "-Nightly-") {
1356 j.Trigger = specs.TRIGGER_NIGHTLY
Ravi Mistryf06dae82017-10-16 10:31:41 -04001357 } else if strings.Contains(name, "-Weekly-") || strings.Contains(name, "CT_DM_1m_SKPs") {
Eric Borenba937a42017-07-31 10:41:15 -04001358 j.Trigger = specs.TRIGGER_WEEKLY
Eric Boren44a68b32018-05-04 08:59:16 -04001359 } else if strings.Contains(name, "Flutter") || strings.Contains(name, "CommandBuffer") {
Eric Borenba937a42017-07-31 10:41:15 -04001360 j.Trigger = specs.TRIGGER_MASTER_ONLY
Eric Boren1178ea02018-04-26 08:58:26 -04001361 } else if strings.Contains(name, "-OnDemand-") || strings.Contains(name, "Android_Framework") {
Eric Borenb66099b2018-04-25 15:09:22 -04001362 j.Trigger = specs.TRIGGER_ON_DEMAND
Eric Boren71b762f2016-11-30 14:05:16 -05001363 }
Eric Boren8615fe52016-12-12 14:30:12 -05001364 b.MustAddJob(name, j)
borenetdb182c72016-09-30 12:53:12 -07001365}
1366
Eric Boren27225492017-02-01 15:56:55 -05001367func loadJson(flag *string, defaultFlag string, val interface{}) {
1368 if *flag == "" {
1369 *flag = defaultFlag
1370 }
1371 b, err := ioutil.ReadFile(*flag)
1372 if err != nil {
1373 glog.Fatal(err)
1374 }
1375 if err := json.Unmarshal(b, val); err != nil {
1376 glog.Fatal(err)
1377 }
1378}
1379
borenetdb182c72016-09-30 12:53:12 -07001380// Regenerate the tasks.json file.
1381func main() {
boreneted20a702016-10-20 11:04:31 -07001382 b := specs.MustNewTasksCfgBuilder()
Eric Boren27225492017-02-01 15:56:55 -05001383 b.SetAssetsDir(*assetsDir)
1384 infraBots := path.Join(b.CheckoutRoot(), "infra", "bots")
1385
1386 // Load the jobs from a JSON file.
1387 loadJson(jobsFile, path.Join(infraBots, "jobs.json"), &JOBS)
1388
Eric Boren27225492017-02-01 15:56:55 -05001389 // Load general config information from a JSON file.
1390 loadJson(cfgFile, path.Join(infraBots, "cfg.json"), &CONFIG)
1391
borenetdb182c72016-09-30 12:53:12 -07001392 // Create the JobNameSchema.
Eric Boren1f8be682017-02-07 09:16:30 -05001393 if *builderNameSchemaFile == "" {
1394 *builderNameSchemaFile = path.Join(b.CheckoutRoot(), "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json")
1395 }
1396 schema, err := NewJobNameSchema(*builderNameSchemaFile)
borenetdb182c72016-09-30 12:53:12 -07001397 if err != nil {
1398 glog.Fatal(err)
1399 }
1400 jobNameSchema = schema
1401
borenetdb182c72016-09-30 12:53:12 -07001402 // Create Tasks and Jobs.
boreneted20a702016-10-20 11:04:31 -07001403 for _, name := range JOBS {
1404 process(b, name)
borenetdb182c72016-09-30 12:53:12 -07001405 }
1406
boreneted20a702016-10-20 11:04:31 -07001407 b.MustFinish()
borenetdb182c72016-09-30 12:53:12 -07001408}
1409
1410// TODO(borenet): The below really belongs in its own file, probably next to the
1411// builder_name_schema.json file.
1412
Eric Boren8ff86a62018-04-17 14:11:23 -04001413// schema is a sub-struct of JobNameSchema.
1414type schema struct {
1415 Keys []string `json:"keys"`
1416 OptionalKeys []string `json:"optional_keys"`
1417 RecurseRoles []string `json:"recurse_roles"`
1418}
1419
borenetdb182c72016-09-30 12:53:12 -07001420// JobNameSchema is a struct used for (de)constructing Job names in a
1421// predictable format.
1422type JobNameSchema struct {
Eric Boren8ff86a62018-04-17 14:11:23 -04001423 Schema map[string]*schema `json:"builder_name_schema"`
1424 Sep string `json:"builder_name_sep"`
borenetdb182c72016-09-30 12:53:12 -07001425}
1426
1427// NewJobNameSchema returns a JobNameSchema instance based on the given JSON
1428// file.
1429func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) {
1430 var rv JobNameSchema
1431 f, err := os.Open(jsonFile)
1432 if err != nil {
1433 return nil, err
1434 }
1435 defer util.Close(f)
1436 if err := json.NewDecoder(f).Decode(&rv); err != nil {
1437 return nil, err
1438 }
1439 return &rv, nil
1440}
1441
1442// ParseJobName splits the given Job name into its component parts, according
1443// to the schema.
1444func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) {
Eric Boren8ff86a62018-04-17 14:11:23 -04001445 popFront := func(items []string) (string, []string, error) {
1446 if len(items) == 0 {
1447 return "", nil, fmt.Errorf("Invalid job name: %s (not enough parts)", n)
1448 }
1449 return items[0], items[1:], nil
1450 }
1451
1452 result := map[string]string{}
1453
1454 var parse func(int, string, []string) ([]string, error)
1455 parse = func(depth int, role string, parts []string) ([]string, error) {
1456 s, ok := s.Schema[role]
1457 if !ok {
1458 return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role)
1459 }
1460 if depth == 0 {
1461 result["role"] = role
1462 } else {
1463 result[fmt.Sprintf("sub-role-%d", depth)] = role
1464 }
1465 var err error
1466 for _, key := range s.Keys {
1467 var value string
1468 value, parts, err = popFront(parts)
1469 if err != nil {
1470 return nil, err
1471 }
1472 result[key] = value
1473 }
1474 for _, subRole := range s.RecurseRoles {
1475 if len(parts) > 0 && parts[0] == subRole {
1476 parts, err = parse(depth+1, parts[0], parts[1:])
1477 if err != nil {
1478 return nil, err
1479 }
1480 }
1481 }
1482 for _, key := range s.OptionalKeys {
1483 if len(parts) > 0 {
1484 var value string
1485 value, parts, err = popFront(parts)
1486 if err != nil {
1487 return nil, err
1488 }
1489 result[key] = value
1490 }
1491 }
1492 if len(parts) > 0 {
1493 return nil, fmt.Errorf("Invalid job name: %s (too many parts)", n)
1494 }
1495 return parts, nil
1496 }
1497
borenetdb182c72016-09-30 12:53:12 -07001498 split := strings.Split(n, s.Sep)
1499 if len(split) < 2 {
Eric Boren8ff86a62018-04-17 14:11:23 -04001500 return nil, fmt.Errorf("Invalid job name: %s (not enough parts)", n)
borenetdb182c72016-09-30 12:53:12 -07001501 }
1502 role := split[0]
1503 split = split[1:]
Eric Boren8ff86a62018-04-17 14:11:23 -04001504 _, err := parse(0, role, split)
1505 return result, err
borenetdb182c72016-09-30 12:53:12 -07001506}
1507
1508// MakeJobName assembles the given parts of a Job name, according to the schema.
1509func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) {
borenetdb182c72016-09-30 12:53:12 -07001510 rvParts := make([]string, 0, len(parts))
Eric Boren8ff86a62018-04-17 14:11:23 -04001511
1512 var process func(int, map[string]string) (map[string]string, error)
1513 process = func(depth int, parts map[string]string) (map[string]string, error) {
1514 roleKey := "role"
1515 if depth != 0 {
1516 roleKey = fmt.Sprintf("sub-role-%d", depth)
borenetdb182c72016-09-30 12:53:12 -07001517 }
Eric Boren8ff86a62018-04-17 14:11:23 -04001518 role, ok := parts[roleKey]
1519 if !ok {
1520 return nil, fmt.Errorf("Invalid job parts; missing key %q", roleKey)
1521 }
1522
1523 s, ok := s.Schema[role]
1524 if !ok {
1525 return nil, fmt.Errorf("Invalid job parts; unknown role %q", role)
1526 }
1527 rvParts = append(rvParts, role)
1528 delete(parts, roleKey)
1529
1530 for _, key := range s.Keys {
1531 value, ok := parts[key]
1532 if !ok {
1533 return nil, fmt.Errorf("Invalid job parts; missing %q", key)
1534 }
1535 rvParts = append(rvParts, value)
1536 delete(parts, key)
1537 }
1538
1539 if len(s.RecurseRoles) > 0 {
1540 subRoleKey := fmt.Sprintf("sub-role-%d", depth+1)
1541 subRole, ok := parts[subRoleKey]
1542 if !ok {
1543 return nil, fmt.Errorf("Invalid job parts; missing %q", subRoleKey)
1544 }
1545 rvParts = append(rvParts, subRole)
1546 delete(parts, subRoleKey)
1547 found := false
1548 for _, recurseRole := range s.RecurseRoles {
1549 if recurseRole == subRole {
1550 found = true
1551 var err error
1552 parts, err = process(depth+1, parts)
1553 if err != nil {
1554 return nil, err
1555 }
1556 break
1557 }
1558 }
1559 if !found {
1560 return nil, fmt.Errorf("Invalid job parts; unknown sub-role %q", subRole)
1561 }
1562 }
1563 for _, key := range s.OptionalKeys {
1564 if value, ok := parts[key]; ok {
1565 rvParts = append(rvParts, value)
1566 delete(parts, key)
1567 }
1568 }
1569 if len(parts) > 0 {
1570 return nil, fmt.Errorf("Invalid job parts: too many parts: %v", parts)
1571 }
1572 return parts, nil
borenetdb182c72016-09-30 12:53:12 -07001573 }
Eric Boren8ff86a62018-04-17 14:11:23 -04001574
1575 // Copy the parts map, so that we can modify at will.
1576 partsCpy := make(map[string]string, len(parts))
1577 for k, v := range parts {
1578 partsCpy[k] = v
1579 }
1580 if _, err := process(0, partsCpy); err != nil {
1581 return "", err
borenetdb182c72016-09-30 12:53:12 -07001582 }
1583 return strings.Join(rvParts, s.Sep), nil
1584}