borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1 | // 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 | |
| 5 | package main |
| 6 | |
| 7 | /* |
| 8 | Generate the tasks.json file. |
| 9 | */ |
| 10 | |
| 11 | import ( |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 12 | "encoding/json" |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 13 | "flag" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 14 | "fmt" |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 15 | "io/ioutil" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 16 | "os" |
| 17 | "path" |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 18 | "path/filepath" |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 19 | "regexp" |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 20 | "runtime" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 21 | "sort" |
| 22 | "strings" |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 23 | "time" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 24 | |
| 25 | "github.com/skia-dev/glog" |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 26 | "go.skia.org/infra/go/sklog" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 27 | "go.skia.org/infra/go/util" |
| 28 | "go.skia.org/infra/task_scheduler/go/specs" |
| 29 | ) |
| 30 | |
| 31 | const ( |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 32 | 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 Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 36 | |
Ben Wagner | 82cbdba | 2017-08-01 15:12:49 -0400 | [diff] [blame] | 37 | DEFAULT_OS_DEBIAN = "Debian-9.1" |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 38 | DEFAULT_OS_UBUNTU = "Ubuntu-14.04" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 39 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 40 | // Name prefix for upload jobs. |
| 41 | PREFIX_UPLOAD = "Upload" |
| 42 | ) |
| 43 | |
| 44 | var ( |
| 45 | // "Constants" |
| 46 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 47 | // Top-level list of all jobs to run at each commit; loaded from |
| 48 | // jobs.json. |
| 49 | JOBS []string |
| 50 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 51 | // General configuration information. |
| 52 | CONFIG struct { |
Eric Boren | 965861b | 2017-02-06 15:38:41 -0500 | [diff] [blame] | 53 | GsBucketGm string `json:"gs_bucket_gm"` |
| 54 | GsBucketNano string `json:"gs_bucket_nano"` |
| 55 | NoUpload []string `json:"no_upload"` |
| 56 | Pool string `json:"pool"` |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 59 | // 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 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 63 | // Defines the structure of job names. |
| 64 | jobNameSchema *JobNameSchema |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 65 | |
Eric Boren | f4a5fc7 | 2017-06-06 08:27:09 -0400 | [diff] [blame] | 66 | // 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 Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 78 | // Flags. |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 79 | 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 Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 82 | jobsFile = flag.String("jobs", "", "JSON file containing jobs to run.") |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 83 | ) |
| 84 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 85 | // linuxGceDimensions are the Swarming dimensions for Linux GCE |
| 86 | // instances. |
| 87 | func linuxGceDimensions() []string { |
| 88 | return []string{ |
| 89 | "cpu:x86-64-avx2", |
| 90 | "gpu:none", |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 91 | fmt.Sprintf("os:%s", DEFAULT_OS_DEBIAN), |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 92 | fmt.Sprintf("pool:%s", CONFIG.Pool), |
| 93 | } |
| 94 | } |
| 95 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 96 | // deriveCompileTaskName returns the name of a compile task based on the given |
| 97 | // job name. |
| 98 | func deriveCompileTaskName(jobName string, parts map[string]string) string { |
| 99 | if parts["role"] == "Housekeeper" { |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 100 | return "Build-Debian9-GCC-x86_64-Release-Shared" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 101 | } else if parts["role"] == "Test" || parts["role"] == "Perf" { |
| 102 | task_os := parts["os"] |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 103 | ec := []string{} |
| 104 | if val := parts["extra_config"]; val != "" { |
| 105 | ec = strings.Split(val, "_") |
Chris Dalton | 97598a5 | 2017-07-18 10:49:07 -0600 | [diff] [blame] | 106 | ignore := []string{"Skpbench", "AbandonGpuContext", "PreAbandonGpuContext", "Valgrind", "ReleaseAndAbandonGpuContext", "CCPR"} |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 107 | 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 Boren | 6ec17e3 | 2017-04-26 14:25:29 -0400 | [diff] [blame] | 114 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 115 | if task_os == "Android" { |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 116 | if !util.In("Android", ec) { |
| 117 | ec = append([]string{"Android"}, ec...) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 118 | } |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 119 | task_os = "Debian9" |
Kevin Lubick | dcd2a90 | 2017-03-08 14:01:01 -0500 | [diff] [blame] | 120 | } else if task_os == "Chromecast" { |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 121 | task_os = "Debian9" |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 122 | ec = append([]string{"Chromecast"}, ec...) |
Kevin Lubick | cb6f398 | 2017-04-07 10:04:08 -0400 | [diff] [blame] | 123 | } else if strings.Contains(task_os, "ChromeOS") { |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 124 | ec = append([]string{"Chromebook", "ARM", "GLES"}, ec...) |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 125 | task_os = "Debian9" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 126 | } else if task_os == "iOS" { |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 127 | ec = append([]string{task_os}, ec...) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 128 | task_os = "Mac" |
| 129 | } else if strings.Contains(task_os, "Win") { |
| 130 | task_os = "Win" |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 131 | } else if strings.Contains(task_os, "Ubuntu") || strings.Contains(task_os, "Debian") { |
| 132 | task_os = "Debian9" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 133 | } |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 134 | jobNameMap := map[string]string{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 135 | "role": "Build", |
| 136 | "os": task_os, |
| 137 | "compiler": parts["compiler"], |
| 138 | "target_arch": parts["arch"], |
| 139 | "configuration": parts["configuration"], |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 140 | } |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 141 | if len(ec) > 0 { |
| 142 | jobNameMap["extra_config"] = strings.Join(ec, "_") |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 143 | } |
| 144 | name, err := jobNameSchema.MakeJobName(jobNameMap) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 145 | 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. |
| 155 | func swarmDimensions(parts map[string]string) []string { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 156 | 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. |
| 163 | func defaultSwarmDimensions(parts map[string]string) []string { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 164 | d := map[string]string{ |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 165 | "pool": CONFIG.Pool, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 166 | } |
| 167 | if os, ok := parts["os"]; ok { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 168 | d["os"], ok = map[string]string{ |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 169 | "Android": "Android", |
| 170 | "Chromecast": "Android", |
Kevin Lubick | cb6f398 | 2017-04-07 10:04:08 -0400 | [diff] [blame] | 171 | "ChromeOS": "ChromeOS", |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 172 | "Debian9": DEFAULT_OS_DEBIAN, |
Ben Wagner | d76a184 | 2017-08-17 17:17:26 -0400 | [diff] [blame] | 173 | "Mac": "Mac-10.12", |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 174 | "Ubuntu14": DEFAULT_OS_UBUNTU, |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 175 | "Ubuntu16": "Ubuntu-16.10", |
Eric Boren | 810c2b6 | 2017-07-11 08:11:15 -0400 | [diff] [blame] | 176 | "Ubuntu17": "Ubuntu-17.04", |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 177 | "Win": "Windows-2008ServerR2-SP1", |
Ben Wagner | 40226b4 | 2017-05-02 13:13:13 -0400 | [diff] [blame] | 178 | "Win10": "Windows-10-15063", |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 179 | "Win2k8": "Windows-2008ServerR2-SP1", |
Ben Wagner | 56738d8 | 2017-04-18 15:38:15 -0400 | [diff] [blame] | 180 | "Win7": "Windows-7-SP1", |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 181 | "Win8": "Windows-8.1-SP0", |
Stephan Altmueller | ddad85b | 2017-05-19 13:08:19 -0400 | [diff] [blame] | 182 | "iOS": "iOS-10.3.1", |
Eric Boren | 54ff2fc | 2016-12-02 12:09:10 -0500 | [diff] [blame] | 183 | }[os] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 184 | if !ok { |
| 185 | glog.Fatalf("Entry %q not found in OS mapping.", os) |
| 186 | } |
Ben Wagner | ae532f6 | 2017-08-02 23:24:16 -0400 | [diff] [blame] | 187 | // These machines have a different Windows image. |
| 188 | if parts["model"] == "Golo" && os == "Win10" && parts["cpu_or_gpu_value"] == "GT610" { |
Ben Wagner | 7355737 | 2016-12-29 16:27:03 -0500 | [diff] [blame] | 189 | d["os"] = "Windows-10-10586" |
Ben Wagner | 17f811b | 2016-12-22 08:40:14 -0500 | [diff] [blame] | 190 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 191 | } else { |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 192 | d["os"] = DEFAULT_OS_DEBIAN |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 193 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 194 | if parts["role"] == "Test" || parts["role"] == "Perf" { |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 195 | if strings.Contains(parts["os"], "Android") || strings.Contains(parts["os"], "Chromecast") { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 196 | // For Android, the device type is a better dimension |
| 197 | // than CPU or GPU. |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 198 | deviceInfo, ok := map[string][]string{ |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 199 | "AndroidOne": {"sprout", "MOB30Q"}, |
| 200 | "Chorizo": {"chorizo", "1.24_82923"}, |
| 201 | "Ci20": {"ci20", "NRD90M"}, |
| 202 | "GalaxyJ5": {"j5xnlte", "MMB29M"}, |
| 203 | "GalaxyS6": {"zerofltetmo", "MMB29K"}, |
| 204 | "GalaxyS7_G930A": {"heroqlteatt", "NRD90M_G930AUCS4BQC2"}, |
| 205 | "GalaxyS7_G930FD": {"herolte", "NRD90M_G930FXXU1DQAS"}, |
| 206 | "GalaxyTab3": {"goyawifi", "JDQ39"}, |
| 207 | "MotoG4": {"athene", "NPJ25.93-14"}, |
| 208 | "NVIDIA_Shield": {"foster", "NRD90M"}, |
| 209 | "Nexus10": {"manta", "LMY49J"}, |
| 210 | "Nexus5": {"hammerhead", "M4B30Z"}, |
| 211 | "Nexus6": {"shamu", "M"}, |
| 212 | "Nexus6p": {"angler", "OPP1.170223.012"}, |
| 213 | "Nexus7": {"grouper", "LMY47V"}, |
| 214 | "Nexus7v2": {"flo", "M"}, |
| 215 | "NexusPlayer": {"fugu", "OPP2.170420.017"}, |
| 216 | "Pixel": {"sailfish", "NMF26Q"}, |
Ben Wagner | 11f844e | 2017-09-06 14:29:17 -0400 | [diff] [blame^] | 217 | "PixelC": {"dragon", "OPR6.170623.010"}, |
Greg Daniel | c34aeb7 | 2017-06-14 11:09:19 -0400 | [diff] [blame] | 218 | "PixelXL": {"marlin", "OPP3.170518.006"}, |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 219 | }[parts["model"]] |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 220 | if !ok { |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 221 | glog.Fatalf("Entry %q not found in Android mapping.", parts["model"]) |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 222 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 223 | d["device_type"] = deviceInfo[0] |
| 224 | d["device_os"] = deviceInfo[1] |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 225 | } else if strings.Contains(parts["os"], "iOS") { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 226 | device, ok := map[string]string{ |
Eric Boren | 792079cf | 2016-11-09 14:03:20 -0500 | [diff] [blame] | 227 | "iPadMini4": "iPad5,1", |
Stephan Altmueller | 63e843d | 2017-04-25 11:38:38 -0400 | [diff] [blame] | 228 | "iPhone6": "iPhone7,2", |
| 229 | "iPhone7": "iPhone9,1", |
| 230 | "iPadPro": "iPad6,3", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 231 | }[parts["model"]] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 232 | if !ok { |
| 233 | glog.Fatalf("Entry %q not found in iOS mapping.", parts["model"]) |
| 234 | } |
| 235 | d["device"] = device |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 236 | } else if parts["cpu_or_gpu"] == "CPU" { |
| 237 | d["gpu"] = "none" |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 238 | cpu, ok := map[string]string{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 239 | "AVX": "x86-64", |
| 240 | "AVX2": "x86-64-avx2", |
| 241 | "SSE4": "x86-64", |
| 242 | }[parts["cpu_or_gpu_value"]] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 243 | if !ok { |
| 244 | glog.Fatalf("Entry %q not found in CPU mapping.", parts["cpu_or_gpu_value"]) |
| 245 | } |
| 246 | d["cpu"] = cpu |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 247 | if strings.Contains(parts["os"], "Win") && parts["cpu_or_gpu_value"] == "AVX2" { |
| 248 | // AVX2 is not correctly detected on Windows. Fall back on other |
| 249 | // dimensions to ensure that we correctly target machines which we know |
| 250 | // have AVX2 support. |
Eric Boren | 085bf7c | 2017-04-06 17:32:44 +0000 | [diff] [blame] | 251 | d["cpu"] = "x86-64" |
Ben Wagner | 56738d8 | 2017-04-18 15:38:15 -0400 | [diff] [blame] | 252 | if parts["model"] != "GCE" { |
| 253 | glog.Fatalf("Please double-check that %q supports AVX2 and update this assertion.", parts["model"]) |
| 254 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 255 | } |
| 256 | } else { |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 257 | if strings.Contains(parts["os"], "Win") { |
| 258 | gpu, ok := map[string]string{ |
| 259 | "AMDHD7770": "1002:683d-22.19.165.512", |
Ben Wagner | 0d2b091 | 2017-08-15 12:43:55 -0400 | [diff] [blame] | 260 | "GT610": "10de:104a-22.21.13.8205", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 261 | "GTX1070": "10de:1ba1-22.21.13.8205", |
| 262 | "GTX660": "10de:11c0-22.21.13.8205", |
| 263 | "GTX960": "10de:1401-22.21.13.8205", |
| 264 | "IntelHD530": "8086:1912-21.20.16.4590", |
Ben Wagner | 5698b00 | 2017-08-04 11:25:33 -0400 | [diff] [blame] | 265 | "IntelHD4400": "8086:0a16-20.19.15.4703", |
Ben Wagner | 3c28653 | 2017-08-11 10:35:57 -0400 | [diff] [blame] | 266 | "IntelHD4600": "8086:0412-20.19.15.4703", |
Ben Wagner | 8ab8f61 | 2017-08-17 13:53:09 -0400 | [diff] [blame] | 267 | "IntelHD615": "8086:591e-21.20.16.4590", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 268 | "IntelIris540": "8086:1926-21.20.16.4590", |
Ben Wagner | 3c28653 | 2017-08-11 10:35:57 -0400 | [diff] [blame] | 269 | "IntelIris6100": "8086:162b-20.19.15.4703", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 270 | "RadeonR9M470X": "1002:6646-22.19.165.512", |
Ben Wagner | ae532f6 | 2017-08-02 23:24:16 -0400 | [diff] [blame] | 271 | "QuadroP400": "10de:1cb3-22.21.13.8205", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 272 | }[parts["cpu_or_gpu_value"]] |
| 273 | if !ok { |
| 274 | glog.Fatalf("Entry %q not found in Win GPU mapping.", parts["cpu_or_gpu_value"]) |
| 275 | } |
| 276 | d["gpu"] = gpu |
Ben Wagner | 0843589 | 2017-02-18 23:28:26 -0500 | [diff] [blame] | 277 | |
Ben Wagner | 4b1df02 | 2017-06-15 12:28:04 -0400 | [diff] [blame] | 278 | // Specify cpu dimension for NUCs and ShuttleCs. We temporarily have two |
| 279 | // types of machines with a GTX960. |
| 280 | cpu, ok := map[string]string{ |
| 281 | "NUC6i7KYK": "x86-64-i7-6770HQ", |
| 282 | "ShuttleC": "x86-64-i7-6700K", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 283 | }[parts["model"]] |
| 284 | if ok { |
Ben Wagner | 4b1df02 | 2017-06-15 12:28:04 -0400 | [diff] [blame] | 285 | d["cpu"] = cpu |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 286 | } |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 287 | } else if strings.Contains(parts["os"], "Ubuntu") || strings.Contains(parts["os"], "Debian") { |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 288 | gpu, ok := map[string]string{ |
Ben Wagner | 2c600fb | 2017-08-14 14:58:19 -0400 | [diff] [blame] | 289 | "GT610": "10de:104a-384.59", |
| 290 | "GTX550Ti": "10de:1244-384.59", |
| 291 | "GTX660": "10de:11c0-384.59", |
| 292 | "GTX960": "10de:1401-384.59", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 293 | // Intel drivers come from CIPD, so no need to specify the version here. |
| 294 | "IntelBayTrail": "8086:0f31", |
| 295 | "IntelHD2000": "8086:0102", |
| 296 | "IntelHD405": "8086:22b1", |
| 297 | "IntelIris540": "8086:1926", |
Ben Wagner | fef8fdd | 2017-08-11 14:13:56 -0400 | [diff] [blame] | 298 | "IntelIris640": "8086:5926", |
Ben Wagner | c274ec4 | 2017-08-03 22:29:22 -0400 | [diff] [blame] | 299 | "QuadroP400": "10de:1cb3-384.59", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 300 | }[parts["cpu_or_gpu_value"]] |
| 301 | if !ok { |
| 302 | glog.Fatalf("Entry %q not found in Ubuntu GPU mapping.", parts["cpu_or_gpu_value"]) |
| 303 | } |
| 304 | d["gpu"] = gpu |
| 305 | } else if strings.Contains(parts["os"], "Mac") { |
| 306 | gpu, ok := map[string]string{ |
Ben Wagner | cc4221b | 2017-08-17 17:29:04 -0400 | [diff] [blame] | 307 | "IntelIris5100": "8086:0a2e", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 308 | }[parts["cpu_or_gpu_value"]] |
| 309 | if !ok { |
| 310 | glog.Fatalf("Entry %q not found in Mac GPU mapping.", parts["cpu_or_gpu_value"]) |
| 311 | } |
| 312 | d["gpu"] = gpu |
| 313 | } else if strings.Contains(parts["os"], "ChromeOS") { |
| 314 | gpu, ok := map[string]string{ |
Kevin Lubick | c14e5a7 | 2017-08-15 13:22:19 -0400 | [diff] [blame] | 315 | "MaliT604": "MaliT604", |
| 316 | "MaliT764": "MaliT764", |
| 317 | "MaliT860": "MaliT860", |
| 318 | "PowerVRGX6250": "PowerVRGX6250", |
| 319 | "TegraK1": "TegraK1", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 320 | }[parts["cpu_or_gpu_value"]] |
| 321 | if !ok { |
| 322 | glog.Fatalf("Entry %q not found in ChromeOS GPU mapping.", parts["cpu_or_gpu_value"]) |
| 323 | } |
| 324 | d["gpu"] = gpu |
| 325 | } else { |
| 326 | glog.Fatalf("Unknown GPU mapping for OS %q.", parts["os"]) |
Ben Wagner | 0843589 | 2017-02-18 23:28:26 -0500 | [diff] [blame] | 327 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 328 | } |
| 329 | } else { |
| 330 | d["gpu"] = "none" |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 331 | if d["os"] == DEFAULT_OS_DEBIAN { |
Kevin Lubick | 4610a9b | 2017-03-22 15:54:54 -0400 | [diff] [blame] | 332 | return linuxGceDimensions() |
| 333 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 334 | } |
Kevin Lubick | 4610a9b | 2017-03-22 15:54:54 -0400 | [diff] [blame] | 335 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 336 | rv := make([]string, 0, len(d)) |
| 337 | for k, v := range d { |
| 338 | rv = append(rv, fmt.Sprintf("%s:%s", k, v)) |
| 339 | } |
| 340 | sort.Strings(rv) |
| 341 | return rv |
| 342 | } |
| 343 | |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 344 | // relpath returns the relative path to the given file from the config file. |
| 345 | func relpath(f string) string { |
| 346 | _, filename, _, _ := runtime.Caller(0) |
| 347 | dir := path.Dir(filename) |
| 348 | rel := dir |
| 349 | if *cfgFile != "" { |
| 350 | rel = path.Dir(*cfgFile) |
| 351 | } |
| 352 | rv, err := filepath.Rel(rel, path.Join(dir, f)) |
| 353 | if err != nil { |
| 354 | sklog.Fatal(err) |
| 355 | } |
| 356 | return rv |
| 357 | } |
| 358 | |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 359 | // bundleRecipes generates the task to bundle and isolate the recipes. |
| 360 | func bundleRecipes(b *specs.TasksCfgBuilder) string { |
| 361 | b.MustAddTask(BUNDLE_RECIPES_NAME, &specs.TaskSpec{ |
Eric Boren | f4a5fc7 | 2017-06-06 08:27:09 -0400 | [diff] [blame] | 362 | CipdPackages: []*specs.CipdPackage{cipdGit1, cipdGit2}, |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 363 | Dimensions: linuxGceDimensions(), |
| 364 | ExtraArgs: []string{ |
| 365 | "--workdir", "../../..", "bundle_recipes", |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 366 | fmt.Sprintf("buildername=%s", BUNDLE_RECIPES_NAME), |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 367 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 368 | }, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 369 | Isolate: relpath("bundle_recipes.isolate"), |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 370 | Priority: 0.7, |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 371 | }) |
| 372 | return BUNDLE_RECIPES_NAME |
| 373 | } |
| 374 | |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 375 | // useBundledRecipes returns true iff the given bot should use bundled recipes |
| 376 | // instead of syncing recipe DEPS itself. |
| 377 | func useBundledRecipes(parts map[string]string) bool { |
| 378 | // Use bundled recipes for all test/perf tasks. |
| 379 | return true |
| 380 | } |
| 381 | |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 382 | type isolateAssetCfg struct { |
| 383 | isolateFile string |
| 384 | cipdPkg string |
| 385 | } |
| 386 | |
| 387 | var ISOLATE_ASSET_MAPPING = map[string]isolateAssetCfg{ |
| 388 | ISOLATE_SKIMAGE_NAME: { |
| 389 | isolateFile: "isolate_skimage.isolate", |
| 390 | cipdPkg: "skimage", |
| 391 | }, |
| 392 | ISOLATE_SKP_NAME: { |
| 393 | isolateFile: "isolate_skp.isolate", |
| 394 | cipdPkg: "skp", |
| 395 | }, |
| 396 | ISOLATE_SVG_NAME: { |
| 397 | isolateFile: "isolate_svg.isolate", |
| 398 | cipdPkg: "svg", |
| 399 | }, |
| 400 | } |
| 401 | |
| 402 | // bundleRecipes generates the task to bundle and isolate the recipes. |
| 403 | func isolateCIPDAsset(b *specs.TasksCfgBuilder, name string) string { |
| 404 | b.MustAddTask(name, &specs.TaskSpec{ |
| 405 | CipdPackages: []*specs.CipdPackage{ |
| 406 | b.MustGetCipdPackageFromAsset(ISOLATE_ASSET_MAPPING[name].cipdPkg), |
| 407 | }, |
| 408 | Dimensions: linuxGceDimensions(), |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 409 | Isolate: relpath(ISOLATE_ASSET_MAPPING[name].isolateFile), |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 410 | Priority: 0.7, |
| 411 | }) |
| 412 | return name |
| 413 | } |
| 414 | |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 415 | // getIsolatedCIPDDeps returns the slice of Isolate_* tasks a given task needs. |
| 416 | // This allows us to save time on I/O bound bots, like the RPIs. |
| 417 | func getIsolatedCIPDDeps(parts map[string]string) []string { |
| 418 | deps := []string{} |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 419 | // Only do this on the RPIs for now. Other, faster machines shouldn't see much |
| 420 | // benefit and we don't need the extra complexity, for now |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 421 | rpiOS := []string{"Android", "ChromeOS", "iOS"} |
| 422 | |
| 423 | if o := parts["os"]; strings.Contains(o, "Chromecast") { |
| 424 | // Chromecasts don't have enough disk space to fit all of the content, |
| 425 | // so we do a subset of the skps. |
| 426 | deps = append(deps, ISOLATE_SKP_NAME) |
| 427 | } else if e := parts["extra_config"]; strings.Contains(e, "Skpbench") { |
| 428 | // Skpbench only needs skps |
| 429 | deps = append(deps, ISOLATE_SKP_NAME) |
| 430 | } else if util.In(o, rpiOS) { |
| 431 | deps = append(deps, ISOLATE_SKP_NAME) |
| 432 | deps = append(deps, ISOLATE_SVG_NAME) |
| 433 | deps = append(deps, ISOLATE_SKIMAGE_NAME) |
| 434 | } |
| 435 | |
| 436 | return deps |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 437 | } |
| 438 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 439 | // compile generates a compile task. Returns the name of the last task in the |
| 440 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 441 | func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 442 | // Collect the necessary CIPD packages. |
| 443 | pkgs := []*specs.CipdPackage{} |
| 444 | |
| 445 | // Android bots require a toolchain. |
| 446 | if strings.Contains(name, "Android") { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 447 | if strings.Contains(name, "Mac") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 448 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_darwin")) |
Mike Klein | 86c2c0f | 2016-11-02 13:13:16 -0400 | [diff] [blame] | 449 | } else if strings.Contains(name, "Win") { |
Mike Klein | e9215f0 | 2016-11-02 15:44:26 -0400 | [diff] [blame] | 450 | pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows") |
| 451 | pkg.Path = "n" |
| 452 | pkgs = append(pkgs, pkg) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 453 | } else { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 454 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_linux")) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 455 | } |
Kevin Lubick | dcd2a90 | 2017-03-08 14:01:01 -0500 | [diff] [blame] | 456 | } else if strings.Contains(name, "Chromecast") { |
| 457 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("cast_toolchain")) |
Kevin Lubick | ffce079 | 2017-05-24 15:30:35 -0400 | [diff] [blame] | 458 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles")) |
Kevin Lubick | 261ea19 | 2017-04-05 07:32:45 -0400 | [diff] [blame] | 459 | } else if strings.Contains(name, "Chromebook") { |
| 460 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 461 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("armhf_sysroot")) |
Kevin Lubick | 671cd72 | 2017-04-12 10:50:18 -0400 | [diff] [blame] | 462 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles")) |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 463 | } else if strings.Contains(name, "Debian") { |
Kevin Lubick | 9c7dcac | 2017-01-18 09:24:56 -0500 | [diff] [blame] | 464 | if strings.Contains(name, "Clang") { |
| 465 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 466 | } |
| 467 | if strings.Contains(name, "Vulkan") { |
| 468 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk")) |
| 469 | } |
Mike Klein | 27dcee1 | 2016-11-09 16:31:42 -0500 | [diff] [blame] | 470 | } else if strings.Contains(name, "Win") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 471 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_toolchain")) |
Mike Klein | 8e3c42b | 2017-07-31 14:57:20 -0400 | [diff] [blame] | 472 | if strings.Contains(name, "Clang") { |
| 473 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_win")) |
| 474 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 475 | if strings.Contains(name, "Vulkan") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 476 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_vulkan_sdk")) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 477 | } |
| 478 | } |
| 479 | |
Stephan Altmueller | 5f3b940 | 2017-03-20 13:38:45 -0400 | [diff] [blame] | 480 | dimensions := swarmDimensions(parts) |
Stephan Altmueller | 5f3b940 | 2017-03-20 13:38:45 -0400 | [diff] [blame] | 481 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 482 | // Add the task. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 483 | b.MustAddTask(name, &specs.TaskSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 484 | CipdPackages: pkgs, |
Stephan Altmueller | 5f3b940 | 2017-03-20 13:38:45 -0400 | [diff] [blame] | 485 | Dimensions: dimensions, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 486 | ExtraArgs: []string{ |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 487 | "--workdir", "../../..", "compile", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 488 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 489 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 490 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 491 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 492 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 493 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 494 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 495 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 496 | }, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 497 | Isolate: relpath("compile_skia.isolate"), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 498 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 499 | }) |
Eric Boren | 8615fe5 | 2016-12-12 14:30:12 -0500 | [diff] [blame] | 500 | // All compile tasks are runnable as their own Job. Assert that the Job |
| 501 | // is listed in JOBS. |
| 502 | if !util.In(name, JOBS) { |
| 503 | glog.Fatalf("Job %q is missing from the JOBS list!", name) |
| 504 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 505 | return name |
| 506 | } |
| 507 | |
| 508 | // recreateSKPs generates a RecreateSKPs task. Returns the name of the last |
| 509 | // task in the generated chain of tasks, which the Job should add as a |
| 510 | // dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 511 | func recreateSKPs(b *specs.TasksCfgBuilder, name string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 512 | b.MustAddTask(name, &specs.TaskSpec{ |
Eric Boren | f9c0904 | 2017-04-17 07:50:20 -0400 | [diff] [blame] | 513 | CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 514 | Dimensions: linuxGceDimensions(), |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 515 | ExecutionTimeout: 4 * time.Hour, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 516 | ExtraArgs: []string{ |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 517 | "--workdir", "../../..", "recreate_skps", |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 518 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 519 | fmt.Sprintf("buildername=%s", name), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 520 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 521 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 522 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 523 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 524 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 525 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 526 | }, |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 527 | IoTimeout: 40 * time.Minute, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 528 | Isolate: relpath("compile_skia.isolate"), |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 529 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 530 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 531 | return name |
| 532 | } |
| 533 | |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 534 | // updateMetaConfig generates a UpdateMetaConfig task. Returns the name of the |
| 535 | // last task in the generated chain of tasks, which the Job should add as a |
| 536 | // dependency. |
| 537 | func updateMetaConfig(b *specs.TasksCfgBuilder, name string) string { |
| 538 | b.MustAddTask(name, &specs.TaskSpec{ |
Stephan Altmueller | ddad85b | 2017-05-19 13:08:19 -0400 | [diff] [blame] | 539 | CipdPackages: []*specs.CipdPackage{}, |
| 540 | Dimensions: linuxGceDimensions(), |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 541 | ExtraArgs: []string{ |
| 542 | "--workdir", "../../..", "update_meta_config", |
| 543 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 544 | fmt.Sprintf("buildername=%s", name), |
| 545 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 546 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 547 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
| 548 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 549 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 550 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 551 | }, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 552 | Isolate: relpath("meta_config.isolate"), |
Stephan Altmueller | ddad85b | 2017-05-19 13:08:19 -0400 | [diff] [blame] | 553 | Priority: 0.8, |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 554 | }) |
| 555 | return name |
| 556 | } |
| 557 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 558 | // ctSKPs generates a CT SKPs task. Returns the name of the last task in the |
| 559 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 560 | func ctSKPs(b *specs.TasksCfgBuilder, name string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 561 | b.MustAddTask(name, &specs.TaskSpec{ |
Ben Wagner | 21c3fb9 | 2017-08-04 14:13:27 -0400 | [diff] [blame] | 562 | CipdPackages: []*specs.CipdPackage{}, |
| 563 | Dimensions: []string{ |
| 564 | "pool:SkiaCT", |
Ravi Mistry | 0ac06e4 | 2017-08-08 07:39:09 -0400 | [diff] [blame] | 565 | "os:Debian-9.1", |
Ben Wagner | 21c3fb9 | 2017-08-04 14:13:27 -0400 | [diff] [blame] | 566 | }, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 567 | ExecutionTimeout: 24 * time.Hour, |
| 568 | ExtraArgs: []string{ |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 569 | "--workdir", "../../..", "ct_skps", |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 570 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 571 | fmt.Sprintf("buildername=%s", name), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 572 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 573 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 574 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 575 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 576 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 577 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 578 | }, |
| 579 | IoTimeout: time.Hour, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 580 | Isolate: relpath("ct_skps_skia.isolate"), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 581 | Priority: 0.8, |
| 582 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 583 | return name |
| 584 | } |
| 585 | |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 586 | // checkGeneratedFiles verifies that no generated SKSL files have been edited |
| 587 | // by hand. |
| 588 | func checkGeneratedFiles(b *specs.TasksCfgBuilder, name string) string { |
| 589 | b.MustAddTask(name, &specs.TaskSpec{ |
| 590 | CipdPackages: []*specs.CipdPackage{}, |
| 591 | Dimensions: linuxGceDimensions(), |
| 592 | ExtraArgs: []string{ |
| 593 | "--workdir", "../../..", "check_generated_files", |
| 594 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 595 | fmt.Sprintf("buildername=%s", name), |
| 596 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 597 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 598 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
| 599 | 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 | }, |
| 603 | Isolate: relpath("compile_skia.isolate"), |
| 604 | Priority: 0.8, |
| 605 | }) |
| 606 | return name |
| 607 | } |
| 608 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 609 | // housekeeper generates a Housekeeper task. Returns the name of the last task |
| 610 | // in the generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 611 | func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 612 | b.MustAddTask(name, &specs.TaskSpec{ |
Eric Boren | 22f5ef7 | 2016-12-02 11:01:33 -0500 | [diff] [blame] | 613 | CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")}, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 614 | Dependencies: []string{compileTaskName}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 615 | Dimensions: linuxGceDimensions(), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 616 | ExtraArgs: []string{ |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 617 | "--workdir", "../../..", "housekeeper", |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 618 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 619 | fmt.Sprintf("buildername=%s", name), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 620 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 621 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 622 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 623 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 624 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 625 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 626 | }, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 627 | Isolate: relpath("housekeeper_skia.isolate"), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 628 | Priority: 0.8, |
| 629 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 630 | return name |
| 631 | } |
| 632 | |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 633 | // infra generates an infra_tests task. Returns the name of the last task in the |
| 634 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 635 | func infra(b *specs.TasksCfgBuilder, name string) string { |
| 636 | b.MustAddTask(name, &specs.TaskSpec{ |
Eric Boren | ade6920 | 2017-04-13 10:00:43 -0400 | [diff] [blame] | 637 | CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 638 | Dimensions: linuxGceDimensions(), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 639 | ExtraArgs: []string{ |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 640 | "--workdir", "../../..", "infra", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 641 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 642 | fmt.Sprintf("buildername=%s", name), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 643 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 644 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 645 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 646 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 647 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 648 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 649 | }, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 650 | Isolate: relpath("infra_skia.isolate"), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 651 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 652 | }) |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 653 | return name |
| 654 | } |
| 655 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 656 | // doUpload indicates whether the given Job should upload its results. |
| 657 | func doUpload(name string) bool { |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 658 | for _, s := range CONFIG.NoUpload { |
| 659 | m, err := regexp.MatchString(s, name) |
| 660 | if err != nil { |
| 661 | glog.Fatal(err) |
| 662 | } |
| 663 | if m { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 664 | return false |
| 665 | } |
| 666 | } |
| 667 | return true |
| 668 | } |
| 669 | |
| 670 | // test generates a Test task. Returns the name of the last task in the |
| 671 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 672 | func test(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 673 | s := &specs.TaskSpec{ |
Eric Boren | 1f2f64b | 2016-11-09 18:35:15 -0500 | [diff] [blame] | 674 | CipdPackages: pkgs, |
| 675 | Dependencies: []string{compileTaskName}, |
| 676 | Dimensions: swarmDimensions(parts), |
| 677 | ExecutionTimeout: 4 * time.Hour, |
| 678 | Expiration: 20 * time.Hour, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 679 | ExtraArgs: []string{ |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 680 | "--workdir", "../../..", "test", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 681 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 682 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 683 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 684 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 685 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 686 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 687 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 688 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 689 | }, |
Eric Boren | 5d9f3bf | 2017-02-22 08:36:03 -0500 | [diff] [blame] | 690 | IoTimeout: 40 * time.Minute, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 691 | Isolate: relpath("test_skia.isolate"), |
Eric Boren | 5d9f3bf | 2017-02-22 08:36:03 -0500 | [diff] [blame] | 692 | MaxAttempts: 1, |
| 693 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 694 | } |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 695 | if useBundledRecipes(parts) { |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 696 | s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME) |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 697 | if strings.Contains(parts["os"], "Win") { |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 698 | s.Isolate = relpath("test_skia_bundled_win.isolate") |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 699 | } else { |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 700 | s.Isolate = relpath("test_skia_bundled_unix.isolate") |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 701 | } |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 702 | } |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 703 | if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 { |
| 704 | s.Dependencies = append(s.Dependencies, deps...) |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 705 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 706 | if strings.Contains(parts["extra_config"], "Valgrind") { |
| 707 | s.ExecutionTimeout = 9 * time.Hour |
| 708 | s.Expiration = 48 * time.Hour |
| 709 | s.IoTimeout = time.Hour |
Eric Boren | d696df7 | 2017-05-31 15:09:10 -0400 | [diff] [blame] | 710 | s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind")) |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 711 | } else if strings.Contains(parts["extra_config"], "MSAN") { |
| 712 | s.ExecutionTimeout = 9 * time.Hour |
Ben Wagner | a6b2ba2 | 2017-06-08 10:34:17 -0400 | [diff] [blame] | 713 | } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" { |
| 714 | // skia:6737 |
| 715 | s.ExecutionTimeout = 6 * time.Hour |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 716 | } |
| 717 | b.MustAddTask(name, s) |
| 718 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 719 | // Upload results if necessary. |
| 720 | if doUpload(name) { |
| 721 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 722 | b.MustAddTask(uploadName, &specs.TaskSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 723 | Dependencies: []string{name}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 724 | Dimensions: linuxGceDimensions(), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 725 | ExtraArgs: []string{ |
| 726 | "--workdir", "../../..", "upload_dm_results", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 727 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 728 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 729 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 730 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 731 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 732 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 733 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 734 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
Eric Boren | 965861b | 2017-02-06 15:38:41 -0500 | [diff] [blame] | 735 | fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketGm), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 736 | }, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 737 | Isolate: relpath("upload_dm_results.isolate"), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 738 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 739 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 740 | return uploadName |
| 741 | } |
| 742 | return name |
| 743 | } |
| 744 | |
| 745 | // perf generates a Perf task. Returns the name of the last task in the |
| 746 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 747 | func perf(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string { |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 748 | recipe := "perf" |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 749 | isolate := relpath("perf_skia.isolate") |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 750 | if strings.Contains(parts["extra_config"], "Skpbench") { |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 751 | recipe = "skpbench" |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 752 | isolate = relpath("skpbench_skia.isolate") |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 753 | if useBundledRecipes(parts) { |
| 754 | if strings.Contains(parts["os"], "Win") { |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 755 | isolate = relpath("skpbench_skia_bundled_win.isolate") |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 756 | } else { |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 757 | isolate = relpath("skpbench_skia_bundled_unix.isolate") |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 758 | } |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 759 | } |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 760 | } else if useBundledRecipes(parts) { |
| 761 | if strings.Contains(parts["os"], "Win") { |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 762 | isolate = relpath("perf_skia_bundled_win.isolate") |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 763 | } else { |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 764 | isolate = relpath("perf_skia_bundled_unix.isolate") |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 765 | } |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 766 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 767 | s := &specs.TaskSpec{ |
Eric Boren | 1f2f64b | 2016-11-09 18:35:15 -0500 | [diff] [blame] | 768 | CipdPackages: pkgs, |
| 769 | Dependencies: []string{compileTaskName}, |
| 770 | Dimensions: swarmDimensions(parts), |
| 771 | ExecutionTimeout: 4 * time.Hour, |
| 772 | Expiration: 20 * time.Hour, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 773 | ExtraArgs: []string{ |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 774 | "--workdir", "../../..", recipe, |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 775 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 776 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 777 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 778 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 779 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 780 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 781 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 782 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 783 | }, |
Eric Boren | 5d9f3bf | 2017-02-22 08:36:03 -0500 | [diff] [blame] | 784 | IoTimeout: 40 * time.Minute, |
| 785 | Isolate: isolate, |
| 786 | MaxAttempts: 1, |
| 787 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 788 | } |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 789 | if useBundledRecipes(parts) { |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 790 | s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME) |
| 791 | } |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 792 | if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 { |
| 793 | s.Dependencies = append(s.Dependencies, deps...) |
| 794 | } |
| 795 | |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 796 | if strings.Contains(parts["extra_config"], "Valgrind") { |
| 797 | s.ExecutionTimeout = 9 * time.Hour |
| 798 | s.Expiration = 48 * time.Hour |
| 799 | s.IoTimeout = time.Hour |
Eric Boren | c5a073d | 2017-06-01 07:13:33 -0400 | [diff] [blame] | 800 | s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind")) |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 801 | } else if strings.Contains(parts["extra_config"], "MSAN") { |
| 802 | s.ExecutionTimeout = 9 * time.Hour |
Ben Wagner | a6b2ba2 | 2017-06-08 10:34:17 -0400 | [diff] [blame] | 803 | } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" { |
| 804 | // skia:6737 |
| 805 | s.ExecutionTimeout = 6 * time.Hour |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 806 | } |
| 807 | b.MustAddTask(name, s) |
| 808 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 809 | // Upload results if necessary. |
| 810 | if strings.Contains(name, "Release") && doUpload(name) { |
| 811 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 812 | b.MustAddTask(uploadName, &specs.TaskSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 813 | Dependencies: []string{name}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 814 | Dimensions: linuxGceDimensions(), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 815 | ExtraArgs: []string{ |
| 816 | "--workdir", "../../..", "upload_nano_results", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 817 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 818 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 819 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 820 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 821 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 822 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 823 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 824 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
Eric Boren | 965861b | 2017-02-06 15:38:41 -0500 | [diff] [blame] | 825 | fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketNano), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 826 | }, |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 827 | Isolate: relpath("upload_nano_results.isolate"), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 828 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 829 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 830 | return uploadName |
| 831 | } |
| 832 | return name |
| 833 | } |
| 834 | |
| 835 | // process generates tasks and jobs for the given job name. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 836 | func process(b *specs.TasksCfgBuilder, name string) { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 837 | deps := []string{} |
| 838 | |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 839 | // Bundle Recipes. |
| 840 | if name == BUNDLE_RECIPES_NAME { |
| 841 | deps = append(deps, bundleRecipes(b)) |
| 842 | } |
| 843 | |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 844 | // Isolate CIPD assets. |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 845 | if _, ok := ISOLATE_ASSET_MAPPING[name]; ok { |
| 846 | deps = append(deps, isolateCIPDAsset(b, name)) |
| 847 | } |
| 848 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 849 | parts, err := jobNameSchema.ParseJobName(name) |
| 850 | if err != nil { |
| 851 | glog.Fatal(err) |
| 852 | } |
| 853 | |
| 854 | // RecreateSKPs. |
| 855 | if strings.Contains(name, "RecreateSKPs") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 856 | deps = append(deps, recreateSKPs(b, name)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 857 | } |
| 858 | |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 859 | // UpdateMetaConfig bot. |
| 860 | if strings.Contains(name, "UpdateMetaConfig") { |
| 861 | deps = append(deps, updateMetaConfig(b, name)) |
| 862 | } |
| 863 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 864 | // CT bots. |
| 865 | if strings.Contains(name, "-CT_") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 866 | deps = append(deps, ctSKPs(b, name)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 867 | } |
| 868 | |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 869 | // Infra tests. |
| 870 | if name == "Housekeeper-PerCommit-InfraTests" { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 871 | deps = append(deps, infra(b, name)) |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 872 | } |
| 873 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 874 | // Compile bots. |
| 875 | if parts["role"] == "Build" { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 876 | deps = append(deps, compile(b, name, parts)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 877 | } |
| 878 | |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 879 | // Most remaining bots need a compile task. |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 880 | compileTaskName := deriveCompileTaskName(name, parts) |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 881 | compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName) |
| 882 | if err != nil { |
| 883 | glog.Fatal(err) |
| 884 | } |
Eric Boren | 628e78b | 2016-11-17 11:33:27 -0500 | [diff] [blame] | 885 | // These bots do not need a compile task. |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 886 | if parts["role"] != "Build" && |
Eric Boren | b8ab7f7 | 2017-04-10 11:00:09 -0400 | [diff] [blame] | 887 | name != "Housekeeper-PerCommit-BundleRecipes" && |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 888 | name != "Housekeeper-PerCommit-InfraTests" && |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 889 | name != "Housekeeper-PerCommit-CheckGeneratedFiles" && |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 890 | !strings.Contains(name, "RecreateSKPs") && |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 891 | !strings.Contains(name, "UpdateMetaConfig") && |
Ben Wagner | 50b8468 | 2017-06-12 13:03:29 -0400 | [diff] [blame] | 892 | !strings.Contains(name, "-CT_") && |
| 893 | !strings.Contains(name, "Housekeeper-PerCommit-Isolate") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 894 | compile(b, compileTaskName, compileTaskParts) |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 895 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 896 | |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 897 | // Housekeepers. |
Eric Boren | 22f5ef7 | 2016-12-02 11:01:33 -0500 | [diff] [blame] | 898 | if name == "Housekeeper-PerCommit" { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 899 | deps = append(deps, housekeeper(b, name, compileTaskName)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 900 | } |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 901 | if name == "Housekeeper-PerCommit-CheckGeneratedFiles" { |
| 902 | deps = append(deps, checkGeneratedFiles(b, name)) |
| 903 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 904 | |
| 905 | // Common assets needed by the remaining bots. |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 906 | |
| 907 | pkgs := []*specs.CipdPackage{} |
| 908 | |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 909 | if deps := getIsolatedCIPDDeps(parts); len(deps) == 0 { |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 910 | pkgs = []*specs.CipdPackage{ |
| 911 | b.MustGetCipdPackageFromAsset("skimage"), |
| 912 | b.MustGetCipdPackageFromAsset("skp"), |
| 913 | b.MustGetCipdPackageFromAsset("svg"), |
| 914 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 915 | } |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 916 | |
Eric Boren | 25062cf | 2017-06-29 15:22:46 -0400 | [diff] [blame] | 917 | if (strings.Contains(name, "Ubuntu") || strings.Contains(name, "Debian")) && strings.Contains(name, "SAN") { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 918 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 919 | } |
Kevin Lubick | 35115eb | 2017-02-17 10:25:34 -0500 | [diff] [blame] | 920 | if strings.Contains(name, "Ubuntu16") { |
| 921 | if strings.Contains(name, "Vulkan") { |
| 922 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk")) |
| 923 | } |
Kevin Lubick | 0a51b48 | 2017-02-06 12:45:29 -0500 | [diff] [blame] | 924 | if strings.Contains(name, "Release") { |
| 925 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_release")) |
| 926 | } else { |
| 927 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_debug")) |
| 928 | } |
| 929 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 930 | |
| 931 | // Test bots. |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 932 | if parts["role"] == "Test" && !strings.Contains(name, "-CT_") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 933 | deps = append(deps, test(b, name, parts, compileTaskName, pkgs)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | // Perf bots. |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 937 | if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 938 | deps = append(deps, perf(b, name, parts, compileTaskName, pkgs)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 939 | } |
| 940 | |
| 941 | // Add the Job spec. |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 942 | j := &specs.JobSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 943 | Priority: 0.8, |
| 944 | TaskSpecs: deps, |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 945 | Trigger: specs.TRIGGER_ANY_BRANCH, |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 946 | } |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 947 | if strings.Contains(name, "-Nightly-") { |
| 948 | j.Trigger = specs.TRIGGER_NIGHTLY |
| 949 | } else if strings.Contains(name, "-Weekly-") || name == "Test-Ubuntu14-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs" { |
| 950 | j.Trigger = specs.TRIGGER_WEEKLY |
| 951 | } else if strings.Contains(name, "Flutter") || strings.Contains(name, "PDFium") || strings.Contains(name, "CommandBuffer") { |
| 952 | j.Trigger = specs.TRIGGER_MASTER_ONLY |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 953 | } |
Eric Boren | 8615fe5 | 2016-12-12 14:30:12 -0500 | [diff] [blame] | 954 | b.MustAddJob(name, j) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 955 | } |
| 956 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 957 | func loadJson(flag *string, defaultFlag string, val interface{}) { |
| 958 | if *flag == "" { |
| 959 | *flag = defaultFlag |
| 960 | } |
| 961 | b, err := ioutil.ReadFile(*flag) |
| 962 | if err != nil { |
| 963 | glog.Fatal(err) |
| 964 | } |
| 965 | if err := json.Unmarshal(b, val); err != nil { |
| 966 | glog.Fatal(err) |
| 967 | } |
| 968 | } |
| 969 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 970 | // Regenerate the tasks.json file. |
| 971 | func main() { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 972 | b := specs.MustNewTasksCfgBuilder() |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 973 | b.SetAssetsDir(*assetsDir) |
| 974 | infraBots := path.Join(b.CheckoutRoot(), "infra", "bots") |
| 975 | |
| 976 | // Load the jobs from a JSON file. |
| 977 | loadJson(jobsFile, path.Join(infraBots, "jobs.json"), &JOBS) |
| 978 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 979 | // Load general config information from a JSON file. |
| 980 | loadJson(cfgFile, path.Join(infraBots, "cfg.json"), &CONFIG) |
| 981 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 982 | // Create the JobNameSchema. |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 983 | if *builderNameSchemaFile == "" { |
| 984 | *builderNameSchemaFile = path.Join(b.CheckoutRoot(), "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json") |
| 985 | } |
| 986 | schema, err := NewJobNameSchema(*builderNameSchemaFile) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 987 | if err != nil { |
| 988 | glog.Fatal(err) |
| 989 | } |
| 990 | jobNameSchema = schema |
| 991 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 992 | // Create Tasks and Jobs. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 993 | for _, name := range JOBS { |
| 994 | process(b, name) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 995 | } |
| 996 | |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 997 | b.MustFinish() |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | // TODO(borenet): The below really belongs in its own file, probably next to the |
| 1001 | // builder_name_schema.json file. |
| 1002 | |
| 1003 | // JobNameSchema is a struct used for (de)constructing Job names in a |
| 1004 | // predictable format. |
| 1005 | type JobNameSchema struct { |
| 1006 | Schema map[string][]string `json:"builder_name_schema"` |
| 1007 | Sep string `json:"builder_name_sep"` |
| 1008 | } |
| 1009 | |
| 1010 | // NewJobNameSchema returns a JobNameSchema instance based on the given JSON |
| 1011 | // file. |
| 1012 | func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) { |
| 1013 | var rv JobNameSchema |
| 1014 | f, err := os.Open(jsonFile) |
| 1015 | if err != nil { |
| 1016 | return nil, err |
| 1017 | } |
| 1018 | defer util.Close(f) |
| 1019 | if err := json.NewDecoder(f).Decode(&rv); err != nil { |
| 1020 | return nil, err |
| 1021 | } |
| 1022 | return &rv, nil |
| 1023 | } |
| 1024 | |
| 1025 | // ParseJobName splits the given Job name into its component parts, according |
| 1026 | // to the schema. |
| 1027 | func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) { |
| 1028 | split := strings.Split(n, s.Sep) |
| 1029 | if len(split) < 2 { |
| 1030 | return nil, fmt.Errorf("Invalid job name: %q", n) |
| 1031 | } |
| 1032 | role := split[0] |
| 1033 | split = split[1:] |
| 1034 | keys, ok := s.Schema[role] |
| 1035 | if !ok { |
| 1036 | return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role) |
| 1037 | } |
| 1038 | extraConfig := "" |
| 1039 | if len(split) == len(keys)+1 { |
| 1040 | extraConfig = split[len(split)-1] |
| 1041 | split = split[:len(split)-1] |
| 1042 | } |
| 1043 | if len(split) != len(keys) { |
| 1044 | return nil, fmt.Errorf("Invalid job name; %q has incorrect number of parts.", n) |
| 1045 | } |
| 1046 | rv := make(map[string]string, len(keys)+2) |
| 1047 | rv["role"] = role |
| 1048 | if extraConfig != "" { |
| 1049 | rv["extra_config"] = extraConfig |
| 1050 | } |
| 1051 | for i, k := range keys { |
| 1052 | rv[k] = split[i] |
| 1053 | } |
| 1054 | return rv, nil |
| 1055 | } |
| 1056 | |
| 1057 | // MakeJobName assembles the given parts of a Job name, according to the schema. |
| 1058 | func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) { |
| 1059 | role, ok := parts["role"] |
| 1060 | if !ok { |
| 1061 | return "", fmt.Errorf("Invalid job parts; jobs must have a role.") |
| 1062 | } |
| 1063 | keys, ok := s.Schema[role] |
| 1064 | if !ok { |
| 1065 | return "", fmt.Errorf("Invalid job parts; unknown role %q", role) |
| 1066 | } |
| 1067 | rvParts := make([]string, 0, len(parts)) |
| 1068 | rvParts = append(rvParts, role) |
| 1069 | for _, k := range keys { |
| 1070 | v, ok := parts[k] |
| 1071 | if !ok { |
| 1072 | return "", fmt.Errorf("Invalid job parts; missing %q", k) |
| 1073 | } |
| 1074 | rvParts = append(rvParts, v) |
| 1075 | } |
| 1076 | if _, ok := parts["extra_config"]; ok { |
| 1077 | rvParts = append(rvParts, parts["extra_config"]) |
| 1078 | } |
| 1079 | return strings.Join(rvParts, s.Sep), nil |
| 1080 | } |