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