blob: 899aa304f102f119772c4f0bb1d5e72cb6befd94 [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"
22 "strings"
Eric Boren4b254b92016-11-08 12:55:32 -050023 "time"
borenetdb182c72016-09-30 12:53:12 -070024
25 "github.com/skia-dev/glog"
Eric Boren7e3a3642017-06-14 15:25:31 -040026 "go.skia.org/infra/go/sklog"
borenetdb182c72016-09-30 12:53:12 -070027 "go.skia.org/infra/go/util"
28 "go.skia.org/infra/task_scheduler/go/specs"
29)
30
31const (
Kevin Lubick07072942017-05-11 13:35:23 -040032 BUNDLE_RECIPES_NAME = "Housekeeper-PerCommit-BundleRecipes"
33 ISOLATE_SKIMAGE_NAME = "Housekeeper-PerCommit-IsolateSkImage"
34 ISOLATE_SKP_NAME = "Housekeeper-PerCommit-IsolateSKP"
35 ISOLATE_SVG_NAME = "Housekeeper-PerCommit-IsolateSVG"
Eric Boren8b3f9e62017-04-04 09:06:16 -040036
Kevin Lubick797ef162016-12-15 10:45:08 -050037 DEFAULT_OS = DEFAULT_OS_LINUX
38 DEFAULT_OS_LINUX = "Ubuntu-14.04"
borenetdb182c72016-09-30 12:53:12 -070039
borenetdb182c72016-09-30 12:53:12 -070040 // Name prefix for upload jobs.
41 PREFIX_UPLOAD = "Upload"
42)
43
44var (
45 // "Constants"
46
Eric Boren27225492017-02-01 15:56:55 -050047 // Top-level list of all jobs to run at each commit; loaded from
48 // jobs.json.
49 JOBS []string
50
Eric Boren27225492017-02-01 15:56:55 -050051 // General configuration information.
52 CONFIG struct {
Eric Boren965861b2017-02-06 15:38:41 -050053 GsBucketGm string `json:"gs_bucket_gm"`
54 GsBucketNano string `json:"gs_bucket_nano"`
55 NoUpload []string `json:"no_upload"`
56 Pool string `json:"pool"`
borenetdb182c72016-09-30 12:53:12 -070057 }
58
Ben Wagner3d2a2f72017-06-13 17:01:16 -040059 // alternateSwarmDimensions can be set in an init function to override the default swarming bot
60 // dimensions for the given task.
61 alternateSwarmDimensions func(parts map[string]string) []string
62
borenetdb182c72016-09-30 12:53:12 -070063 // Defines the structure of job names.
64 jobNameSchema *JobNameSchema
Eric Boren27225492017-02-01 15:56:55 -050065
Eric Borenf4a5fc72017-06-06 08:27:09 -040066 // Git 2.13.
67 cipdGit1 = &specs.CipdPackage{
68 Name: fmt.Sprintf("infra/git/${platform}"),
69 Path: "git",
70 Version: fmt.Sprintf("version:2.13.0.chromium9"),
71 }
72 cipdGit2 = &specs.CipdPackage{
73 Name: fmt.Sprintf("infra/tools/git/${platform}"),
74 Path: "git",
75 Version: fmt.Sprintf("git_revision:a78b5f3658c0578a017db48df97d20ac09822bcd"),
76 }
77
Eric Boren27225492017-02-01 15:56:55 -050078 // Flags.
Eric Boren1f8be682017-02-07 09:16:30 -050079 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.")
80 assetsDir = flag.String("assets_dir", "", "Directory containing assets.")
81 cfgFile = flag.String("cfg_file", "", "JSON file containing general configuration information.")
Eric Boren1f8be682017-02-07 09:16:30 -050082 jobsFile = flag.String("jobs", "", "JSON file containing jobs to run.")
borenetdb182c72016-09-30 12:53:12 -070083)
84
Eric Boren27225492017-02-01 15:56:55 -050085// linuxGceDimensions are the Swarming dimensions for Linux GCE
86// instances.
87func linuxGceDimensions() []string {
88 return []string{
89 "cpu:x86-64-avx2",
90 "gpu:none",
91 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX),
92 fmt.Sprintf("pool:%s", CONFIG.Pool),
93 }
94}
95
borenetdb182c72016-09-30 12:53:12 -070096// deriveCompileTaskName returns the name of a compile task based on the given
97// job name.
98func deriveCompileTaskName(jobName string, parts map[string]string) string {
99 if parts["role"] == "Housekeeper" {
100 return "Build-Ubuntu-GCC-x86_64-Release-Shared"
101 } else if parts["role"] == "Test" || parts["role"] == "Perf" {
102 task_os := parts["os"]
Ben Wagner988d15e2017-04-27 13:08:50 -0400103 ec := []string{}
104 if val := parts["extra_config"]; val != "" {
105 ec = strings.Split(val, "_")
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400106 ignore := []string{"Skpbench", "AbandonGpuContext", "PreAbandonGpuContext", "Valgrind", "ReleaseAndAbandonGpuContext"}
Ben Wagner988d15e2017-04-27 13:08:50 -0400107 keep := make([]string, 0, len(ec))
108 for _, part := range ec {
109 if !util.In(part, ignore) {
110 keep = append(keep, part)
111 }
112 }
113 ec = keep
Eric Boren6ec17e32017-04-26 14:25:29 -0400114 }
borenetdb182c72016-09-30 12:53:12 -0700115 if task_os == "Android" {
Ben Wagner988d15e2017-04-27 13:08:50 -0400116 if !util.In("Android", ec) {
117 ec = append([]string{"Android"}, ec...)
borenetdb182c72016-09-30 12:53:12 -0700118 }
borenet52383432016-10-17 10:17:53 -0700119 task_os = "Ubuntu"
Kevin Lubickdcd2a902017-03-08 14:01:01 -0500120 } else if task_os == "Chromecast" {
121 task_os = "Ubuntu"
Ben Wagner988d15e2017-04-27 13:08:50 -0400122 ec = append([]string{"Chromecast"}, ec...)
Kevin Lubickcb6f3982017-04-07 10:04:08 -0400123 } else if strings.Contains(task_os, "ChromeOS") {
Ben Wagner988d15e2017-04-27 13:08:50 -0400124 ec = append([]string{"Chromebook", "ARM", "GLES"}, ec...)
Kevin Lubick261ea192017-04-05 07:32:45 -0400125 task_os = "Ubuntu"
borenetdb182c72016-09-30 12:53:12 -0700126 } else if task_os == "iOS" {
Ben Wagner988d15e2017-04-27 13:08:50 -0400127 ec = append([]string{task_os}, ec...)
borenetdb182c72016-09-30 12:53:12 -0700128 task_os = "Mac"
129 } else if strings.Contains(task_os, "Win") {
130 task_os = "Win"
Kevin Lubick893c49e2017-01-17 15:15:40 -0500131 } else if strings.Contains(task_os, "Ubuntu") {
132 task_os = "Ubuntu"
borenetdb182c72016-09-30 12:53:12 -0700133 }
Eric Boren50831302016-11-18 13:10:51 -0500134 jobNameMap := map[string]string{
borenetdb182c72016-09-30 12:53:12 -0700135 "role": "Build",
136 "os": task_os,
137 "compiler": parts["compiler"],
138 "target_arch": parts["arch"],
139 "configuration": parts["configuration"],
Eric Boren50831302016-11-18 13:10:51 -0500140 }
Ben Wagner988d15e2017-04-27 13:08:50 -0400141 if len(ec) > 0 {
142 jobNameMap["extra_config"] = strings.Join(ec, "_")
Eric Boren50831302016-11-18 13:10:51 -0500143 }
144 name, err := jobNameSchema.MakeJobName(jobNameMap)
borenetdb182c72016-09-30 12:53:12 -0700145 if err != nil {
146 glog.Fatal(err)
147 }
148 return name
149 } else {
150 return jobName
151 }
152}
153
154// swarmDimensions generates swarming bot dimensions for the given task.
155func swarmDimensions(parts map[string]string) []string {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400156 if alternateSwarmDimensions != nil {
157 return alternateSwarmDimensions(parts)
158 }
159 return defaultSwarmDimensions(parts)
160}
161
162// defaultSwarmDimensions generates default swarming bot dimensions for the given task.
163func defaultSwarmDimensions(parts map[string]string) []string {
borenetdb182c72016-09-30 12:53:12 -0700164 d := map[string]string{
Eric Boren27225492017-02-01 15:56:55 -0500165 "pool": CONFIG.Pool,
borenetdb182c72016-09-30 12:53:12 -0700166 }
167 if os, ok := parts["os"]; ok {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400168 d["os"], ok = map[string]string{
Kevin Lubick291547d2017-03-21 09:25:34 -0400169 "Android": "Android",
170 "Chromecast": "Android",
Kevin Lubickcb6f3982017-04-07 10:04:08 -0400171 "ChromeOS": "ChromeOS",
Kevin Lubick291547d2017-03-21 09:25:34 -0400172 "Mac": "Mac-10.11",
173 "Ubuntu": DEFAULT_OS_LINUX,
174 "Ubuntu16": "Ubuntu-16.10",
175 "Win": "Windows-2008ServerR2-SP1",
Ben Wagner40226b42017-05-02 13:13:13 -0400176 "Win10": "Windows-10-15063",
Kevin Lubick291547d2017-03-21 09:25:34 -0400177 "Win2k8": "Windows-2008ServerR2-SP1",
Ben Wagner56738d82017-04-18 15:38:15 -0400178 "Win7": "Windows-7-SP1",
Kevin Lubick291547d2017-03-21 09:25:34 -0400179 "Win8": "Windows-8.1-SP0",
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400180 "iOS": "iOS-10.3.1",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500181 }[os]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400182 if !ok {
183 glog.Fatalf("Entry %q not found in OS mapping.", os)
184 }
Ben Wagner73557372016-12-29 16:27:03 -0500185 // Chrome Golo has a different Windows image.
186 if parts["model"] == "Golo" && os == "Win10" {
187 d["os"] = "Windows-10-10586"
Ben Wagner17f811b2016-12-22 08:40:14 -0500188 }
borenetdb182c72016-09-30 12:53:12 -0700189 } else {
190 d["os"] = DEFAULT_OS
191 }
borenetdb182c72016-09-30 12:53:12 -0700192 if parts["role"] == "Test" || parts["role"] == "Perf" {
Kevin Lubick291547d2017-03-21 09:25:34 -0400193 if strings.Contains(parts["os"], "Android") || strings.Contains(parts["os"], "Chromecast") {
borenetdb182c72016-09-30 12:53:12 -0700194 // For Android, the device type is a better dimension
195 // than CPU or GPU.
Ben Wagner36682782017-06-14 10:01:45 -0400196 deviceInfo, ok := map[string][]string{
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400197 "AndroidOne": {"sprout", "MOB30Q"},
198 "Chorizo": {"chorizo", "1.24_82923"},
199 "Ci20": {"ci20", "NRD90M"},
200 "GalaxyJ5": {"j5xnlte", "MMB29M"},
201 "GalaxyS6": {"zerofltetmo", "MMB29K"},
202 "GalaxyS7_G930A": {"heroqlteatt", "NRD90M_G930AUCS4BQC2"},
203 "GalaxyS7_G930FD": {"herolte", "NRD90M_G930FXXU1DQAS"},
204 "GalaxyTab3": {"goyawifi", "JDQ39"},
205 "MotoG4": {"athene", "NPJ25.93-14"},
206 "NVIDIA_Shield": {"foster", "NRD90M"},
207 "Nexus10": {"manta", "LMY49J"},
208 "Nexus5": {"hammerhead", "M4B30Z"},
209 "Nexus6": {"shamu", "M"},
210 "Nexus6p": {"angler", "OPP1.170223.012"},
211 "Nexus7": {"grouper", "LMY47V"},
212 "Nexus7v2": {"flo", "M"},
213 "NexusPlayer": {"fugu", "OPP2.170420.017"},
214 "Pixel": {"sailfish", "NMF26Q"},
215 "PixelC": {"dragon", "N2G47D"},
Greg Danielc34aeb72017-06-14 11:09:19 -0400216 "PixelXL": {"marlin", "OPP3.170518.006"},
Ben Wagner36682782017-06-14 10:01:45 -0400217 }[parts["model"]]
Eric Boren27225492017-02-01 15:56:55 -0500218 if !ok {
Ben Wagner36682782017-06-14 10:01:45 -0400219 glog.Fatalf("Entry %q not found in Android mapping.", parts["model"])
Eric Boren27225492017-02-01 15:56:55 -0500220 }
Eric Boren4b254b92016-11-08 12:55:32 -0500221 d["device_type"] = deviceInfo[0]
222 d["device_os"] = deviceInfo[1]
borenetdb182c72016-09-30 12:53:12 -0700223 } else if strings.Contains(parts["os"], "iOS") {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400224 device, ok := map[string]string{
Eric Boren792079cf2016-11-09 14:03:20 -0500225 "iPadMini4": "iPad5,1",
Stephan Altmueller63e843d2017-04-25 11:38:38 -0400226 "iPhone6": "iPhone7,2",
227 "iPhone7": "iPhone9,1",
228 "iPadPro": "iPad6,3",
borenetdb182c72016-09-30 12:53:12 -0700229 }[parts["model"]]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400230 if !ok {
231 glog.Fatalf("Entry %q not found in iOS mapping.", parts["model"])
232 }
233 d["device"] = device
borenetdb182c72016-09-30 12:53:12 -0700234 } else if parts["cpu_or_gpu"] == "CPU" {
235 d["gpu"] = "none"
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400236 cpu, ok := map[string]string{
borenetdb182c72016-09-30 12:53:12 -0700237 "AVX": "x86-64",
238 "AVX2": "x86-64-avx2",
239 "SSE4": "x86-64",
240 }[parts["cpu_or_gpu_value"]]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400241 if !ok {
242 glog.Fatalf("Entry %q not found in CPU mapping.", parts["cpu_or_gpu_value"])
243 }
244 d["cpu"] = cpu
borenetdb182c72016-09-30 12:53:12 -0700245 if strings.Contains(parts["os"], "Win") && parts["cpu_or_gpu_value"] == "AVX2" {
246 // AVX2 is not correctly detected on Windows. Fall back on other
247 // dimensions to ensure that we correctly target machines which we know
248 // have AVX2 support.
Eric Boren085bf7c2017-04-06 17:32:44 +0000249 d["cpu"] = "x86-64"
Ben Wagner56738d82017-04-18 15:38:15 -0400250 if parts["model"] != "GCE" {
251 glog.Fatalf("Please double-check that %q supports AVX2 and update this assertion.", parts["model"])
252 }
borenetdb182c72016-09-30 12:53:12 -0700253 }
254 } else {
Ben Wagner1d060782017-06-14 10:34:18 -0400255 if strings.Contains(parts["os"], "Win") {
256 gpu, ok := map[string]string{
257 "AMDHD7770": "1002:683d-22.19.165.512",
258 "GT610": "10de:104a-21.21.13.7619",
259 "GTX1070": "10de:1ba1-22.21.13.8205",
260 "GTX660": "10de:11c0-22.21.13.8205",
261 "GTX960": "10de:1401-22.21.13.8205",
262 "IntelHD530": "8086:1912-21.20.16.4590",
263 "IntelHD4400": "8086:0a16-20.19.15.4531",
264 "IntelHD4600": "8086:0412-20.19.15.4531",
265 "IntelIris540": "8086:1926-21.20.16.4590",
266 "IntelIris6100": "8086:162b-20.19.15.4531",
267 "RadeonR9M470X": "1002:6646-22.19.165.512",
268 }[parts["cpu_or_gpu_value"]]
269 if !ok {
270 glog.Fatalf("Entry %q not found in Win GPU mapping.", parts["cpu_or_gpu_value"])
271 }
272 d["gpu"] = gpu
Ben Wagner08435892017-02-18 23:28:26 -0500273
Ben Wagner4b1df022017-06-15 12:28:04 -0400274 // Specify cpu dimension for NUCs and ShuttleCs. We temporarily have two
275 // types of machines with a GTX960.
276 cpu, ok := map[string]string{
277 "NUC6i7KYK": "x86-64-i7-6770HQ",
278 "ShuttleC": "x86-64-i7-6700K",
Ben Wagner1d060782017-06-14 10:34:18 -0400279 }[parts["model"]]
280 if ok {
Ben Wagner4b1df022017-06-15 12:28:04 -0400281 d["cpu"] = cpu
Ben Wagner1d060782017-06-14 10:34:18 -0400282 }
283 } else if strings.Contains(parts["os"], "Ubuntu") {
284 gpu, ok := map[string]string{
285 "GT610": "10de:104a-340.96",
286 "GTX550Ti": "10de:1244-340.76",
287 "GTX660": "10de:11c0-367.57",
288 "GTX960": "10de:1401-367.57",
289 // Intel drivers come from CIPD, so no need to specify the version here.
290 "IntelBayTrail": "8086:0f31",
291 "IntelHD2000": "8086:0102",
292 "IntelHD405": "8086:22b1",
293 "IntelIris540": "8086:1926",
294 }[parts["cpu_or_gpu_value"]]
295 if !ok {
296 glog.Fatalf("Entry %q not found in Ubuntu GPU mapping.", parts["cpu_or_gpu_value"])
297 }
298 d["gpu"] = gpu
299 } else if strings.Contains(parts["os"], "Mac") {
300 gpu, ok := map[string]string{
301 // TODO(benjaminwagner): GPU name doesn't match device ID.
302 "IntelHD4000": "8086:0a2e",
303 }[parts["cpu_or_gpu_value"]]
304 if !ok {
305 glog.Fatalf("Entry %q not found in Mac GPU mapping.", parts["cpu_or_gpu_value"])
306 }
307 d["gpu"] = gpu
308 } else if strings.Contains(parts["os"], "ChromeOS") {
309 gpu, ok := map[string]string{
310 "MaliT604": "MaliT604",
311 "MaliT764": "MaliT764",
312 "MaliT860": "MaliT860",
313 "TegraK1": "TegraK1",
314 }[parts["cpu_or_gpu_value"]]
315 if !ok {
316 glog.Fatalf("Entry %q not found in ChromeOS GPU mapping.", parts["cpu_or_gpu_value"])
317 }
318 d["gpu"] = gpu
319 } else {
320 glog.Fatalf("Unknown GPU mapping for OS %q.", parts["os"])
Ben Wagner08435892017-02-18 23:28:26 -0500321 }
borenetdb182c72016-09-30 12:53:12 -0700322 }
323 } else {
324 d["gpu"] = "none"
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400325 if d["os"] == DEFAULT_OS_LINUX {
326 return linuxGceDimensions()
327 }
borenetdb182c72016-09-30 12:53:12 -0700328 }
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400329
borenetdb182c72016-09-30 12:53:12 -0700330 rv := make([]string, 0, len(d))
331 for k, v := range d {
332 rv = append(rv, fmt.Sprintf("%s:%s", k, v))
333 }
334 sort.Strings(rv)
335 return rv
336}
337
Eric Boren7e3a3642017-06-14 15:25:31 -0400338// relpath returns the relative path to the given file from the config file.
339func relpath(f string) string {
340 _, filename, _, _ := runtime.Caller(0)
341 dir := path.Dir(filename)
342 rel := dir
343 if *cfgFile != "" {
344 rel = path.Dir(*cfgFile)
345 }
346 rv, err := filepath.Rel(rel, path.Join(dir, f))
347 if err != nil {
348 sklog.Fatal(err)
349 }
350 return rv
351}
352
Eric Boren8b3f9e62017-04-04 09:06:16 -0400353// bundleRecipes generates the task to bundle and isolate the recipes.
354func bundleRecipes(b *specs.TasksCfgBuilder) string {
355 b.MustAddTask(BUNDLE_RECIPES_NAME, &specs.TaskSpec{
Eric Borenf4a5fc72017-06-06 08:27:09 -0400356 CipdPackages: []*specs.CipdPackage{cipdGit1, cipdGit2},
Eric Boren8b3f9e62017-04-04 09:06:16 -0400357 Dimensions: linuxGceDimensions(),
358 ExtraArgs: []string{
359 "--workdir", "../../..", "bundle_recipes",
Eric Boren8b3f9e62017-04-04 09:06:16 -0400360 fmt.Sprintf("buildername=%s", BUNDLE_RECIPES_NAME),
Eric Boren8b3f9e62017-04-04 09:06:16 -0400361 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
Eric Boren8b3f9e62017-04-04 09:06:16 -0400362 },
Eric Boren7e3a3642017-06-14 15:25:31 -0400363 Isolate: relpath("bundle_recipes.isolate"),
Kevin Lubick07072942017-05-11 13:35:23 -0400364 Priority: 0.7,
Eric Boren8b3f9e62017-04-04 09:06:16 -0400365 })
366 return BUNDLE_RECIPES_NAME
367}
368
Eric Boren23a6ec62017-04-07 08:31:22 -0400369// useBundledRecipes returns true iff the given bot should use bundled recipes
370// instead of syncing recipe DEPS itself.
371func useBundledRecipes(parts map[string]string) bool {
372 // Use bundled recipes for all test/perf tasks.
373 return true
374}
375
Kevin Lubick07072942017-05-11 13:35:23 -0400376type isolateAssetCfg struct {
377 isolateFile string
378 cipdPkg string
379}
380
381var ISOLATE_ASSET_MAPPING = map[string]isolateAssetCfg{
382 ISOLATE_SKIMAGE_NAME: {
383 isolateFile: "isolate_skimage.isolate",
384 cipdPkg: "skimage",
385 },
386 ISOLATE_SKP_NAME: {
387 isolateFile: "isolate_skp.isolate",
388 cipdPkg: "skp",
389 },
390 ISOLATE_SVG_NAME: {
391 isolateFile: "isolate_svg.isolate",
392 cipdPkg: "svg",
393 },
394}
395
396// bundleRecipes generates the task to bundle and isolate the recipes.
397func isolateCIPDAsset(b *specs.TasksCfgBuilder, name string) string {
398 b.MustAddTask(name, &specs.TaskSpec{
399 CipdPackages: []*specs.CipdPackage{
400 b.MustGetCipdPackageFromAsset(ISOLATE_ASSET_MAPPING[name].cipdPkg),
401 },
402 Dimensions: linuxGceDimensions(),
Eric Boren7e3a3642017-06-14 15:25:31 -0400403 Isolate: relpath(ISOLATE_ASSET_MAPPING[name].isolateFile),
Kevin Lubick07072942017-05-11 13:35:23 -0400404 Priority: 0.7,
405 })
406 return name
407}
408
Kevin Lubick90189522017-05-15 08:30:27 -0400409// getIsolatedCIPDDeps returns the slice of Isolate_* tasks a given task needs.
410// This allows us to save time on I/O bound bots, like the RPIs.
411func getIsolatedCIPDDeps(parts map[string]string) []string {
412 deps := []string{}
Kevin Lubick07072942017-05-11 13:35:23 -0400413 // Only do this on the RPIs for now. Other, faster machines shouldn't see much
414 // benefit and we don't need the extra complexity, for now
Kevin Lubick90189522017-05-15 08:30:27 -0400415 rpiOS := []string{"Android", "ChromeOS", "iOS"}
416
417 if o := parts["os"]; strings.Contains(o, "Chromecast") {
418 // Chromecasts don't have enough disk space to fit all of the content,
419 // so we do a subset of the skps.
420 deps = append(deps, ISOLATE_SKP_NAME)
421 } else if e := parts["extra_config"]; strings.Contains(e, "Skpbench") {
422 // Skpbench only needs skps
423 deps = append(deps, ISOLATE_SKP_NAME)
424 } else if util.In(o, rpiOS) {
425 deps = append(deps, ISOLATE_SKP_NAME)
426 deps = append(deps, ISOLATE_SVG_NAME)
427 deps = append(deps, ISOLATE_SKIMAGE_NAME)
428 }
429
430 return deps
Kevin Lubick07072942017-05-11 13:35:23 -0400431}
432
borenetdb182c72016-09-30 12:53:12 -0700433// compile generates a compile task. Returns the name of the last task in the
434// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700435func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string {
borenetdb182c72016-09-30 12:53:12 -0700436 // Collect the necessary CIPD packages.
437 pkgs := []*specs.CipdPackage{}
438
439 // Android bots require a toolchain.
440 if strings.Contains(name, "Android") {
borenetdb182c72016-09-30 12:53:12 -0700441 if strings.Contains(name, "Mac") {
boreneted20a702016-10-20 11:04:31 -0700442 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_darwin"))
Mike Klein86c2c0f2016-11-02 13:13:16 -0400443 } else if strings.Contains(name, "Win") {
Mike Kleine9215f02016-11-02 15:44:26 -0400444 pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows")
445 pkg.Path = "n"
446 pkgs = append(pkgs, pkg)
borenetdb182c72016-09-30 12:53:12 -0700447 } else {
boreneted20a702016-10-20 11:04:31 -0700448 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_linux"))
borenetdb182c72016-09-30 12:53:12 -0700449 }
Kevin Lubickdcd2a902017-03-08 14:01:01 -0500450 } else if strings.Contains(name, "Chromecast") {
451 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("cast_toolchain"))
Kevin Lubickffce0792017-05-24 15:30:35 -0400452 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles"))
Kevin Lubick261ea192017-04-05 07:32:45 -0400453 } else if strings.Contains(name, "Chromebook") {
454 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
455 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("armhf_sysroot"))
Kevin Lubick671cd722017-04-12 10:50:18 -0400456 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles"))
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500457 } else if strings.Contains(name, "Ubuntu") {
458 if strings.Contains(name, "Clang") {
459 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
460 }
461 if strings.Contains(name, "Vulkan") {
462 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
463 }
Mike Klein27dcee12016-11-09 16:31:42 -0500464 } else if strings.Contains(name, "Win") {
boreneted20a702016-10-20 11:04:31 -0700465 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_toolchain"))
borenetdb182c72016-09-30 12:53:12 -0700466 if strings.Contains(name, "Vulkan") {
boreneted20a702016-10-20 11:04:31 -0700467 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_vulkan_sdk"))
borenetdb182c72016-09-30 12:53:12 -0700468 }
469 }
470
Stephan Altmueller5f3b9402017-03-20 13:38:45 -0400471 // TODO(stephana): Remove this once all Mac machines are on the same
472 // OS version again. Move the call to swarmDimensions back to the
473 // creation of the TaskSpec struct below.
474 dimensions := swarmDimensions(parts)
475 if strings.Contains(name, "Mac") {
476 for idx, dim := range dimensions {
477 if strings.HasPrefix(dim, "os") {
478 dimensions[idx] = "os:Mac-10.12"
479 break
480 }
481 }
482 }
483
borenetdb182c72016-09-30 12:53:12 -0700484 // Add the task.
boreneted20a702016-10-20 11:04:31 -0700485 b.MustAddTask(name, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700486 CipdPackages: pkgs,
Stephan Altmueller5f3b9402017-03-20 13:38:45 -0400487 Dimensions: dimensions,
borenetdb182c72016-09-30 12:53:12 -0700488 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400489 "--workdir", "../../..", "compile",
skia.buildbots2478c732016-11-04 14:37:26 -0400490 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700491 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700492 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
493 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400494 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700495 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400496 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
497 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700498 },
Eric Boren7e3a3642017-06-14 15:25:31 -0400499 Isolate: relpath("compile_skia.isolate"),
borenetdb182c72016-09-30 12:53:12 -0700500 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700501 })
Eric Boren8615fe52016-12-12 14:30:12 -0500502 // All compile tasks are runnable as their own Job. Assert that the Job
503 // is listed in JOBS.
504 if !util.In(name, JOBS) {
505 glog.Fatalf("Job %q is missing from the JOBS list!", name)
506 }
borenetdb182c72016-09-30 12:53:12 -0700507 return name
508}
509
510// recreateSKPs generates a RecreateSKPs task. Returns the name of the last
511// task in the generated chain of tasks, which the Job should add as a
512// dependency.
boreneted20a702016-10-20 11:04:31 -0700513func recreateSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500514 b.MustAddTask(name, &specs.TaskSpec{
Eric Borenf9c09042017-04-17 07:50:20 -0400515 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren27225492017-02-01 15:56:55 -0500516 Dimensions: linuxGceDimensions(),
Eric Borenf5a90e82016-11-15 15:18:20 -0500517 ExecutionTimeout: 4 * time.Hour,
Eric Boren4b254b92016-11-08 12:55:32 -0500518 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400519 "--workdir", "../../..", "recreate_skps",
Eric Boren4b254b92016-11-08 12:55:32 -0500520 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
521 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500522 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
523 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400524 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500525 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
526 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
527 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
528 },
Eric Borenf5a90e82016-11-15 15:18:20 -0500529 IoTimeout: 40 * time.Minute,
Eric Boren7e3a3642017-06-14 15:25:31 -0400530 Isolate: relpath("compile_skia.isolate"),
Eric Borenf5a90e82016-11-15 15:18:20 -0500531 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500532 })
borenetdb182c72016-09-30 12:53:12 -0700533 return name
534}
535
Ravi Mistry01b48e72017-05-17 14:28:06 -0400536// updateMetaConfig generates a UpdateMetaConfig task. Returns the name of the
537// last task in the generated chain of tasks, which the Job should add as a
538// dependency.
539func updateMetaConfig(b *specs.TasksCfgBuilder, name string) string {
540 b.MustAddTask(name, &specs.TaskSpec{
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400541 CipdPackages: []*specs.CipdPackage{},
542 Dimensions: linuxGceDimensions(),
Ravi Mistry01b48e72017-05-17 14:28:06 -0400543 ExtraArgs: []string{
544 "--workdir", "../../..", "update_meta_config",
545 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
546 fmt.Sprintf("buildername=%s", name),
547 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
548 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
549 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
550 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
551 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
552 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
553 },
Eric Boren7e3a3642017-06-14 15:25:31 -0400554 Isolate: relpath("meta_config.isolate"),
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400555 Priority: 0.8,
Ravi Mistry01b48e72017-05-17 14:28:06 -0400556 })
557 return name
558}
559
borenetdb182c72016-09-30 12:53:12 -0700560// ctSKPs generates a CT SKPs task. Returns the name of the last task in the
561// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700562func ctSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500563 b.MustAddTask(name, &specs.TaskSpec{
564 CipdPackages: []*specs.CipdPackage{},
565 Dimensions: []string{"pool:SkiaCT"},
566 ExecutionTimeout: 24 * time.Hour,
567 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400568 "--workdir", "../../..", "ct_skps",
Eric Boren4b254b92016-11-08 12:55:32 -0500569 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
570 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500571 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
572 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400573 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500574 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
575 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
576 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
577 },
578 IoTimeout: time.Hour,
Eric Boren7e3a3642017-06-14 15:25:31 -0400579 Isolate: relpath("ct_skps_skia.isolate"),
Eric Boren4b254b92016-11-08 12:55:32 -0500580 Priority: 0.8,
581 })
borenetdb182c72016-09-30 12:53:12 -0700582 return name
583}
584
585// housekeeper generates a Housekeeper task. Returns the name of the last task
586// in the generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700587func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500588 b.MustAddTask(name, &specs.TaskSpec{
Eric Boren22f5ef72016-12-02 11:01:33 -0500589 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren4b254b92016-11-08 12:55:32 -0500590 Dependencies: []string{compileTaskName},
Eric Boren27225492017-02-01 15:56:55 -0500591 Dimensions: linuxGceDimensions(),
Eric Boren4b254b92016-11-08 12:55:32 -0500592 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400593 "--workdir", "../../..", "housekeeper",
Eric Boren4b254b92016-11-08 12:55:32 -0500594 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
595 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500596 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
597 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400598 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500599 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
600 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
601 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
602 },
Eric Boren7e3a3642017-06-14 15:25:31 -0400603 Isolate: relpath("housekeeper_skia.isolate"),
Eric Boren4b254b92016-11-08 12:55:32 -0500604 Priority: 0.8,
605 })
borenetdb182c72016-09-30 12:53:12 -0700606 return name
607}
608
borenet2dbbfa52016-10-14 06:32:09 -0700609// infra generates an infra_tests task. Returns the name of the last task in the
610// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700611func infra(b *specs.TasksCfgBuilder, name string) string {
612 b.MustAddTask(name, &specs.TaskSpec{
Eric Borenade69202017-04-13 10:00:43 -0400613 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren27225492017-02-01 15:56:55 -0500614 Dimensions: linuxGceDimensions(),
borenet2dbbfa52016-10-14 06:32:09 -0700615 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400616 "--workdir", "../../..", "infra",
skia.buildbots2478c732016-11-04 14:37:26 -0400617 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenet2dbbfa52016-10-14 06:32:09 -0700618 fmt.Sprintf("buildername=%s", name),
borenet2dbbfa52016-10-14 06:32:09 -0700619 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
620 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400621 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet2dbbfa52016-10-14 06:32:09 -0700622 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400623 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
624 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenet2dbbfa52016-10-14 06:32:09 -0700625 },
Eric Boren7e3a3642017-06-14 15:25:31 -0400626 Isolate: relpath("infra_skia.isolate"),
borenet2dbbfa52016-10-14 06:32:09 -0700627 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700628 })
borenet2dbbfa52016-10-14 06:32:09 -0700629 return name
630}
631
borenetdb182c72016-09-30 12:53:12 -0700632// doUpload indicates whether the given Job should upload its results.
633func doUpload(name string) bool {
Eric Boren27225492017-02-01 15:56:55 -0500634 for _, s := range CONFIG.NoUpload {
635 m, err := regexp.MatchString(s, name)
636 if err != nil {
637 glog.Fatal(err)
638 }
639 if m {
borenetdb182c72016-09-30 12:53:12 -0700640 return false
641 }
642 }
643 return true
644}
645
646// test generates a Test task. Returns the name of the last task in the
647// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700648func test(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500649 s := &specs.TaskSpec{
Eric Boren1f2f64b2016-11-09 18:35:15 -0500650 CipdPackages: pkgs,
651 Dependencies: []string{compileTaskName},
652 Dimensions: swarmDimensions(parts),
653 ExecutionTimeout: 4 * time.Hour,
654 Expiration: 20 * time.Hour,
borenetdb182c72016-09-30 12:53:12 -0700655 ExtraArgs: []string{
Eric Boren768f52f2017-04-10 08:14:33 -0400656 "--workdir", "../../..", "test",
skia.buildbots2478c732016-11-04 14:37:26 -0400657 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700658 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700659 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
660 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400661 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700662 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400663 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
664 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700665 },
Eric Boren5d9f3bf2017-02-22 08:36:03 -0500666 IoTimeout: 40 * time.Minute,
Eric Boren7e3a3642017-06-14 15:25:31 -0400667 Isolate: relpath("test_skia.isolate"),
Eric Boren5d9f3bf2017-02-22 08:36:03 -0500668 MaxAttempts: 1,
669 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500670 }
Eric Boren23a6ec62017-04-07 08:31:22 -0400671 if useBundledRecipes(parts) {
Eric Boren8b3f9e62017-04-04 09:06:16 -0400672 s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME)
Eric Boren23a6ec62017-04-07 08:31:22 -0400673 if strings.Contains(parts["os"], "Win") {
Eric Boren7e3a3642017-06-14 15:25:31 -0400674 s.Isolate = relpath("test_skia_bundled_win.isolate")
Eric Boren23a6ec62017-04-07 08:31:22 -0400675 } else {
Eric Boren7e3a3642017-06-14 15:25:31 -0400676 s.Isolate = relpath("test_skia_bundled_unix.isolate")
Eric Boren23a6ec62017-04-07 08:31:22 -0400677 }
Eric Boren8b3f9e62017-04-04 09:06:16 -0400678 }
Kevin Lubick90189522017-05-15 08:30:27 -0400679 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
680 s.Dependencies = append(s.Dependencies, deps...)
Kevin Lubick07072942017-05-11 13:35:23 -0400681 }
Eric Boren4b254b92016-11-08 12:55:32 -0500682 if strings.Contains(parts["extra_config"], "Valgrind") {
683 s.ExecutionTimeout = 9 * time.Hour
684 s.Expiration = 48 * time.Hour
685 s.IoTimeout = time.Hour
Eric Borend696df72017-05-31 15:09:10 -0400686 s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind"))
Eric Boren4b254b92016-11-08 12:55:32 -0500687 } else if strings.Contains(parts["extra_config"], "MSAN") {
688 s.ExecutionTimeout = 9 * time.Hour
Ben Wagnera6b2ba22017-06-08 10:34:17 -0400689 } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" {
690 // skia:6737
691 s.ExecutionTimeout = 6 * time.Hour
Eric Boren4b254b92016-11-08 12:55:32 -0500692 }
693 b.MustAddTask(name, s)
694
borenetdb182c72016-09-30 12:53:12 -0700695 // Upload results if necessary.
696 if doUpload(name) {
697 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700698 b.MustAddTask(uploadName, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700699 Dependencies: []string{name},
Eric Boren27225492017-02-01 15:56:55 -0500700 Dimensions: linuxGceDimensions(),
borenetdb182c72016-09-30 12:53:12 -0700701 ExtraArgs: []string{
702 "--workdir", "../../..", "upload_dm_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400703 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700704 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700705 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
706 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400707 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700708 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400709 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
710 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
Eric Boren965861b2017-02-06 15:38:41 -0500711 fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketGm),
borenetdb182c72016-09-30 12:53:12 -0700712 },
Eric Boren7e3a3642017-06-14 15:25:31 -0400713 Isolate: relpath("upload_dm_results.isolate"),
borenetdb182c72016-09-30 12:53:12 -0700714 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700715 })
borenetdb182c72016-09-30 12:53:12 -0700716 return uploadName
717 }
718 return name
719}
720
721// perf generates a Perf task. Returns the name of the last task in the
722// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700723func perf(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Eric Boren768f52f2017-04-10 08:14:33 -0400724 recipe := "perf"
Eric Boren7e3a3642017-06-14 15:25:31 -0400725 isolate := relpath("perf_skia.isolate")
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500726 if strings.Contains(parts["extra_config"], "Skpbench") {
Eric Boren768f52f2017-04-10 08:14:33 -0400727 recipe = "skpbench"
Eric Boren7e3a3642017-06-14 15:25:31 -0400728 isolate = relpath("skpbench_skia.isolate")
Eric Boren23a6ec62017-04-07 08:31:22 -0400729 if useBundledRecipes(parts) {
730 if strings.Contains(parts["os"], "Win") {
Eric Boren7e3a3642017-06-14 15:25:31 -0400731 isolate = relpath("skpbench_skia_bundled_win.isolate")
Eric Boren23a6ec62017-04-07 08:31:22 -0400732 } else {
Eric Boren7e3a3642017-06-14 15:25:31 -0400733 isolate = relpath("skpbench_skia_bundled_unix.isolate")
Eric Boren23a6ec62017-04-07 08:31:22 -0400734 }
Eric Boren8b3f9e62017-04-04 09:06:16 -0400735 }
Eric Boren23a6ec62017-04-07 08:31:22 -0400736 } else if useBundledRecipes(parts) {
737 if strings.Contains(parts["os"], "Win") {
Eric Boren7e3a3642017-06-14 15:25:31 -0400738 isolate = relpath("perf_skia_bundled_win.isolate")
Eric Boren23a6ec62017-04-07 08:31:22 -0400739 } else {
Eric Boren7e3a3642017-06-14 15:25:31 -0400740 isolate = relpath("perf_skia_bundled_unix.isolate")
Eric Boren23a6ec62017-04-07 08:31:22 -0400741 }
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500742 }
Eric Boren4b254b92016-11-08 12:55:32 -0500743 s := &specs.TaskSpec{
Eric Boren1f2f64b2016-11-09 18:35:15 -0500744 CipdPackages: pkgs,
745 Dependencies: []string{compileTaskName},
746 Dimensions: swarmDimensions(parts),
747 ExecutionTimeout: 4 * time.Hour,
748 Expiration: 20 * time.Hour,
borenetdb182c72016-09-30 12:53:12 -0700749 ExtraArgs: []string{
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500750 "--workdir", "../../..", recipe,
skia.buildbots2478c732016-11-04 14:37:26 -0400751 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700752 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700753 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
754 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400755 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700756 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400757 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
758 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700759 },
Eric Boren5d9f3bf2017-02-22 08:36:03 -0500760 IoTimeout: 40 * time.Minute,
761 Isolate: isolate,
762 MaxAttempts: 1,
763 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500764 }
Eric Boren23a6ec62017-04-07 08:31:22 -0400765 if useBundledRecipes(parts) {
Eric Boren8b3f9e62017-04-04 09:06:16 -0400766 s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME)
767 }
Kevin Lubick90189522017-05-15 08:30:27 -0400768 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
769 s.Dependencies = append(s.Dependencies, deps...)
770 }
771
Eric Boren4b254b92016-11-08 12:55:32 -0500772 if strings.Contains(parts["extra_config"], "Valgrind") {
773 s.ExecutionTimeout = 9 * time.Hour
774 s.Expiration = 48 * time.Hour
775 s.IoTimeout = time.Hour
Eric Borenc5a073d2017-06-01 07:13:33 -0400776 s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind"))
Eric Boren4b254b92016-11-08 12:55:32 -0500777 } else if strings.Contains(parts["extra_config"], "MSAN") {
778 s.ExecutionTimeout = 9 * time.Hour
Ben Wagnera6b2ba22017-06-08 10:34:17 -0400779 } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" {
780 // skia:6737
781 s.ExecutionTimeout = 6 * time.Hour
Eric Boren4b254b92016-11-08 12:55:32 -0500782 }
783 b.MustAddTask(name, s)
784
borenetdb182c72016-09-30 12:53:12 -0700785 // Upload results if necessary.
786 if strings.Contains(name, "Release") && doUpload(name) {
787 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700788 b.MustAddTask(uploadName, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700789 Dependencies: []string{name},
Eric Boren27225492017-02-01 15:56:55 -0500790 Dimensions: linuxGceDimensions(),
borenetdb182c72016-09-30 12:53:12 -0700791 ExtraArgs: []string{
792 "--workdir", "../../..", "upload_nano_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400793 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700794 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700795 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
796 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400797 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700798 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400799 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
800 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
Eric Boren965861b2017-02-06 15:38:41 -0500801 fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketNano),
borenetdb182c72016-09-30 12:53:12 -0700802 },
Eric Boren7e3a3642017-06-14 15:25:31 -0400803 Isolate: relpath("upload_nano_results.isolate"),
borenetdb182c72016-09-30 12:53:12 -0700804 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700805 })
borenetdb182c72016-09-30 12:53:12 -0700806 return uploadName
807 }
808 return name
809}
810
811// process generates tasks and jobs for the given job name.
boreneted20a702016-10-20 11:04:31 -0700812func process(b *specs.TasksCfgBuilder, name string) {
borenetdb182c72016-09-30 12:53:12 -0700813 deps := []string{}
814
Eric Boren8b3f9e62017-04-04 09:06:16 -0400815 // Bundle Recipes.
816 if name == BUNDLE_RECIPES_NAME {
817 deps = append(deps, bundleRecipes(b))
818 }
819
Kevin Lubick07072942017-05-11 13:35:23 -0400820 // Isolate CIPD assets.
Kevin Lubick07072942017-05-11 13:35:23 -0400821 if _, ok := ISOLATE_ASSET_MAPPING[name]; ok {
822 deps = append(deps, isolateCIPDAsset(b, name))
823 }
824
borenetdb182c72016-09-30 12:53:12 -0700825 parts, err := jobNameSchema.ParseJobName(name)
826 if err != nil {
827 glog.Fatal(err)
828 }
829
830 // RecreateSKPs.
831 if strings.Contains(name, "RecreateSKPs") {
boreneted20a702016-10-20 11:04:31 -0700832 deps = append(deps, recreateSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -0700833 }
834
Ravi Mistry01b48e72017-05-17 14:28:06 -0400835 // UpdateMetaConfig bot.
836 if strings.Contains(name, "UpdateMetaConfig") {
837 deps = append(deps, updateMetaConfig(b, name))
838 }
839
borenetdb182c72016-09-30 12:53:12 -0700840 // CT bots.
841 if strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700842 deps = append(deps, ctSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -0700843 }
844
borenet2dbbfa52016-10-14 06:32:09 -0700845 // Infra tests.
846 if name == "Housekeeper-PerCommit-InfraTests" {
boreneted20a702016-10-20 11:04:31 -0700847 deps = append(deps, infra(b, name))
borenet2dbbfa52016-10-14 06:32:09 -0700848 }
849
borenetdb182c72016-09-30 12:53:12 -0700850 // Compile bots.
851 if parts["role"] == "Build" {
boreneted20a702016-10-20 11:04:31 -0700852 deps = append(deps, compile(b, name, parts))
borenetdb182c72016-09-30 12:53:12 -0700853 }
854
Eric Borenf5a90e82016-11-15 15:18:20 -0500855 // Most remaining bots need a compile task.
borenetdb182c72016-09-30 12:53:12 -0700856 compileTaskName := deriveCompileTaskName(name, parts)
borenet52383432016-10-17 10:17:53 -0700857 compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName)
858 if err != nil {
859 glog.Fatal(err)
860 }
Eric Boren628e78b2016-11-17 11:33:27 -0500861 // These bots do not need a compile task.
Eric Borenf5a90e82016-11-15 15:18:20 -0500862 if parts["role"] != "Build" &&
Eric Borenb8ab7f72017-04-10 11:00:09 -0400863 name != "Housekeeper-PerCommit-BundleRecipes" &&
Eric Borenf5a90e82016-11-15 15:18:20 -0500864 name != "Housekeeper-PerCommit-InfraTests" &&
Eric Boren71b762f2016-11-30 14:05:16 -0500865 !strings.Contains(name, "RecreateSKPs") &&
Ravi Mistry01b48e72017-05-17 14:28:06 -0400866 !strings.Contains(name, "UpdateMetaConfig") &&
Ben Wagner50b84682017-06-12 13:03:29 -0400867 !strings.Contains(name, "-CT_") &&
868 !strings.Contains(name, "Housekeeper-PerCommit-Isolate") {
boreneted20a702016-10-20 11:04:31 -0700869 compile(b, compileTaskName, compileTaskParts)
borenet52383432016-10-17 10:17:53 -0700870 }
borenetdb182c72016-09-30 12:53:12 -0700871
872 // Housekeeper.
Eric Boren22f5ef72016-12-02 11:01:33 -0500873 if name == "Housekeeper-PerCommit" {
boreneted20a702016-10-20 11:04:31 -0700874 deps = append(deps, housekeeper(b, name, compileTaskName))
borenetdb182c72016-09-30 12:53:12 -0700875 }
876
877 // Common assets needed by the remaining bots.
Kevin Lubick07072942017-05-11 13:35:23 -0400878
879 pkgs := []*specs.CipdPackage{}
880
Kevin Lubick90189522017-05-15 08:30:27 -0400881 if deps := getIsolatedCIPDDeps(parts); len(deps) == 0 {
Kevin Lubick07072942017-05-11 13:35:23 -0400882 pkgs = []*specs.CipdPackage{
883 b.MustGetCipdPackageFromAsset("skimage"),
884 b.MustGetCipdPackageFromAsset("skp"),
885 b.MustGetCipdPackageFromAsset("svg"),
886 }
borenetdb182c72016-09-30 12:53:12 -0700887 }
Kevin Lubick90189522017-05-15 08:30:27 -0400888
Eric Boren4b254b92016-11-08 12:55:32 -0500889 if strings.Contains(name, "Ubuntu") && strings.Contains(name, "SAN") {
890 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
891 }
Kevin Lubick35115eb2017-02-17 10:25:34 -0500892 if strings.Contains(name, "Ubuntu16") {
893 if strings.Contains(name, "Vulkan") {
894 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
895 }
Kevin Lubick0a51b482017-02-06 12:45:29 -0500896 if strings.Contains(name, "Release") {
897 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_release"))
898 } else {
899 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_debug"))
900 }
901 }
borenetdb182c72016-09-30 12:53:12 -0700902
903 // Test bots.
Eric Boren71b762f2016-11-30 14:05:16 -0500904 if parts["role"] == "Test" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700905 deps = append(deps, test(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -0700906 }
907
908 // Perf bots.
Eric Boren71b762f2016-11-30 14:05:16 -0500909 if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700910 deps = append(deps, perf(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -0700911 }
912
913 // Add the Job spec.
Eric Borenf5a90e82016-11-15 15:18:20 -0500914 j := &specs.JobSpec{
borenetdb182c72016-09-30 12:53:12 -0700915 Priority: 0.8,
916 TaskSpecs: deps,
Eric Borenf5a90e82016-11-15 15:18:20 -0500917 }
918 if name == "Housekeeper-Nightly-RecreateSKPs_Canary" {
919 j.Trigger = "nightly"
920 }
Ravi Mistry01b48e72017-05-17 14:28:06 -0400921 if name == "Housekeeper-Nightly-UpdateMetaConfig" {
922 j.Trigger = "nightly"
923 }
Eric Borenf5a90e82016-11-15 15:18:20 -0500924 if name == "Housekeeper-Weekly-RecreateSKPs" {
925 j.Trigger = "weekly"
926 }
Eric Boren71b762f2016-11-30 14:05:16 -0500927 if name == "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs" {
928 j.Trigger = "weekly"
929 }
Eric Boren8615fe52016-12-12 14:30:12 -0500930 b.MustAddJob(name, j)
borenetdb182c72016-09-30 12:53:12 -0700931}
932
Eric Boren27225492017-02-01 15:56:55 -0500933func loadJson(flag *string, defaultFlag string, val interface{}) {
934 if *flag == "" {
935 *flag = defaultFlag
936 }
937 b, err := ioutil.ReadFile(*flag)
938 if err != nil {
939 glog.Fatal(err)
940 }
941 if err := json.Unmarshal(b, val); err != nil {
942 glog.Fatal(err)
943 }
944}
945
borenetdb182c72016-09-30 12:53:12 -0700946// Regenerate the tasks.json file.
947func main() {
boreneted20a702016-10-20 11:04:31 -0700948 b := specs.MustNewTasksCfgBuilder()
Eric Boren27225492017-02-01 15:56:55 -0500949 b.SetAssetsDir(*assetsDir)
950 infraBots := path.Join(b.CheckoutRoot(), "infra", "bots")
951
952 // Load the jobs from a JSON file.
953 loadJson(jobsFile, path.Join(infraBots, "jobs.json"), &JOBS)
954
Eric Boren27225492017-02-01 15:56:55 -0500955 // Load general config information from a JSON file.
956 loadJson(cfgFile, path.Join(infraBots, "cfg.json"), &CONFIG)
957
borenetdb182c72016-09-30 12:53:12 -0700958 // Create the JobNameSchema.
Eric Boren1f8be682017-02-07 09:16:30 -0500959 if *builderNameSchemaFile == "" {
960 *builderNameSchemaFile = path.Join(b.CheckoutRoot(), "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json")
961 }
962 schema, err := NewJobNameSchema(*builderNameSchemaFile)
borenetdb182c72016-09-30 12:53:12 -0700963 if err != nil {
964 glog.Fatal(err)
965 }
966 jobNameSchema = schema
967
borenetdb182c72016-09-30 12:53:12 -0700968 // Create Tasks and Jobs.
boreneted20a702016-10-20 11:04:31 -0700969 for _, name := range JOBS {
970 process(b, name)
borenetdb182c72016-09-30 12:53:12 -0700971 }
972
boreneted20a702016-10-20 11:04:31 -0700973 b.MustFinish()
borenetdb182c72016-09-30 12:53:12 -0700974}
975
976// TODO(borenet): The below really belongs in its own file, probably next to the
977// builder_name_schema.json file.
978
979// JobNameSchema is a struct used for (de)constructing Job names in a
980// predictable format.
981type JobNameSchema struct {
982 Schema map[string][]string `json:"builder_name_schema"`
983 Sep string `json:"builder_name_sep"`
984}
985
986// NewJobNameSchema returns a JobNameSchema instance based on the given JSON
987// file.
988func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) {
989 var rv JobNameSchema
990 f, err := os.Open(jsonFile)
991 if err != nil {
992 return nil, err
993 }
994 defer util.Close(f)
995 if err := json.NewDecoder(f).Decode(&rv); err != nil {
996 return nil, err
997 }
998 return &rv, nil
999}
1000
1001// ParseJobName splits the given Job name into its component parts, according
1002// to the schema.
1003func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) {
1004 split := strings.Split(n, s.Sep)
1005 if len(split) < 2 {
1006 return nil, fmt.Errorf("Invalid job name: %q", n)
1007 }
1008 role := split[0]
1009 split = split[1:]
1010 keys, ok := s.Schema[role]
1011 if !ok {
1012 return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role)
1013 }
1014 extraConfig := ""
1015 if len(split) == len(keys)+1 {
1016 extraConfig = split[len(split)-1]
1017 split = split[:len(split)-1]
1018 }
1019 if len(split) != len(keys) {
1020 return nil, fmt.Errorf("Invalid job name; %q has incorrect number of parts.", n)
1021 }
1022 rv := make(map[string]string, len(keys)+2)
1023 rv["role"] = role
1024 if extraConfig != "" {
1025 rv["extra_config"] = extraConfig
1026 }
1027 for i, k := range keys {
1028 rv[k] = split[i]
1029 }
1030 return rv, nil
1031}
1032
1033// MakeJobName assembles the given parts of a Job name, according to the schema.
1034func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) {
1035 role, ok := parts["role"]
1036 if !ok {
1037 return "", fmt.Errorf("Invalid job parts; jobs must have a role.")
1038 }
1039 keys, ok := s.Schema[role]
1040 if !ok {
1041 return "", fmt.Errorf("Invalid job parts; unknown role %q", role)
1042 }
1043 rvParts := make([]string, 0, len(parts))
1044 rvParts = append(rvParts, role)
1045 for _, k := range keys {
1046 v, ok := parts[k]
1047 if !ok {
1048 return "", fmt.Errorf("Invalid job parts; missing %q", k)
1049 }
1050 rvParts = append(rvParts, v)
1051 }
1052 if _, ok := parts["extra_config"]; ok {
1053 rvParts = append(rvParts, parts["extra_config"])
1054 }
1055 return strings.Join(rvParts, s.Sep), nil
1056}