blob: c43689a2fea57f8b47c0a6d0738d6867cea32e6a [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 Boren27225492017-02-01 15:56:55 -050018 "regexp"
borenetdb182c72016-09-30 12:53:12 -070019 "sort"
20 "strings"
Eric Boren4b254b92016-11-08 12:55:32 -050021 "time"
borenetdb182c72016-09-30 12:53:12 -070022
23 "github.com/skia-dev/glog"
borenetdb182c72016-09-30 12:53:12 -070024 "go.skia.org/infra/go/util"
25 "go.skia.org/infra/task_scheduler/go/specs"
26)
27
28const (
Kevin Lubick07072942017-05-11 13:35:23 -040029 BUNDLE_RECIPES_NAME = "Housekeeper-PerCommit-BundleRecipes"
30 ISOLATE_SKIMAGE_NAME = "Housekeeper-PerCommit-IsolateSkImage"
31 ISOLATE_SKP_NAME = "Housekeeper-PerCommit-IsolateSKP"
32 ISOLATE_SVG_NAME = "Housekeeper-PerCommit-IsolateSVG"
Eric Boren8b3f9e62017-04-04 09:06:16 -040033
Kevin Lubick797ef162016-12-15 10:45:08 -050034 DEFAULT_OS = DEFAULT_OS_LINUX
35 DEFAULT_OS_LINUX = "Ubuntu-14.04"
borenetdb182c72016-09-30 12:53:12 -070036
borenetdb182c72016-09-30 12:53:12 -070037 // Name prefix for upload jobs.
38 PREFIX_UPLOAD = "Upload"
39)
40
41var (
42 // "Constants"
43
Eric Boren27225492017-02-01 15:56:55 -050044 // Top-level list of all jobs to run at each commit; loaded from
45 // jobs.json.
46 JOBS []string
47
Eric Boren27225492017-02-01 15:56:55 -050048 // General configuration information.
49 CONFIG struct {
Eric Boren965861b2017-02-06 15:38:41 -050050 GsBucketGm string `json:"gs_bucket_gm"`
51 GsBucketNano string `json:"gs_bucket_nano"`
52 NoUpload []string `json:"no_upload"`
53 Pool string `json:"pool"`
borenetdb182c72016-09-30 12:53:12 -070054 }
55
Ben Wagner3d2a2f72017-06-13 17:01:16 -040056 // alternateSwarmDimensions can be set in an init function to override the default swarming bot
57 // dimensions for the given task.
58 alternateSwarmDimensions func(parts map[string]string) []string
59
borenetdb182c72016-09-30 12:53:12 -070060 // Defines the structure of job names.
61 jobNameSchema *JobNameSchema
Eric Boren27225492017-02-01 15:56:55 -050062
Eric Borenf4a5fc72017-06-06 08:27:09 -040063 // Git 2.13.
64 cipdGit1 = &specs.CipdPackage{
65 Name: fmt.Sprintf("infra/git/${platform}"),
66 Path: "git",
67 Version: fmt.Sprintf("version:2.13.0.chromium9"),
68 }
69 cipdGit2 = &specs.CipdPackage{
70 Name: fmt.Sprintf("infra/tools/git/${platform}"),
71 Path: "git",
72 Version: fmt.Sprintf("git_revision:a78b5f3658c0578a017db48df97d20ac09822bcd"),
73 }
74
Eric Boren27225492017-02-01 15:56:55 -050075 // Flags.
Eric Boren1f8be682017-02-07 09:16:30 -050076 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.")
77 assetsDir = flag.String("assets_dir", "", "Directory containing assets.")
78 cfgFile = flag.String("cfg_file", "", "JSON file containing general configuration information.")
Eric Boren1f8be682017-02-07 09:16:30 -050079 jobsFile = flag.String("jobs", "", "JSON file containing jobs to run.")
borenetdb182c72016-09-30 12:53:12 -070080)
81
Eric Boren27225492017-02-01 15:56:55 -050082// linuxGceDimensions are the Swarming dimensions for Linux GCE
83// instances.
84func linuxGceDimensions() []string {
85 return []string{
86 "cpu:x86-64-avx2",
87 "gpu:none",
88 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX),
89 fmt.Sprintf("pool:%s", CONFIG.Pool),
90 }
91}
92
borenetdb182c72016-09-30 12:53:12 -070093// deriveCompileTaskName returns the name of a compile task based on the given
94// job name.
95func deriveCompileTaskName(jobName string, parts map[string]string) string {
96 if parts["role"] == "Housekeeper" {
97 return "Build-Ubuntu-GCC-x86_64-Release-Shared"
98 } else if parts["role"] == "Test" || parts["role"] == "Perf" {
99 task_os := parts["os"]
Ben Wagner988d15e2017-04-27 13:08:50 -0400100 ec := []string{}
101 if val := parts["extra_config"]; val != "" {
102 ec = strings.Split(val, "_")
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400103 ignore := []string{"Skpbench", "AbandonGpuContext", "PreAbandonGpuContext", "Valgrind", "ReleaseAndAbandonGpuContext"}
Ben Wagner988d15e2017-04-27 13:08:50 -0400104 keep := make([]string, 0, len(ec))
105 for _, part := range ec {
106 if !util.In(part, ignore) {
107 keep = append(keep, part)
108 }
109 }
110 ec = keep
Eric Boren6ec17e32017-04-26 14:25:29 -0400111 }
borenetdb182c72016-09-30 12:53:12 -0700112 if task_os == "Android" {
Ben Wagner988d15e2017-04-27 13:08:50 -0400113 if !util.In("Android", ec) {
114 ec = append([]string{"Android"}, ec...)
borenetdb182c72016-09-30 12:53:12 -0700115 }
borenet52383432016-10-17 10:17:53 -0700116 task_os = "Ubuntu"
Kevin Lubickdcd2a902017-03-08 14:01:01 -0500117 } else if task_os == "Chromecast" {
118 task_os = "Ubuntu"
Ben Wagner988d15e2017-04-27 13:08:50 -0400119 ec = append([]string{"Chromecast"}, ec...)
Kevin Lubickcb6f3982017-04-07 10:04:08 -0400120 } else if strings.Contains(task_os, "ChromeOS") {
Ben Wagner988d15e2017-04-27 13:08:50 -0400121 ec = append([]string{"Chromebook", "ARM", "GLES"}, ec...)
Kevin Lubick261ea192017-04-05 07:32:45 -0400122 task_os = "Ubuntu"
borenetdb182c72016-09-30 12:53:12 -0700123 } else if task_os == "iOS" {
Ben Wagner988d15e2017-04-27 13:08:50 -0400124 ec = append([]string{task_os}, ec...)
borenetdb182c72016-09-30 12:53:12 -0700125 task_os = "Mac"
126 } else if strings.Contains(task_os, "Win") {
127 task_os = "Win"
Kevin Lubick893c49e2017-01-17 15:15:40 -0500128 } else if strings.Contains(task_os, "Ubuntu") {
129 task_os = "Ubuntu"
borenetdb182c72016-09-30 12:53:12 -0700130 }
Eric Boren50831302016-11-18 13:10:51 -0500131 jobNameMap := map[string]string{
borenetdb182c72016-09-30 12:53:12 -0700132 "role": "Build",
133 "os": task_os,
134 "compiler": parts["compiler"],
135 "target_arch": parts["arch"],
136 "configuration": parts["configuration"],
Eric Boren50831302016-11-18 13:10:51 -0500137 }
Ben Wagner988d15e2017-04-27 13:08:50 -0400138 if len(ec) > 0 {
139 jobNameMap["extra_config"] = strings.Join(ec, "_")
Eric Boren50831302016-11-18 13:10:51 -0500140 }
141 name, err := jobNameSchema.MakeJobName(jobNameMap)
borenetdb182c72016-09-30 12:53:12 -0700142 if err != nil {
143 glog.Fatal(err)
144 }
145 return name
146 } else {
147 return jobName
148 }
149}
150
151// swarmDimensions generates swarming bot dimensions for the given task.
152func swarmDimensions(parts map[string]string) []string {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400153 if alternateSwarmDimensions != nil {
154 return alternateSwarmDimensions(parts)
155 }
156 return defaultSwarmDimensions(parts)
157}
158
159// defaultSwarmDimensions generates default swarming bot dimensions for the given task.
160func defaultSwarmDimensions(parts map[string]string) []string {
borenetdb182c72016-09-30 12:53:12 -0700161 d := map[string]string{
Eric Boren27225492017-02-01 15:56:55 -0500162 "pool": CONFIG.Pool,
borenetdb182c72016-09-30 12:53:12 -0700163 }
164 if os, ok := parts["os"]; ok {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400165 d["os"], ok = map[string]string{
Kevin Lubick291547d2017-03-21 09:25:34 -0400166 "Android": "Android",
167 "Chromecast": "Android",
Kevin Lubickcb6f3982017-04-07 10:04:08 -0400168 "ChromeOS": "ChromeOS",
Kevin Lubick291547d2017-03-21 09:25:34 -0400169 "Mac": "Mac-10.11",
170 "Ubuntu": DEFAULT_OS_LINUX,
171 "Ubuntu16": "Ubuntu-16.10",
172 "Win": "Windows-2008ServerR2-SP1",
Ben Wagner40226b42017-05-02 13:13:13 -0400173 "Win10": "Windows-10-15063",
Kevin Lubick291547d2017-03-21 09:25:34 -0400174 "Win2k8": "Windows-2008ServerR2-SP1",
Ben Wagner56738d82017-04-18 15:38:15 -0400175 "Win7": "Windows-7-SP1",
Kevin Lubick291547d2017-03-21 09:25:34 -0400176 "Win8": "Windows-8.1-SP0",
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400177 "iOS": "iOS-10.3.1",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500178 }[os]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400179 if !ok {
180 glog.Fatalf("Entry %q not found in OS mapping.", os)
181 }
Ben Wagner73557372016-12-29 16:27:03 -0500182 // Chrome Golo has a different Windows image.
183 if parts["model"] == "Golo" && os == "Win10" {
184 d["os"] = "Windows-10-10586"
Ben Wagner17f811b2016-12-22 08:40:14 -0500185 }
borenetdb182c72016-09-30 12:53:12 -0700186 } else {
187 d["os"] = DEFAULT_OS
188 }
borenetdb182c72016-09-30 12:53:12 -0700189 if parts["role"] == "Test" || parts["role"] == "Perf" {
Kevin Lubick291547d2017-03-21 09:25:34 -0400190 if strings.Contains(parts["os"], "Android") || strings.Contains(parts["os"], "Chromecast") {
borenetdb182c72016-09-30 12:53:12 -0700191 // For Android, the device type is a better dimension
192 // than CPU or GPU.
Ben Wagner36682782017-06-14 10:01:45 -0400193 deviceInfo, ok := map[string][]string{
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400194 "AndroidOne": {"sprout", "MOB30Q"},
195 "Chorizo": {"chorizo", "1.24_82923"},
196 "Ci20": {"ci20", "NRD90M"},
197 "GalaxyJ5": {"j5xnlte", "MMB29M"},
198 "GalaxyS6": {"zerofltetmo", "MMB29K"},
199 "GalaxyS7_G930A": {"heroqlteatt", "NRD90M_G930AUCS4BQC2"},
200 "GalaxyS7_G930FD": {"herolte", "NRD90M_G930FXXU1DQAS"},
201 "GalaxyTab3": {"goyawifi", "JDQ39"},
202 "MotoG4": {"athene", "NPJ25.93-14"},
203 "NVIDIA_Shield": {"foster", "NRD90M"},
204 "Nexus10": {"manta", "LMY49J"},
205 "Nexus5": {"hammerhead", "M4B30Z"},
206 "Nexus6": {"shamu", "M"},
207 "Nexus6p": {"angler", "OPP1.170223.012"},
208 "Nexus7": {"grouper", "LMY47V"},
209 "Nexus7v2": {"flo", "M"},
210 "NexusPlayer": {"fugu", "OPP2.170420.017"},
211 "Pixel": {"sailfish", "NMF26Q"},
212 "PixelC": {"dragon", "N2G47D"},
Greg Danielc34aeb72017-06-14 11:09:19 -0400213 "PixelXL": {"marlin", "OPP3.170518.006"},
Ben Wagner36682782017-06-14 10:01:45 -0400214 }[parts["model"]]
Eric Boren27225492017-02-01 15:56:55 -0500215 if !ok {
Ben Wagner36682782017-06-14 10:01:45 -0400216 glog.Fatalf("Entry %q not found in Android mapping.", parts["model"])
Eric Boren27225492017-02-01 15:56:55 -0500217 }
Eric Boren4b254b92016-11-08 12:55:32 -0500218 d["device_type"] = deviceInfo[0]
219 d["device_os"] = deviceInfo[1]
borenetdb182c72016-09-30 12:53:12 -0700220 } else if strings.Contains(parts["os"], "iOS") {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400221 device, ok := map[string]string{
Eric Boren792079cf2016-11-09 14:03:20 -0500222 "iPadMini4": "iPad5,1",
Stephan Altmueller63e843d2017-04-25 11:38:38 -0400223 "iPhone6": "iPhone7,2",
224 "iPhone7": "iPhone9,1",
225 "iPadPro": "iPad6,3",
borenetdb182c72016-09-30 12:53:12 -0700226 }[parts["model"]]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400227 if !ok {
228 glog.Fatalf("Entry %q not found in iOS mapping.", parts["model"])
229 }
230 d["device"] = device
borenetdb182c72016-09-30 12:53:12 -0700231 } else if parts["cpu_or_gpu"] == "CPU" {
232 d["gpu"] = "none"
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400233 cpu, ok := map[string]string{
borenetdb182c72016-09-30 12:53:12 -0700234 "AVX": "x86-64",
235 "AVX2": "x86-64-avx2",
236 "SSE4": "x86-64",
237 }[parts["cpu_or_gpu_value"]]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400238 if !ok {
239 glog.Fatalf("Entry %q not found in CPU mapping.", parts["cpu_or_gpu_value"])
240 }
241 d["cpu"] = cpu
borenetdb182c72016-09-30 12:53:12 -0700242 if strings.Contains(parts["os"], "Win") && parts["cpu_or_gpu_value"] == "AVX2" {
243 // AVX2 is not correctly detected on Windows. Fall back on other
244 // dimensions to ensure that we correctly target machines which we know
245 // have AVX2 support.
Eric Boren085bf7c2017-04-06 17:32:44 +0000246 d["cpu"] = "x86-64"
Ben Wagner56738d82017-04-18 15:38:15 -0400247 if parts["model"] != "GCE" {
248 glog.Fatalf("Please double-check that %q supports AVX2 and update this assertion.", parts["model"])
249 }
borenetdb182c72016-09-30 12:53:12 -0700250 }
251 } else {
Ben Wagner1d060782017-06-14 10:34:18 -0400252 if strings.Contains(parts["os"], "Win") {
253 gpu, ok := map[string]string{
254 "AMDHD7770": "1002:683d-22.19.165.512",
255 "GT610": "10de:104a-21.21.13.7619",
256 "GTX1070": "10de:1ba1-22.21.13.8205",
257 "GTX660": "10de:11c0-22.21.13.8205",
258 "GTX960": "10de:1401-22.21.13.8205",
259 "IntelHD530": "8086:1912-21.20.16.4590",
260 "IntelHD4400": "8086:0a16-20.19.15.4531",
261 "IntelHD4600": "8086:0412-20.19.15.4531",
262 "IntelIris540": "8086:1926-21.20.16.4590",
263 "IntelIris6100": "8086:162b-20.19.15.4531",
264 "RadeonR9M470X": "1002:6646-22.19.165.512",
265 }[parts["cpu_or_gpu_value"]]
266 if !ok {
267 glog.Fatalf("Entry %q not found in Win GPU mapping.", parts["cpu_or_gpu_value"])
268 }
269 d["gpu"] = gpu
Ben Wagner08435892017-02-18 23:28:26 -0500270
Ben Wagner1d060782017-06-14 10:34:18 -0400271 // Hack: Specify machine_type dimension for NUCs and ShuttleCs. We
272 // temporarily have two types of machines with a GTX960. The only way to
273 // distinguish these bots is by machine_type.
274 machine_type, ok := map[string]string{
275 "NUC6i7KYK": "n1-highcpu-8",
276 "ShuttleC": "n1-standard-8",
277 }[parts["model"]]
278 if ok {
279 d["machine_type"] = machine_type
280 }
281 } else if strings.Contains(parts["os"], "Ubuntu") {
282 gpu, ok := map[string]string{
283 "GT610": "10de:104a-340.96",
284 "GTX550Ti": "10de:1244-340.76",
285 "GTX660": "10de:11c0-367.57",
286 "GTX960": "10de:1401-367.57",
287 // Intel drivers come from CIPD, so no need to specify the version here.
288 "IntelBayTrail": "8086:0f31",
289 "IntelHD2000": "8086:0102",
290 "IntelHD405": "8086:22b1",
291 "IntelIris540": "8086:1926",
292 }[parts["cpu_or_gpu_value"]]
293 if !ok {
294 glog.Fatalf("Entry %q not found in Ubuntu GPU mapping.", parts["cpu_or_gpu_value"])
295 }
296 d["gpu"] = gpu
297 } else if strings.Contains(parts["os"], "Mac") {
298 gpu, ok := map[string]string{
299 // TODO(benjaminwagner): GPU name doesn't match device ID.
300 "IntelHD4000": "8086:0a2e",
301 }[parts["cpu_or_gpu_value"]]
302 if !ok {
303 glog.Fatalf("Entry %q not found in Mac GPU mapping.", parts["cpu_or_gpu_value"])
304 }
305 d["gpu"] = gpu
306 } else if strings.Contains(parts["os"], "ChromeOS") {
307 gpu, ok := map[string]string{
308 "MaliT604": "MaliT604",
309 "MaliT764": "MaliT764",
310 "MaliT860": "MaliT860",
311 "TegraK1": "TegraK1",
312 }[parts["cpu_or_gpu_value"]]
313 if !ok {
314 glog.Fatalf("Entry %q not found in ChromeOS GPU mapping.", parts["cpu_or_gpu_value"])
315 }
316 d["gpu"] = gpu
317 } else {
318 glog.Fatalf("Unknown GPU mapping for OS %q.", parts["os"])
Ben Wagner08435892017-02-18 23:28:26 -0500319 }
borenetdb182c72016-09-30 12:53:12 -0700320 }
321 } else {
322 d["gpu"] = "none"
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400323 if d["os"] == DEFAULT_OS_LINUX {
324 return linuxGceDimensions()
325 }
borenetdb182c72016-09-30 12:53:12 -0700326 }
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400327
borenetdb182c72016-09-30 12:53:12 -0700328 rv := make([]string, 0, len(d))
329 for k, v := range d {
330 rv = append(rv, fmt.Sprintf("%s:%s", k, v))
331 }
332 sort.Strings(rv)
333 return rv
334}
335
Eric Boren8b3f9e62017-04-04 09:06:16 -0400336// bundleRecipes generates the task to bundle and isolate the recipes.
337func bundleRecipes(b *specs.TasksCfgBuilder) string {
338 b.MustAddTask(BUNDLE_RECIPES_NAME, &specs.TaskSpec{
Eric Borenf4a5fc72017-06-06 08:27:09 -0400339 CipdPackages: []*specs.CipdPackage{cipdGit1, cipdGit2},
Eric Boren8b3f9e62017-04-04 09:06:16 -0400340 Dimensions: linuxGceDimensions(),
341 ExtraArgs: []string{
342 "--workdir", "../../..", "bundle_recipes",
Eric Boren8b3f9e62017-04-04 09:06:16 -0400343 fmt.Sprintf("buildername=%s", BUNDLE_RECIPES_NAME),
Eric Boren8b3f9e62017-04-04 09:06:16 -0400344 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
Eric Boren8b3f9e62017-04-04 09:06:16 -0400345 },
346 Isolate: "bundle_recipes.isolate",
Kevin Lubick07072942017-05-11 13:35:23 -0400347 Priority: 0.7,
Eric Boren8b3f9e62017-04-04 09:06:16 -0400348 })
349 return BUNDLE_RECIPES_NAME
350}
351
Eric Boren23a6ec62017-04-07 08:31:22 -0400352// useBundledRecipes returns true iff the given bot should use bundled recipes
353// instead of syncing recipe DEPS itself.
354func useBundledRecipes(parts map[string]string) bool {
355 // Use bundled recipes for all test/perf tasks.
356 return true
357}
358
Kevin Lubick07072942017-05-11 13:35:23 -0400359type isolateAssetCfg struct {
360 isolateFile string
361 cipdPkg string
362}
363
364var ISOLATE_ASSET_MAPPING = map[string]isolateAssetCfg{
365 ISOLATE_SKIMAGE_NAME: {
366 isolateFile: "isolate_skimage.isolate",
367 cipdPkg: "skimage",
368 },
369 ISOLATE_SKP_NAME: {
370 isolateFile: "isolate_skp.isolate",
371 cipdPkg: "skp",
372 },
373 ISOLATE_SVG_NAME: {
374 isolateFile: "isolate_svg.isolate",
375 cipdPkg: "svg",
376 },
377}
378
379// bundleRecipes generates the task to bundle and isolate the recipes.
380func isolateCIPDAsset(b *specs.TasksCfgBuilder, name string) string {
381 b.MustAddTask(name, &specs.TaskSpec{
382 CipdPackages: []*specs.CipdPackage{
383 b.MustGetCipdPackageFromAsset(ISOLATE_ASSET_MAPPING[name].cipdPkg),
384 },
385 Dimensions: linuxGceDimensions(),
386 Isolate: ISOLATE_ASSET_MAPPING[name].isolateFile,
387 Priority: 0.7,
388 })
389 return name
390}
391
Kevin Lubick90189522017-05-15 08:30:27 -0400392// getIsolatedCIPDDeps returns the slice of Isolate_* tasks a given task needs.
393// This allows us to save time on I/O bound bots, like the RPIs.
394func getIsolatedCIPDDeps(parts map[string]string) []string {
395 deps := []string{}
Kevin Lubick07072942017-05-11 13:35:23 -0400396 // Only do this on the RPIs for now. Other, faster machines shouldn't see much
397 // benefit and we don't need the extra complexity, for now
Kevin Lubick90189522017-05-15 08:30:27 -0400398 rpiOS := []string{"Android", "ChromeOS", "iOS"}
399
400 if o := parts["os"]; strings.Contains(o, "Chromecast") {
401 // Chromecasts don't have enough disk space to fit all of the content,
402 // so we do a subset of the skps.
403 deps = append(deps, ISOLATE_SKP_NAME)
404 } else if e := parts["extra_config"]; strings.Contains(e, "Skpbench") {
405 // Skpbench only needs skps
406 deps = append(deps, ISOLATE_SKP_NAME)
407 } else if util.In(o, rpiOS) {
408 deps = append(deps, ISOLATE_SKP_NAME)
409 deps = append(deps, ISOLATE_SVG_NAME)
410 deps = append(deps, ISOLATE_SKIMAGE_NAME)
411 }
412
413 return deps
Kevin Lubick07072942017-05-11 13:35:23 -0400414}
415
borenetdb182c72016-09-30 12:53:12 -0700416// compile generates a compile task. Returns the name of the last task in the
417// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700418func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string {
borenetdb182c72016-09-30 12:53:12 -0700419 // Collect the necessary CIPD packages.
420 pkgs := []*specs.CipdPackage{}
421
422 // Android bots require a toolchain.
423 if strings.Contains(name, "Android") {
borenetdb182c72016-09-30 12:53:12 -0700424 if strings.Contains(name, "Mac") {
boreneted20a702016-10-20 11:04:31 -0700425 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_darwin"))
Mike Klein86c2c0f2016-11-02 13:13:16 -0400426 } else if strings.Contains(name, "Win") {
Mike Kleine9215f02016-11-02 15:44:26 -0400427 pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows")
428 pkg.Path = "n"
429 pkgs = append(pkgs, pkg)
borenetdb182c72016-09-30 12:53:12 -0700430 } else {
boreneted20a702016-10-20 11:04:31 -0700431 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_linux"))
borenetdb182c72016-09-30 12:53:12 -0700432 }
Kevin Lubickdcd2a902017-03-08 14:01:01 -0500433 } else if strings.Contains(name, "Chromecast") {
434 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("cast_toolchain"))
Kevin Lubickffce0792017-05-24 15:30:35 -0400435 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles"))
Kevin Lubick261ea192017-04-05 07:32:45 -0400436 } else if strings.Contains(name, "Chromebook") {
437 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
438 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("armhf_sysroot"))
Kevin Lubick671cd722017-04-12 10:50:18 -0400439 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles"))
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500440 } else if strings.Contains(name, "Ubuntu") {
441 if strings.Contains(name, "Clang") {
442 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
443 }
444 if strings.Contains(name, "Vulkan") {
445 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
446 }
Mike Klein27dcee12016-11-09 16:31:42 -0500447 } else if strings.Contains(name, "Win") {
boreneted20a702016-10-20 11:04:31 -0700448 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_toolchain"))
borenetdb182c72016-09-30 12:53:12 -0700449 if strings.Contains(name, "Vulkan") {
boreneted20a702016-10-20 11:04:31 -0700450 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_vulkan_sdk"))
borenetdb182c72016-09-30 12:53:12 -0700451 }
452 }
453
Stephan Altmueller5f3b9402017-03-20 13:38:45 -0400454 // TODO(stephana): Remove this once all Mac machines are on the same
455 // OS version again. Move the call to swarmDimensions back to the
456 // creation of the TaskSpec struct below.
457 dimensions := swarmDimensions(parts)
458 if strings.Contains(name, "Mac") {
459 for idx, dim := range dimensions {
460 if strings.HasPrefix(dim, "os") {
461 dimensions[idx] = "os:Mac-10.12"
462 break
463 }
464 }
465 }
466
borenetdb182c72016-09-30 12:53:12 -0700467 // Add the task.
boreneted20a702016-10-20 11:04:31 -0700468 b.MustAddTask(name, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700469 CipdPackages: pkgs,
Stephan Altmueller5f3b9402017-03-20 13:38:45 -0400470 Dimensions: dimensions,
borenetdb182c72016-09-30 12:53:12 -0700471 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400472 "--workdir", "../../..", "compile",
skia.buildbots2478c732016-11-04 14:37:26 -0400473 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700474 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700475 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
476 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400477 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700478 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400479 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
480 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700481 },
482 Isolate: "compile_skia.isolate",
483 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700484 })
Eric Boren8615fe52016-12-12 14:30:12 -0500485 // All compile tasks are runnable as their own Job. Assert that the Job
486 // is listed in JOBS.
487 if !util.In(name, JOBS) {
488 glog.Fatalf("Job %q is missing from the JOBS list!", name)
489 }
borenetdb182c72016-09-30 12:53:12 -0700490 return name
491}
492
493// recreateSKPs generates a RecreateSKPs task. Returns the name of the last
494// task in the generated chain of tasks, which the Job should add as a
495// dependency.
boreneted20a702016-10-20 11:04:31 -0700496func recreateSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500497 b.MustAddTask(name, &specs.TaskSpec{
Eric Borenf9c09042017-04-17 07:50:20 -0400498 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren27225492017-02-01 15:56:55 -0500499 Dimensions: linuxGceDimensions(),
Eric Borenf5a90e82016-11-15 15:18:20 -0500500 ExecutionTimeout: 4 * time.Hour,
Eric Boren4b254b92016-11-08 12:55:32 -0500501 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400502 "--workdir", "../../..", "recreate_skps",
Eric Boren4b254b92016-11-08 12:55:32 -0500503 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
504 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500505 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
506 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400507 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500508 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
509 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
510 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
511 },
Eric Borenf5a90e82016-11-15 15:18:20 -0500512 IoTimeout: 40 * time.Minute,
513 Isolate: "compile_skia.isolate",
514 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500515 })
borenetdb182c72016-09-30 12:53:12 -0700516 return name
517}
518
Ravi Mistry01b48e72017-05-17 14:28:06 -0400519// updateMetaConfig generates a UpdateMetaConfig task. Returns the name of the
520// last task in the generated chain of tasks, which the Job should add as a
521// dependency.
522func updateMetaConfig(b *specs.TasksCfgBuilder, name string) string {
523 b.MustAddTask(name, &specs.TaskSpec{
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400524 CipdPackages: []*specs.CipdPackage{},
525 Dimensions: linuxGceDimensions(),
Ravi Mistry01b48e72017-05-17 14:28:06 -0400526 ExtraArgs: []string{
527 "--workdir", "../../..", "update_meta_config",
528 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
529 fmt.Sprintf("buildername=%s", name),
530 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
531 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
532 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
533 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
534 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
535 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
536 },
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400537 Isolate: "meta_config.isolate",
538 Priority: 0.8,
Ravi Mistry01b48e72017-05-17 14:28:06 -0400539 })
540 return name
541}
542
borenetdb182c72016-09-30 12:53:12 -0700543// ctSKPs generates a CT SKPs task. Returns the name of the last task in the
544// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700545func ctSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500546 b.MustAddTask(name, &specs.TaskSpec{
547 CipdPackages: []*specs.CipdPackage{},
548 Dimensions: []string{"pool:SkiaCT"},
549 ExecutionTimeout: 24 * time.Hour,
550 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400551 "--workdir", "../../..", "ct_skps",
Eric Boren4b254b92016-11-08 12:55:32 -0500552 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
553 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500554 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
555 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400556 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500557 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
558 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
559 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
560 },
561 IoTimeout: time.Hour,
562 Isolate: "ct_skps_skia.isolate",
563 Priority: 0.8,
564 })
borenetdb182c72016-09-30 12:53:12 -0700565 return name
566}
567
568// housekeeper generates a Housekeeper task. Returns the name of the last task
569// in the generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700570func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500571 b.MustAddTask(name, &specs.TaskSpec{
Eric Boren22f5ef72016-12-02 11:01:33 -0500572 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren4b254b92016-11-08 12:55:32 -0500573 Dependencies: []string{compileTaskName},
Eric Boren27225492017-02-01 15:56:55 -0500574 Dimensions: linuxGceDimensions(),
Eric Boren4b254b92016-11-08 12:55:32 -0500575 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400576 "--workdir", "../../..", "housekeeper",
Eric Boren4b254b92016-11-08 12:55:32 -0500577 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
578 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500579 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
580 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400581 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500582 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
583 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
584 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
585 },
586 Isolate: "housekeeper_skia.isolate",
587 Priority: 0.8,
588 })
borenetdb182c72016-09-30 12:53:12 -0700589 return name
590}
591
borenet2dbbfa52016-10-14 06:32:09 -0700592// infra generates an infra_tests task. Returns the name of the last task in the
593// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700594func infra(b *specs.TasksCfgBuilder, name string) string {
595 b.MustAddTask(name, &specs.TaskSpec{
Eric Borenade69202017-04-13 10:00:43 -0400596 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren27225492017-02-01 15:56:55 -0500597 Dimensions: linuxGceDimensions(),
borenet2dbbfa52016-10-14 06:32:09 -0700598 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400599 "--workdir", "../../..", "infra",
skia.buildbots2478c732016-11-04 14:37:26 -0400600 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenet2dbbfa52016-10-14 06:32:09 -0700601 fmt.Sprintf("buildername=%s", name),
borenet2dbbfa52016-10-14 06:32:09 -0700602 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
603 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400604 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet2dbbfa52016-10-14 06:32:09 -0700605 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400606 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
607 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenet2dbbfa52016-10-14 06:32:09 -0700608 },
609 Isolate: "infra_skia.isolate",
610 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700611 })
borenet2dbbfa52016-10-14 06:32:09 -0700612 return name
613}
614
borenetdb182c72016-09-30 12:53:12 -0700615// doUpload indicates whether the given Job should upload its results.
616func doUpload(name string) bool {
Eric Boren27225492017-02-01 15:56:55 -0500617 for _, s := range CONFIG.NoUpload {
618 m, err := regexp.MatchString(s, name)
619 if err != nil {
620 glog.Fatal(err)
621 }
622 if m {
borenetdb182c72016-09-30 12:53:12 -0700623 return false
624 }
625 }
626 return true
627}
628
629// test generates a Test task. Returns the name of the last task in the
630// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700631func test(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500632 s := &specs.TaskSpec{
Eric Boren1f2f64b2016-11-09 18:35:15 -0500633 CipdPackages: pkgs,
634 Dependencies: []string{compileTaskName},
635 Dimensions: swarmDimensions(parts),
636 ExecutionTimeout: 4 * time.Hour,
637 Expiration: 20 * time.Hour,
borenetdb182c72016-09-30 12:53:12 -0700638 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400639 "--workdir", "../../..", "test",
skia.buildbots2478c732016-11-04 14:37:26 -0400640 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700641 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700642 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
643 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400644 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700645 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400646 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
647 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700648 },
Eric Boren5d9f3bf2017-02-22 08:36:03 -0500649 IoTimeout: 40 * time.Minute,
650 Isolate: "test_skia.isolate",
651 MaxAttempts: 1,
652 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500653 }
Eric Boren23a6ec62017-04-07 08:31:22 -0400654 if useBundledRecipes(parts) {
Eric Boren8b3f9e62017-04-04 09:06:16 -0400655 s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME)
Eric Boren23a6ec62017-04-07 08:31:22 -0400656 if strings.Contains(parts["os"], "Win") {
657 s.Isolate = "test_skia_bundled_win.isolate"
658 } else {
659 s.Isolate = "test_skia_bundled_unix.isolate"
660 }
Eric Boren8b3f9e62017-04-04 09:06:16 -0400661 }
Kevin Lubick90189522017-05-15 08:30:27 -0400662 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
663 s.Dependencies = append(s.Dependencies, deps...)
Kevin Lubick07072942017-05-11 13:35:23 -0400664 }
Eric Boren4b254b92016-11-08 12:55:32 -0500665 if strings.Contains(parts["extra_config"], "Valgrind") {
666 s.ExecutionTimeout = 9 * time.Hour
667 s.Expiration = 48 * time.Hour
668 s.IoTimeout = time.Hour
Eric Borend696df72017-05-31 15:09:10 -0400669 s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind"))
Eric Boren4b254b92016-11-08 12:55:32 -0500670 } else if strings.Contains(parts["extra_config"], "MSAN") {
671 s.ExecutionTimeout = 9 * time.Hour
Ben Wagnera6b2ba22017-06-08 10:34:17 -0400672 } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" {
673 // skia:6737
674 s.ExecutionTimeout = 6 * time.Hour
Eric Boren4b254b92016-11-08 12:55:32 -0500675 }
676 b.MustAddTask(name, s)
677
borenetdb182c72016-09-30 12:53:12 -0700678 // Upload results if necessary.
679 if doUpload(name) {
680 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700681 b.MustAddTask(uploadName, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700682 Dependencies: []string{name},
Eric Boren27225492017-02-01 15:56:55 -0500683 Dimensions: linuxGceDimensions(),
borenetdb182c72016-09-30 12:53:12 -0700684 ExtraArgs: []string{
685 "--workdir", "../../..", "upload_dm_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400686 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700687 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700688 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
689 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400690 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700691 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400692 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
693 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
Eric Boren965861b2017-02-06 15:38:41 -0500694 fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketGm),
borenetdb182c72016-09-30 12:53:12 -0700695 },
696 Isolate: "upload_dm_results.isolate",
697 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700698 })
borenetdb182c72016-09-30 12:53:12 -0700699 return uploadName
700 }
701 return name
702}
703
704// perf generates a Perf task. Returns the name of the last task in the
705// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700706func perf(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Eric Boren768f52f2017-04-10 08:14:33 -0400707 recipe := "perf"
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500708 isolate := "perf_skia.isolate"
709 if strings.Contains(parts["extra_config"], "Skpbench") {
Eric Boren768f52f2017-04-10 08:14:33 -0400710 recipe = "skpbench"
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500711 isolate = "skpbench_skia.isolate"
Eric Boren23a6ec62017-04-07 08:31:22 -0400712 if useBundledRecipes(parts) {
713 if strings.Contains(parts["os"], "Win") {
714 isolate = "skpbench_skia_bundled_win.isolate"
715 } else {
716 isolate = "skpbench_skia_bundled_unix.isolate"
717 }
Eric Boren8b3f9e62017-04-04 09:06:16 -0400718 }
Eric Boren23a6ec62017-04-07 08:31:22 -0400719 } else if useBundledRecipes(parts) {
720 if strings.Contains(parts["os"], "Win") {
721 isolate = "perf_skia_bundled_win.isolate"
722 } else {
723 isolate = "perf_skia_bundled_unix.isolate"
724 }
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500725 }
Eric Boren4b254b92016-11-08 12:55:32 -0500726 s := &specs.TaskSpec{
Eric Boren1f2f64b2016-11-09 18:35:15 -0500727 CipdPackages: pkgs,
728 Dependencies: []string{compileTaskName},
729 Dimensions: swarmDimensions(parts),
730 ExecutionTimeout: 4 * time.Hour,
731 Expiration: 20 * time.Hour,
borenetdb182c72016-09-30 12:53:12 -0700732 ExtraArgs: []string{
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500733 "--workdir", "../../..", recipe,
skia.buildbots2478c732016-11-04 14:37:26 -0400734 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700735 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700736 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
737 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400738 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700739 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400740 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
741 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700742 },
Eric Boren5d9f3bf2017-02-22 08:36:03 -0500743 IoTimeout: 40 * time.Minute,
744 Isolate: isolate,
745 MaxAttempts: 1,
746 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500747 }
Eric Boren23a6ec62017-04-07 08:31:22 -0400748 if useBundledRecipes(parts) {
Eric Boren8b3f9e62017-04-04 09:06:16 -0400749 s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME)
750 }
Kevin Lubick90189522017-05-15 08:30:27 -0400751 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
752 s.Dependencies = append(s.Dependencies, deps...)
753 }
754
Eric Boren4b254b92016-11-08 12:55:32 -0500755 if strings.Contains(parts["extra_config"], "Valgrind") {
756 s.ExecutionTimeout = 9 * time.Hour
757 s.Expiration = 48 * time.Hour
758 s.IoTimeout = time.Hour
Eric Borenc5a073d2017-06-01 07:13:33 -0400759 s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind"))
Eric Boren4b254b92016-11-08 12:55:32 -0500760 } else if strings.Contains(parts["extra_config"], "MSAN") {
761 s.ExecutionTimeout = 9 * time.Hour
Ben Wagnera6b2ba22017-06-08 10:34:17 -0400762 } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" {
763 // skia:6737
764 s.ExecutionTimeout = 6 * time.Hour
Eric Boren4b254b92016-11-08 12:55:32 -0500765 }
766 b.MustAddTask(name, s)
767
borenetdb182c72016-09-30 12:53:12 -0700768 // Upload results if necessary.
769 if strings.Contains(name, "Release") && doUpload(name) {
770 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700771 b.MustAddTask(uploadName, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700772 Dependencies: []string{name},
Eric Boren27225492017-02-01 15:56:55 -0500773 Dimensions: linuxGceDimensions(),
borenetdb182c72016-09-30 12:53:12 -0700774 ExtraArgs: []string{
775 "--workdir", "../../..", "upload_nano_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400776 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700777 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700778 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
779 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400780 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700781 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400782 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
783 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
Eric Boren965861b2017-02-06 15:38:41 -0500784 fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketNano),
borenetdb182c72016-09-30 12:53:12 -0700785 },
786 Isolate: "upload_nano_results.isolate",
787 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700788 })
borenetdb182c72016-09-30 12:53:12 -0700789 return uploadName
790 }
791 return name
792}
793
794// process generates tasks and jobs for the given job name.
boreneted20a702016-10-20 11:04:31 -0700795func process(b *specs.TasksCfgBuilder, name string) {
borenetdb182c72016-09-30 12:53:12 -0700796 deps := []string{}
797
Eric Boren8b3f9e62017-04-04 09:06:16 -0400798 // Bundle Recipes.
799 if name == BUNDLE_RECIPES_NAME {
800 deps = append(deps, bundleRecipes(b))
801 }
802
Kevin Lubick07072942017-05-11 13:35:23 -0400803 // Isolate CIPD assets.
Kevin Lubick07072942017-05-11 13:35:23 -0400804 if _, ok := ISOLATE_ASSET_MAPPING[name]; ok {
805 deps = append(deps, isolateCIPDAsset(b, name))
806 }
807
borenetdb182c72016-09-30 12:53:12 -0700808 parts, err := jobNameSchema.ParseJobName(name)
809 if err != nil {
810 glog.Fatal(err)
811 }
812
813 // RecreateSKPs.
814 if strings.Contains(name, "RecreateSKPs") {
boreneted20a702016-10-20 11:04:31 -0700815 deps = append(deps, recreateSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -0700816 }
817
Ravi Mistry01b48e72017-05-17 14:28:06 -0400818 // UpdateMetaConfig bot.
819 if strings.Contains(name, "UpdateMetaConfig") {
820 deps = append(deps, updateMetaConfig(b, name))
821 }
822
borenetdb182c72016-09-30 12:53:12 -0700823 // CT bots.
824 if strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700825 deps = append(deps, ctSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -0700826 }
827
borenet2dbbfa52016-10-14 06:32:09 -0700828 // Infra tests.
829 if name == "Housekeeper-PerCommit-InfraTests" {
boreneted20a702016-10-20 11:04:31 -0700830 deps = append(deps, infra(b, name))
borenet2dbbfa52016-10-14 06:32:09 -0700831 }
832
borenetdb182c72016-09-30 12:53:12 -0700833 // Compile bots.
834 if parts["role"] == "Build" {
boreneted20a702016-10-20 11:04:31 -0700835 deps = append(deps, compile(b, name, parts))
borenetdb182c72016-09-30 12:53:12 -0700836 }
837
Eric Borenf5a90e82016-11-15 15:18:20 -0500838 // Most remaining bots need a compile task.
borenetdb182c72016-09-30 12:53:12 -0700839 compileTaskName := deriveCompileTaskName(name, parts)
borenet52383432016-10-17 10:17:53 -0700840 compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName)
841 if err != nil {
842 glog.Fatal(err)
843 }
Eric Boren628e78b2016-11-17 11:33:27 -0500844 // These bots do not need a compile task.
Eric Borenf5a90e82016-11-15 15:18:20 -0500845 if parts["role"] != "Build" &&
Eric Borenb8ab7f72017-04-10 11:00:09 -0400846 name != "Housekeeper-PerCommit-BundleRecipes" &&
Eric Borenf5a90e82016-11-15 15:18:20 -0500847 name != "Housekeeper-PerCommit-InfraTests" &&
Eric Boren71b762f2016-11-30 14:05:16 -0500848 !strings.Contains(name, "RecreateSKPs") &&
Ravi Mistry01b48e72017-05-17 14:28:06 -0400849 !strings.Contains(name, "UpdateMetaConfig") &&
Ben Wagner50b84682017-06-12 13:03:29 -0400850 !strings.Contains(name, "-CT_") &&
851 !strings.Contains(name, "Housekeeper-PerCommit-Isolate") {
boreneted20a702016-10-20 11:04:31 -0700852 compile(b, compileTaskName, compileTaskParts)
borenet52383432016-10-17 10:17:53 -0700853 }
borenetdb182c72016-09-30 12:53:12 -0700854
855 // Housekeeper.
Eric Boren22f5ef72016-12-02 11:01:33 -0500856 if name == "Housekeeper-PerCommit" {
boreneted20a702016-10-20 11:04:31 -0700857 deps = append(deps, housekeeper(b, name, compileTaskName))
borenetdb182c72016-09-30 12:53:12 -0700858 }
859
860 // Common assets needed by the remaining bots.
Kevin Lubick07072942017-05-11 13:35:23 -0400861
862 pkgs := []*specs.CipdPackage{}
863
Kevin Lubick90189522017-05-15 08:30:27 -0400864 if deps := getIsolatedCIPDDeps(parts); len(deps) == 0 {
Kevin Lubick07072942017-05-11 13:35:23 -0400865 pkgs = []*specs.CipdPackage{
866 b.MustGetCipdPackageFromAsset("skimage"),
867 b.MustGetCipdPackageFromAsset("skp"),
868 b.MustGetCipdPackageFromAsset("svg"),
869 }
borenetdb182c72016-09-30 12:53:12 -0700870 }
Kevin Lubick90189522017-05-15 08:30:27 -0400871
Eric Boren4b254b92016-11-08 12:55:32 -0500872 if strings.Contains(name, "Ubuntu") && strings.Contains(name, "SAN") {
873 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
874 }
Kevin Lubick35115eb2017-02-17 10:25:34 -0500875 if strings.Contains(name, "Ubuntu16") {
876 if strings.Contains(name, "Vulkan") {
877 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
878 }
Kevin Lubick0a51b482017-02-06 12:45:29 -0500879 if strings.Contains(name, "Release") {
880 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_release"))
881 } else {
882 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_debug"))
883 }
884 }
borenetdb182c72016-09-30 12:53:12 -0700885
886 // Test bots.
Eric Boren71b762f2016-11-30 14:05:16 -0500887 if parts["role"] == "Test" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700888 deps = append(deps, test(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -0700889 }
890
891 // Perf bots.
Eric Boren71b762f2016-11-30 14:05:16 -0500892 if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700893 deps = append(deps, perf(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -0700894 }
895
896 // Add the Job spec.
Eric Borenf5a90e82016-11-15 15:18:20 -0500897 j := &specs.JobSpec{
borenetdb182c72016-09-30 12:53:12 -0700898 Priority: 0.8,
899 TaskSpecs: deps,
Eric Borenf5a90e82016-11-15 15:18:20 -0500900 }
901 if name == "Housekeeper-Nightly-RecreateSKPs_Canary" {
902 j.Trigger = "nightly"
903 }
Ravi Mistry01b48e72017-05-17 14:28:06 -0400904 if name == "Housekeeper-Nightly-UpdateMetaConfig" {
905 j.Trigger = "nightly"
906 }
Eric Borenf5a90e82016-11-15 15:18:20 -0500907 if name == "Housekeeper-Weekly-RecreateSKPs" {
908 j.Trigger = "weekly"
909 }
Eric Boren71b762f2016-11-30 14:05:16 -0500910 if name == "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs" {
911 j.Trigger = "weekly"
912 }
Eric Boren8615fe52016-12-12 14:30:12 -0500913 b.MustAddJob(name, j)
borenetdb182c72016-09-30 12:53:12 -0700914}
915
Eric Boren27225492017-02-01 15:56:55 -0500916func loadJson(flag *string, defaultFlag string, val interface{}) {
917 if *flag == "" {
918 *flag = defaultFlag
919 }
920 b, err := ioutil.ReadFile(*flag)
921 if err != nil {
922 glog.Fatal(err)
923 }
924 if err := json.Unmarshal(b, val); err != nil {
925 glog.Fatal(err)
926 }
927}
928
borenetdb182c72016-09-30 12:53:12 -0700929// Regenerate the tasks.json file.
930func main() {
boreneted20a702016-10-20 11:04:31 -0700931 b := specs.MustNewTasksCfgBuilder()
Eric Boren27225492017-02-01 15:56:55 -0500932 b.SetAssetsDir(*assetsDir)
933 infraBots := path.Join(b.CheckoutRoot(), "infra", "bots")
934
935 // Load the jobs from a JSON file.
936 loadJson(jobsFile, path.Join(infraBots, "jobs.json"), &JOBS)
937
Eric Boren27225492017-02-01 15:56:55 -0500938 // Load general config information from a JSON file.
939 loadJson(cfgFile, path.Join(infraBots, "cfg.json"), &CONFIG)
940
borenetdb182c72016-09-30 12:53:12 -0700941 // Create the JobNameSchema.
Eric Boren1f8be682017-02-07 09:16:30 -0500942 if *builderNameSchemaFile == "" {
943 *builderNameSchemaFile = path.Join(b.CheckoutRoot(), "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json")
944 }
945 schema, err := NewJobNameSchema(*builderNameSchemaFile)
borenetdb182c72016-09-30 12:53:12 -0700946 if err != nil {
947 glog.Fatal(err)
948 }
949 jobNameSchema = schema
950
borenetdb182c72016-09-30 12:53:12 -0700951 // Create Tasks and Jobs.
boreneted20a702016-10-20 11:04:31 -0700952 for _, name := range JOBS {
953 process(b, name)
borenetdb182c72016-09-30 12:53:12 -0700954 }
955
boreneted20a702016-10-20 11:04:31 -0700956 b.MustFinish()
borenetdb182c72016-09-30 12:53:12 -0700957}
958
959// TODO(borenet): The below really belongs in its own file, probably next to the
960// builder_name_schema.json file.
961
962// JobNameSchema is a struct used for (de)constructing Job names in a
963// predictable format.
964type JobNameSchema struct {
965 Schema map[string][]string `json:"builder_name_schema"`
966 Sep string `json:"builder_name_sep"`
967}
968
969// NewJobNameSchema returns a JobNameSchema instance based on the given JSON
970// file.
971func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) {
972 var rv JobNameSchema
973 f, err := os.Open(jsonFile)
974 if err != nil {
975 return nil, err
976 }
977 defer util.Close(f)
978 if err := json.NewDecoder(f).Decode(&rv); err != nil {
979 return nil, err
980 }
981 return &rv, nil
982}
983
984// ParseJobName splits the given Job name into its component parts, according
985// to the schema.
986func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) {
987 split := strings.Split(n, s.Sep)
988 if len(split) < 2 {
989 return nil, fmt.Errorf("Invalid job name: %q", n)
990 }
991 role := split[0]
992 split = split[1:]
993 keys, ok := s.Schema[role]
994 if !ok {
995 return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role)
996 }
997 extraConfig := ""
998 if len(split) == len(keys)+1 {
999 extraConfig = split[len(split)-1]
1000 split = split[:len(split)-1]
1001 }
1002 if len(split) != len(keys) {
1003 return nil, fmt.Errorf("Invalid job name; %q has incorrect number of parts.", n)
1004 }
1005 rv := make(map[string]string, len(keys)+2)
1006 rv["role"] = role
1007 if extraConfig != "" {
1008 rv["extra_config"] = extraConfig
1009 }
1010 for i, k := range keys {
1011 rv[k] = split[i]
1012 }
1013 return rv, nil
1014}
1015
1016// MakeJobName assembles the given parts of a Job name, according to the schema.
1017func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) {
1018 role, ok := parts["role"]
1019 if !ok {
1020 return "", fmt.Errorf("Invalid job parts; jobs must have a role.")
1021 }
1022 keys, ok := s.Schema[role]
1023 if !ok {
1024 return "", fmt.Errorf("Invalid job parts; unknown role %q", role)
1025 }
1026 rvParts := make([]string, 0, len(parts))
1027 rvParts = append(rvParts, role)
1028 for _, k := range keys {
1029 v, ok := parts[k]
1030 if !ok {
1031 return "", fmt.Errorf("Invalid job parts; missing %q", k)
1032 }
1033 rvParts = append(rvParts, v)
1034 }
1035 if _, ok := parts["extra_config"]; ok {
1036 rvParts = append(rvParts, parts["extra_config"])
1037 }
1038 return strings.Join(rvParts, s.Sep), nil
1039}