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 | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 18 | "regexp" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 19 | "sort" |
| 20 | "strings" |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 21 | "time" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 22 | |
| 23 | "github.com/skia-dev/glog" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 24 | "go.skia.org/infra/go/util" |
| 25 | "go.skia.org/infra/task_scheduler/go/specs" |
| 26 | ) |
| 27 | |
| 28 | const ( |
Kevin Lubick | 797ef16 | 2016-12-15 10:45:08 -0500 | [diff] [blame] | 29 | DEFAULT_OS = DEFAULT_OS_LINUX |
| 30 | DEFAULT_OS_LINUX = "Ubuntu-14.04" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 31 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 32 | // Name prefix for upload jobs. |
| 33 | PREFIX_UPLOAD = "Upload" |
| 34 | ) |
| 35 | |
| 36 | var ( |
| 37 | // "Constants" |
| 38 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 39 | // Top-level list of all jobs to run at each commit; loaded from |
| 40 | // jobs.json. |
| 41 | JOBS []string |
| 42 | |
| 43 | // Mapping of human-friendly Android device names to a pair of {device_type, device_os}. |
| 44 | ANDROID_MAPPING map[string][]string |
| 45 | |
| 46 | // General configuration information. |
| 47 | CONFIG struct { |
Eric Boren | 965861b | 2017-02-06 15:38:41 -0500 | [diff] [blame] | 48 | GsBucketGm string `json:"gs_bucket_gm"` |
| 49 | GsBucketNano string `json:"gs_bucket_nano"` |
| 50 | NoUpload []string `json:"no_upload"` |
| 51 | Pool string `json:"pool"` |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 54 | // Mapping of human-friendly GPU names to PCI IDs. |
| 55 | GPU_MAPPING map[string]string |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 56 | |
| 57 | // Defines the structure of job names. |
| 58 | jobNameSchema *JobNameSchema |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 59 | |
| 60 | // Flags. |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 61 | androidMapFile = flag.String("android_map", "", "JSON file containing a mapping of human-friendly Android device names to a pair of {device_type, device_os}.") |
| 62 | 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.") |
| 63 | assetsDir = flag.String("assets_dir", "", "Directory containing assets.") |
| 64 | cfgFile = flag.String("cfg_file", "", "JSON file containing general configuration information.") |
| 65 | gpuMapFile = flag.String("gpu_map", "", "JSON file containing a mapping of human-friendly GPU names to PCI IDs.") |
| 66 | jobsFile = flag.String("jobs", "", "JSON file containing jobs to run.") |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 67 | ) |
| 68 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 69 | // linuxGceDimensions are the Swarming dimensions for Linux GCE |
| 70 | // instances. |
| 71 | func linuxGceDimensions() []string { |
| 72 | return []string{ |
| 73 | "cpu:x86-64-avx2", |
| 74 | "gpu:none", |
| 75 | fmt.Sprintf("os:%s", DEFAULT_OS_LINUX), |
| 76 | fmt.Sprintf("pool:%s", CONFIG.Pool), |
| 77 | } |
| 78 | } |
| 79 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 80 | // deriveCompileTaskName returns the name of a compile task based on the given |
| 81 | // job name. |
| 82 | func deriveCompileTaskName(jobName string, parts map[string]string) string { |
| 83 | if parts["role"] == "Housekeeper" { |
| 84 | return "Build-Ubuntu-GCC-x86_64-Release-Shared" |
| 85 | } else if parts["role"] == "Test" || parts["role"] == "Perf" { |
| 86 | task_os := parts["os"] |
| 87 | ec := parts["extra_config"] |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 88 | ec = strings.TrimSuffix(ec, "_Skpbench") |
Ben Wagner | 46df2a1 | 2017-02-21 19:10:24 -0500 | [diff] [blame] | 89 | ec = strings.TrimSuffix(ec, "_AbandonGpuContext") |
| 90 | ec = strings.TrimSuffix(ec, "_PreAbandonGpuContext") |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 91 | if task_os == "Android" { |
| 92 | if ec == "Vulkan" { |
| 93 | ec = "Android_Vulkan" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 94 | } |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 95 | task_os = "Ubuntu" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 96 | } else if task_os == "iOS" { |
| 97 | ec = task_os |
| 98 | task_os = "Mac" |
| 99 | } else if strings.Contains(task_os, "Win") { |
| 100 | task_os = "Win" |
Kevin Lubick | 893c49e | 2017-01-17 15:15:40 -0500 | [diff] [blame] | 101 | } else if strings.Contains(task_os, "Ubuntu") { |
| 102 | task_os = "Ubuntu" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 103 | } |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 104 | jobNameMap := map[string]string{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 105 | "role": "Build", |
| 106 | "os": task_os, |
| 107 | "compiler": parts["compiler"], |
| 108 | "target_arch": parts["arch"], |
| 109 | "configuration": parts["configuration"], |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 110 | } |
| 111 | if ec != "" { |
| 112 | jobNameMap["extra_config"] = ec |
| 113 | } |
| 114 | name, err := jobNameSchema.MakeJobName(jobNameMap) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 115 | if err != nil { |
| 116 | glog.Fatal(err) |
| 117 | } |
| 118 | return name |
| 119 | } else { |
| 120 | return jobName |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // swarmDimensions generates swarming bot dimensions for the given task. |
| 125 | func swarmDimensions(parts map[string]string) []string { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 126 | d := map[string]string{ |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 127 | "pool": CONFIG.Pool, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 128 | } |
| 129 | if os, ok := parts["os"]; ok { |
Eric Boren | 54ff2fc | 2016-12-02 12:09:10 -0500 | [diff] [blame] | 130 | d["os"] = map[string]string{ |
Kevin Lubick | 893c49e | 2017-01-17 15:15:40 -0500 | [diff] [blame] | 131 | "Android": "Android", |
| 132 | "Mac": "Mac-10.11", |
| 133 | "Ubuntu": DEFAULT_OS_LINUX, |
Kevin Lubick | 9063eca | 2017-02-01 11:10:32 -0500 | [diff] [blame] | 134 | "Ubuntu16": "Ubuntu-16.10", |
Kevin Lubick | 893c49e | 2017-01-17 15:15:40 -0500 | [diff] [blame] | 135 | "Win": "Windows-2008ServerR2-SP1", |
| 136 | "Win10": "Windows-10-14393", |
| 137 | "Win2k8": "Windows-2008ServerR2-SP1", |
| 138 | "Win8": "Windows-8.1-SP0", |
| 139 | "iOS": "iOS-9.3.1", |
Eric Boren | 54ff2fc | 2016-12-02 12:09:10 -0500 | [diff] [blame] | 140 | }[os] |
Ben Wagner | 7355737 | 2016-12-29 16:27:03 -0500 | [diff] [blame] | 141 | // Chrome Golo has a different Windows image. |
| 142 | if parts["model"] == "Golo" && os == "Win10" { |
| 143 | d["os"] = "Windows-10-10586" |
Ben Wagner | 17f811b | 2016-12-22 08:40:14 -0500 | [diff] [blame] | 144 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 145 | } else { |
| 146 | d["os"] = DEFAULT_OS |
| 147 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 148 | if parts["role"] == "Test" || parts["role"] == "Perf" { |
| 149 | if strings.Contains(parts["os"], "Android") { |
| 150 | // For Android, the device type is a better dimension |
| 151 | // than CPU or GPU. |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 152 | deviceInfo, ok := ANDROID_MAPPING[parts["model"]] |
| 153 | if !ok { |
| 154 | glog.Fatalf("Entry %q not found in Android mapping: %v", parts["model"], ANDROID_MAPPING) |
| 155 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 156 | d["device_type"] = deviceInfo[0] |
| 157 | d["device_os"] = deviceInfo[1] |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 158 | } else if strings.Contains(parts["os"], "iOS") { |
| 159 | d["device"] = map[string]string{ |
Eric Boren | 792079cf | 2016-11-09 14:03:20 -0500 | [diff] [blame] | 160 | "iPadMini4": "iPad5,1", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 161 | }[parts["model"]] |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 162 | } else if parts["cpu_or_gpu"] == "CPU" { |
| 163 | d["gpu"] = "none" |
| 164 | d["cpu"] = map[string]string{ |
| 165 | "AVX": "x86-64", |
| 166 | "AVX2": "x86-64-avx2", |
| 167 | "SSE4": "x86-64", |
| 168 | }[parts["cpu_or_gpu_value"]] |
| 169 | if strings.Contains(parts["os"], "Win") && parts["cpu_or_gpu_value"] == "AVX2" { |
| 170 | // AVX2 is not correctly detected on Windows. Fall back on other |
| 171 | // dimensions to ensure that we correctly target machines which we know |
| 172 | // have AVX2 support. |
| 173 | d["cpu"] = "x86-64" |
| 174 | d["os"] = "Windows-2008ServerR2-SP1" |
| 175 | } |
| 176 | } else { |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 177 | gpu, ok := GPU_MAPPING[parts["cpu_or_gpu_value"]] |
| 178 | if !ok { |
| 179 | glog.Fatalf("Entry %q not found in GPU mapping: %v", parts["cpu_or_gpu_value"], GPU_MAPPING) |
| 180 | } |
| 181 | d["gpu"] = gpu |
Ben Wagner | 0843589 | 2017-02-18 23:28:26 -0500 | [diff] [blame] | 182 | |
| 183 | // Hack: Specify machine_type dimension for NUCs and ShuttleCs. We |
| 184 | // temporarily have two types of machines with a GTX960. The only way to |
| 185 | // distinguish these bots is by machine_type. |
| 186 | machine_type, ok := map[string]string{ |
| 187 | "NUC6i7KYK": "n1-highcpu-8", |
| 188 | "ShuttleC": "n1-standard-8", |
| 189 | }[parts["model"]] |
| 190 | if ok { |
| 191 | d["machine_type"] = machine_type |
| 192 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 193 | } |
| 194 | } else { |
| 195 | d["gpu"] = "none" |
| 196 | } |
| 197 | rv := make([]string, 0, len(d)) |
| 198 | for k, v := range d { |
| 199 | rv = append(rv, fmt.Sprintf("%s:%s", k, v)) |
| 200 | } |
| 201 | sort.Strings(rv) |
| 202 | return rv |
| 203 | } |
| 204 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 205 | // compile generates a compile task. Returns the name of the last task in the |
| 206 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 207 | func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 208 | // Collect the necessary CIPD packages. |
| 209 | pkgs := []*specs.CipdPackage{} |
| 210 | |
| 211 | // Android bots require a toolchain. |
| 212 | if strings.Contains(name, "Android") { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 213 | if strings.Contains(name, "Mac") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 214 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_darwin")) |
Mike Klein | 86c2c0f | 2016-11-02 13:13:16 -0400 | [diff] [blame] | 215 | } else if strings.Contains(name, "Win") { |
Mike Klein | e9215f0 | 2016-11-02 15:44:26 -0400 | [diff] [blame] | 216 | pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows") |
| 217 | pkg.Path = "n" |
| 218 | pkgs = append(pkgs, pkg) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 219 | } else { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 220 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_linux")) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 221 | } |
Kevin Lubick | 9c7dcac | 2017-01-18 09:24:56 -0500 | [diff] [blame] | 222 | } else if strings.Contains(name, "Ubuntu") { |
| 223 | if strings.Contains(name, "Clang") { |
| 224 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 225 | } |
| 226 | if strings.Contains(name, "Vulkan") { |
| 227 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk")) |
| 228 | } |
Mike Klein | 27dcee1 | 2016-11-09 16:31:42 -0500 | [diff] [blame] | 229 | } else if strings.Contains(name, "Win") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 230 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_toolchain")) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 231 | if strings.Contains(name, "Vulkan") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 232 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_vulkan_sdk")) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 233 | } |
| 234 | } |
| 235 | |
| 236 | // Add the task. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 237 | b.MustAddTask(name, &specs.TaskSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 238 | CipdPackages: pkgs, |
| 239 | Dimensions: swarmDimensions(parts), |
| 240 | ExtraArgs: []string{ |
| 241 | "--workdir", "../../..", "swarm_compile", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 242 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 243 | fmt.Sprintf("buildername=%s", name), |
| 244 | "mastername=fake-master", |
| 245 | "buildnumber=2", |
| 246 | "slavename=fake-buildslave", |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 247 | "nobuildbot=True", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 248 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 249 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 250 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 251 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 252 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 253 | }, |
| 254 | Isolate: "compile_skia.isolate", |
| 255 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 256 | }) |
Eric Boren | 8615fe5 | 2016-12-12 14:30:12 -0500 | [diff] [blame] | 257 | // All compile tasks are runnable as their own Job. Assert that the Job |
| 258 | // is listed in JOBS. |
| 259 | if !util.In(name, JOBS) { |
| 260 | glog.Fatalf("Job %q is missing from the JOBS list!", name) |
| 261 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 262 | return name |
| 263 | } |
| 264 | |
| 265 | // recreateSKPs generates a RecreateSKPs task. Returns the name of the last |
| 266 | // task in the generated chain of tasks, which the Job should add as a |
| 267 | // dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 268 | func recreateSKPs(b *specs.TasksCfgBuilder, name string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 269 | b.MustAddTask(name, &specs.TaskSpec{ |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 270 | CipdPackages: []*specs.CipdPackage{}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 271 | Dimensions: linuxGceDimensions(), |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 272 | ExecutionTimeout: 4 * time.Hour, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 273 | ExtraArgs: []string{ |
| 274 | "--workdir", "../../..", "swarm_RecreateSKPs", |
| 275 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 276 | fmt.Sprintf("buildername=%s", name), |
| 277 | "mastername=fake-master", |
| 278 | "buildnumber=2", |
| 279 | "slavename=fake-buildslave", |
| 280 | "nobuildbot=True", |
| 281 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 282 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 283 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 284 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 285 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 286 | }, |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 287 | IoTimeout: 40 * time.Minute, |
| 288 | Isolate: "compile_skia.isolate", |
| 289 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 290 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 291 | return name |
| 292 | } |
| 293 | |
| 294 | // ctSKPs generates a CT SKPs task. Returns the name of the last task in the |
| 295 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 296 | func ctSKPs(b *specs.TasksCfgBuilder, name string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 297 | b.MustAddTask(name, &specs.TaskSpec{ |
| 298 | CipdPackages: []*specs.CipdPackage{}, |
| 299 | Dimensions: []string{"pool:SkiaCT"}, |
| 300 | ExecutionTimeout: 24 * time.Hour, |
| 301 | ExtraArgs: []string{ |
| 302 | "--workdir", "../../..", "swarm_ct_skps", |
| 303 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 304 | fmt.Sprintf("buildername=%s", name), |
| 305 | "mastername=fake-master", |
| 306 | "buildnumber=2", |
| 307 | "slavename=fake-buildslave", |
| 308 | "nobuildbot=True", |
| 309 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 310 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 311 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 312 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 313 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 314 | }, |
| 315 | IoTimeout: time.Hour, |
| 316 | Isolate: "ct_skps_skia.isolate", |
| 317 | Priority: 0.8, |
| 318 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 319 | return name |
| 320 | } |
| 321 | |
| 322 | // housekeeper generates a Housekeeper task. Returns the name of the last task |
| 323 | // 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] | 324 | func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 325 | b.MustAddTask(name, &specs.TaskSpec{ |
Eric Boren | 22f5ef7 | 2016-12-02 11:01:33 -0500 | [diff] [blame] | 326 | CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")}, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 327 | Dependencies: []string{compileTaskName}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 328 | Dimensions: linuxGceDimensions(), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 329 | ExtraArgs: []string{ |
| 330 | "--workdir", "../../..", "swarm_housekeeper", |
| 331 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 332 | fmt.Sprintf("buildername=%s", name), |
| 333 | "mastername=fake-master", |
| 334 | "buildnumber=2", |
| 335 | "slavename=fake-buildslave", |
| 336 | "nobuildbot=True", |
| 337 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 338 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 339 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 340 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 341 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 342 | }, |
| 343 | Isolate: "housekeeper_skia.isolate", |
| 344 | Priority: 0.8, |
| 345 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 346 | return name |
| 347 | } |
| 348 | |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 349 | // infra generates an infra_tests task. Returns the name of the last task in the |
| 350 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 351 | func infra(b *specs.TasksCfgBuilder, name string) string { |
| 352 | b.MustAddTask(name, &specs.TaskSpec{ |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 353 | CipdPackages: []*specs.CipdPackage{}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 354 | Dimensions: linuxGceDimensions(), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 355 | ExtraArgs: []string{ |
| 356 | "--workdir", "../../..", "swarm_infra", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 357 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 358 | fmt.Sprintf("buildername=%s", name), |
| 359 | "mastername=fake-master", |
| 360 | "buildnumber=2", |
| 361 | "slavename=fake-buildslave", |
| 362 | "nobuildbot=True", |
| 363 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 364 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 365 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 366 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 367 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 368 | }, |
| 369 | Isolate: "infra_skia.isolate", |
| 370 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 371 | }) |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 372 | return name |
| 373 | } |
| 374 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 375 | // doUpload indicates whether the given Job should upload its results. |
| 376 | func doUpload(name string) bool { |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 377 | for _, s := range CONFIG.NoUpload { |
| 378 | m, err := regexp.MatchString(s, name) |
| 379 | if err != nil { |
| 380 | glog.Fatal(err) |
| 381 | } |
| 382 | if m { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 383 | return false |
| 384 | } |
| 385 | } |
| 386 | return true |
| 387 | } |
| 388 | |
| 389 | // test generates a Test task. Returns the name of the last task in the |
| 390 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 391 | 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] | 392 | s := &specs.TaskSpec{ |
Eric Boren | 1f2f64b | 2016-11-09 18:35:15 -0500 | [diff] [blame] | 393 | CipdPackages: pkgs, |
| 394 | Dependencies: []string{compileTaskName}, |
| 395 | Dimensions: swarmDimensions(parts), |
| 396 | ExecutionTimeout: 4 * time.Hour, |
| 397 | Expiration: 20 * time.Hour, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 398 | ExtraArgs: []string{ |
| 399 | "--workdir", "../../..", "swarm_test", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 400 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 401 | fmt.Sprintf("buildername=%s", name), |
| 402 | "mastername=fake-master", |
| 403 | "buildnumber=2", |
| 404 | "slavename=fake-buildslave", |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 405 | "nobuildbot=True", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 406 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 407 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 408 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 409 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 410 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 411 | }, |
Eric Boren | 5d9f3bf | 2017-02-22 08:36:03 -0500 | [diff] [blame^] | 412 | IoTimeout: 40 * time.Minute, |
| 413 | Isolate: "test_skia.isolate", |
| 414 | MaxAttempts: 1, |
| 415 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 416 | } |
| 417 | if strings.Contains(parts["extra_config"], "Valgrind") { |
| 418 | s.ExecutionTimeout = 9 * time.Hour |
| 419 | s.Expiration = 48 * time.Hour |
| 420 | s.IoTimeout = time.Hour |
| 421 | } else if strings.Contains(parts["extra_config"], "MSAN") { |
| 422 | s.ExecutionTimeout = 9 * time.Hour |
| 423 | } |
| 424 | b.MustAddTask(name, s) |
| 425 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 426 | // Upload results if necessary. |
| 427 | if doUpload(name) { |
| 428 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 429 | b.MustAddTask(uploadName, &specs.TaskSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 430 | Dependencies: []string{name}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 431 | Dimensions: linuxGceDimensions(), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 432 | ExtraArgs: []string{ |
| 433 | "--workdir", "../../..", "upload_dm_results", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 434 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 435 | fmt.Sprintf("buildername=%s", name), |
| 436 | "mastername=fake-master", |
| 437 | "buildnumber=2", |
| 438 | "slavename=fake-buildslave", |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 439 | "nobuildbot=True", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 440 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 441 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 442 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 443 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 444 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
Eric Boren | 965861b | 2017-02-06 15:38:41 -0500 | [diff] [blame] | 445 | fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketGm), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 446 | }, |
| 447 | Isolate: "upload_dm_results.isolate", |
| 448 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 449 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 450 | return uploadName |
| 451 | } |
| 452 | return name |
| 453 | } |
| 454 | |
| 455 | // perf generates a Perf task. Returns the name of the last task in the |
| 456 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 457 | func perf(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string { |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 458 | recipe := "swarm_perf" |
| 459 | isolate := "perf_skia.isolate" |
| 460 | if strings.Contains(parts["extra_config"], "Skpbench") { |
| 461 | recipe = "swarm_skpbench" |
| 462 | isolate = "skpbench_skia.isolate" |
| 463 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 464 | s := &specs.TaskSpec{ |
Eric Boren | 1f2f64b | 2016-11-09 18:35:15 -0500 | [diff] [blame] | 465 | CipdPackages: pkgs, |
| 466 | Dependencies: []string{compileTaskName}, |
| 467 | Dimensions: swarmDimensions(parts), |
| 468 | ExecutionTimeout: 4 * time.Hour, |
| 469 | Expiration: 20 * time.Hour, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 470 | ExtraArgs: []string{ |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 471 | "--workdir", "../../..", recipe, |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 472 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 473 | fmt.Sprintf("buildername=%s", name), |
| 474 | "mastername=fake-master", |
| 475 | "buildnumber=2", |
| 476 | "slavename=fake-buildslave", |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 477 | "nobuildbot=True", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 478 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 479 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 480 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 481 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 482 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 483 | }, |
Eric Boren | 5d9f3bf | 2017-02-22 08:36:03 -0500 | [diff] [blame^] | 484 | IoTimeout: 40 * time.Minute, |
| 485 | Isolate: isolate, |
| 486 | MaxAttempts: 1, |
| 487 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 488 | } |
| 489 | if strings.Contains(parts["extra_config"], "Valgrind") { |
| 490 | s.ExecutionTimeout = 9 * time.Hour |
| 491 | s.Expiration = 48 * time.Hour |
| 492 | s.IoTimeout = time.Hour |
| 493 | } else if strings.Contains(parts["extra_config"], "MSAN") { |
| 494 | s.ExecutionTimeout = 9 * time.Hour |
| 495 | } |
| 496 | b.MustAddTask(name, s) |
| 497 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 498 | // Upload results if necessary. |
| 499 | if strings.Contains(name, "Release") && doUpload(name) { |
| 500 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 501 | b.MustAddTask(uploadName, &specs.TaskSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 502 | Dependencies: []string{name}, |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 503 | Dimensions: linuxGceDimensions(), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 504 | ExtraArgs: []string{ |
| 505 | "--workdir", "../../..", "upload_nano_results", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 506 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 507 | fmt.Sprintf("buildername=%s", name), |
| 508 | "mastername=fake-master", |
| 509 | "buildnumber=2", |
| 510 | "slavename=fake-buildslave", |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 511 | "nobuildbot=True", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 512 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 513 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 514 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 515 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 516 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
Eric Boren | 965861b | 2017-02-06 15:38:41 -0500 | [diff] [blame] | 517 | fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketNano), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 518 | }, |
| 519 | Isolate: "upload_nano_results.isolate", |
| 520 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 521 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 522 | return uploadName |
| 523 | } |
| 524 | return name |
| 525 | } |
| 526 | |
| 527 | // process generates tasks and jobs for the given job name. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 528 | func process(b *specs.TasksCfgBuilder, name string) { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 529 | deps := []string{} |
| 530 | |
| 531 | parts, err := jobNameSchema.ParseJobName(name) |
| 532 | if err != nil { |
| 533 | glog.Fatal(err) |
| 534 | } |
| 535 | |
| 536 | // RecreateSKPs. |
| 537 | if strings.Contains(name, "RecreateSKPs") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 538 | deps = append(deps, recreateSKPs(b, name)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | // CT bots. |
| 542 | if strings.Contains(name, "-CT_") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 543 | deps = append(deps, ctSKPs(b, name)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 544 | } |
| 545 | |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 546 | // Infra tests. |
| 547 | if name == "Housekeeper-PerCommit-InfraTests" { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 548 | deps = append(deps, infra(b, name)) |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 549 | } |
| 550 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 551 | // Compile bots. |
| 552 | if parts["role"] == "Build" { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 553 | deps = append(deps, compile(b, name, parts)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 554 | } |
| 555 | |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 556 | // Most remaining bots need a compile task. |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 557 | compileTaskName := deriveCompileTaskName(name, parts) |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 558 | compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName) |
| 559 | if err != nil { |
| 560 | glog.Fatal(err) |
| 561 | } |
Eric Boren | 628e78b | 2016-11-17 11:33:27 -0500 | [diff] [blame] | 562 | // These bots do not need a compile task. |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 563 | if parts["role"] != "Build" && |
| 564 | name != "Housekeeper-PerCommit-InfraTests" && |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 565 | !strings.Contains(name, "RecreateSKPs") && |
| 566 | !strings.Contains(name, "-CT_") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 567 | compile(b, compileTaskName, compileTaskParts) |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 568 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 569 | |
| 570 | // Housekeeper. |
Eric Boren | 22f5ef7 | 2016-12-02 11:01:33 -0500 | [diff] [blame] | 571 | if name == "Housekeeper-PerCommit" { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 572 | deps = append(deps, housekeeper(b, name, compileTaskName)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | // Common assets needed by the remaining bots. |
| 576 | pkgs := []*specs.CipdPackage{ |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 577 | b.MustGetCipdPackageFromAsset("skimage"), |
| 578 | b.MustGetCipdPackageFromAsset("skp"), |
| 579 | b.MustGetCipdPackageFromAsset("svg"), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 580 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 581 | if strings.Contains(name, "Ubuntu") && strings.Contains(name, "SAN") { |
| 582 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 583 | } |
Kevin Lubick | 35115eb | 2017-02-17 10:25:34 -0500 | [diff] [blame] | 584 | if strings.Contains(name, "Ubuntu16") { |
| 585 | if strings.Contains(name, "Vulkan") { |
| 586 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk")) |
| 587 | } |
Kevin Lubick | 0a51b48 | 2017-02-06 12:45:29 -0500 | [diff] [blame] | 588 | if strings.Contains(name, "Release") { |
| 589 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_release")) |
| 590 | } else { |
| 591 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_debug")) |
| 592 | } |
| 593 | } |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 594 | // Skpbench only needs skps |
| 595 | if strings.Contains(name, "Skpbench") { |
| 596 | pkgs = []*specs.CipdPackage{ |
| 597 | b.MustGetCipdPackageFromAsset("skp"), |
| 598 | } |
| 599 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 600 | |
| 601 | // Test bots. |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 602 | if parts["role"] == "Test" && !strings.Contains(name, "-CT_") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 603 | deps = append(deps, test(b, name, parts, compileTaskName, pkgs)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | // Perf bots. |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 607 | if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 608 | deps = append(deps, perf(b, name, parts, compileTaskName, pkgs)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | // Add the Job spec. |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 612 | j := &specs.JobSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 613 | Priority: 0.8, |
| 614 | TaskSpecs: deps, |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 615 | } |
| 616 | if name == "Housekeeper-Nightly-RecreateSKPs_Canary" { |
| 617 | j.Trigger = "nightly" |
| 618 | } |
| 619 | if name == "Housekeeper-Weekly-RecreateSKPs" { |
| 620 | j.Trigger = "weekly" |
| 621 | } |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 622 | if name == "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs" { |
| 623 | j.Trigger = "weekly" |
| 624 | } |
Eric Boren | 8615fe5 | 2016-12-12 14:30:12 -0500 | [diff] [blame] | 625 | b.MustAddJob(name, j) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 626 | } |
| 627 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 628 | func loadJson(flag *string, defaultFlag string, val interface{}) { |
| 629 | if *flag == "" { |
| 630 | *flag = defaultFlag |
| 631 | } |
| 632 | b, err := ioutil.ReadFile(*flag) |
| 633 | if err != nil { |
| 634 | glog.Fatal(err) |
| 635 | } |
| 636 | if err := json.Unmarshal(b, val); err != nil { |
| 637 | glog.Fatal(err) |
| 638 | } |
| 639 | } |
| 640 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 641 | // Regenerate the tasks.json file. |
| 642 | func main() { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 643 | b := specs.MustNewTasksCfgBuilder() |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 644 | b.SetAssetsDir(*assetsDir) |
| 645 | infraBots := path.Join(b.CheckoutRoot(), "infra", "bots") |
| 646 | |
| 647 | // Load the jobs from a JSON file. |
| 648 | loadJson(jobsFile, path.Join(infraBots, "jobs.json"), &JOBS) |
| 649 | |
| 650 | // Load the GPU mapping from a JSON file. |
| 651 | loadJson(gpuMapFile, path.Join(infraBots, "gpu_map.json"), &GPU_MAPPING) |
| 652 | |
| 653 | // Load the Android device mapping from a JSON file. |
| 654 | loadJson(androidMapFile, path.Join(infraBots, "android_map.json"), &ANDROID_MAPPING) |
| 655 | |
| 656 | // Load general config information from a JSON file. |
| 657 | loadJson(cfgFile, path.Join(infraBots, "cfg.json"), &CONFIG) |
| 658 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 659 | // Create the JobNameSchema. |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 660 | if *builderNameSchemaFile == "" { |
| 661 | *builderNameSchemaFile = path.Join(b.CheckoutRoot(), "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json") |
| 662 | } |
| 663 | schema, err := NewJobNameSchema(*builderNameSchemaFile) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 664 | if err != nil { |
| 665 | glog.Fatal(err) |
| 666 | } |
| 667 | jobNameSchema = schema |
| 668 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 669 | // Create Tasks and Jobs. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 670 | for _, name := range JOBS { |
| 671 | process(b, name) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 672 | } |
| 673 | |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 674 | b.MustFinish() |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | // TODO(borenet): The below really belongs in its own file, probably next to the |
| 678 | // builder_name_schema.json file. |
| 679 | |
| 680 | // JobNameSchema is a struct used for (de)constructing Job names in a |
| 681 | // predictable format. |
| 682 | type JobNameSchema struct { |
| 683 | Schema map[string][]string `json:"builder_name_schema"` |
| 684 | Sep string `json:"builder_name_sep"` |
| 685 | } |
| 686 | |
| 687 | // NewJobNameSchema returns a JobNameSchema instance based on the given JSON |
| 688 | // file. |
| 689 | func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) { |
| 690 | var rv JobNameSchema |
| 691 | f, err := os.Open(jsonFile) |
| 692 | if err != nil { |
| 693 | return nil, err |
| 694 | } |
| 695 | defer util.Close(f) |
| 696 | if err := json.NewDecoder(f).Decode(&rv); err != nil { |
| 697 | return nil, err |
| 698 | } |
| 699 | return &rv, nil |
| 700 | } |
| 701 | |
| 702 | // ParseJobName splits the given Job name into its component parts, according |
| 703 | // to the schema. |
| 704 | func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) { |
| 705 | split := strings.Split(n, s.Sep) |
| 706 | if len(split) < 2 { |
| 707 | return nil, fmt.Errorf("Invalid job name: %q", n) |
| 708 | } |
| 709 | role := split[0] |
| 710 | split = split[1:] |
| 711 | keys, ok := s.Schema[role] |
| 712 | if !ok { |
| 713 | return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role) |
| 714 | } |
| 715 | extraConfig := "" |
| 716 | if len(split) == len(keys)+1 { |
| 717 | extraConfig = split[len(split)-1] |
| 718 | split = split[:len(split)-1] |
| 719 | } |
| 720 | if len(split) != len(keys) { |
| 721 | return nil, fmt.Errorf("Invalid job name; %q has incorrect number of parts.", n) |
| 722 | } |
| 723 | rv := make(map[string]string, len(keys)+2) |
| 724 | rv["role"] = role |
| 725 | if extraConfig != "" { |
| 726 | rv["extra_config"] = extraConfig |
| 727 | } |
| 728 | for i, k := range keys { |
| 729 | rv[k] = split[i] |
| 730 | } |
| 731 | return rv, nil |
| 732 | } |
| 733 | |
| 734 | // MakeJobName assembles the given parts of a Job name, according to the schema. |
| 735 | func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) { |
| 736 | role, ok := parts["role"] |
| 737 | if !ok { |
| 738 | return "", fmt.Errorf("Invalid job parts; jobs must have a role.") |
| 739 | } |
| 740 | keys, ok := s.Schema[role] |
| 741 | if !ok { |
| 742 | return "", fmt.Errorf("Invalid job parts; unknown role %q", role) |
| 743 | } |
| 744 | rvParts := make([]string, 0, len(parts)) |
| 745 | rvParts = append(rvParts, role) |
| 746 | for _, k := range keys { |
| 747 | v, ok := parts[k] |
| 748 | if !ok { |
| 749 | return "", fmt.Errorf("Invalid job parts; missing %q", k) |
| 750 | } |
| 751 | rvParts = append(rvParts, v) |
| 752 | } |
| 753 | if _, ok := parts["extra_config"]; ok { |
| 754 | rvParts = append(rvParts, parts["extra_config"]) |
| 755 | } |
| 756 | return strings.Join(rvParts, s.Sep), nil |
| 757 | } |