borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | package main |
| 6 | |
| 7 | /* |
| 8 | Generate the tasks.json file. |
| 9 | */ |
| 10 | |
| 11 | import ( |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 12 | "encoding/json" |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 13 | "flag" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 14 | "fmt" |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 15 | "io/ioutil" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 16 | "os" |
| 17 | "path" |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 18 | "path/filepath" |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 19 | "regexp" |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 20 | "runtime" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 21 | "sort" |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 22 | "strconv" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 23 | "strings" |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 24 | "time" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 25 | |
| 26 | "github.com/skia-dev/glog" |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 27 | "go.skia.org/infra/go/sklog" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 28 | "go.skia.org/infra/go/util" |
| 29 | "go.skia.org/infra/task_scheduler/go/specs" |
| 30 | ) |
| 31 | |
| 32 | const ( |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 33 | BUNDLE_RECIPES_NAME = "Housekeeper-PerCommit-BundleRecipes" |
| 34 | ISOLATE_SKIMAGE_NAME = "Housekeeper-PerCommit-IsolateSkImage" |
| 35 | ISOLATE_SKP_NAME = "Housekeeper-PerCommit-IsolateSKP" |
| 36 | ISOLATE_SVG_NAME = "Housekeeper-PerCommit-IsolateSVG" |
| 37 | ISOLATE_NDK_LINUX_NAME = "Housekeeper-PerCommit-IsolateAndroidNDKLinux" |
| 38 | ISOLATE_WIN_TOOLCHAIN_NAME = "Housekeeper-PerCommit-IsolateWinToolchain" |
| 39 | ISOLATE_WIN_VULKAN_SDK_NAME = "Housekeeper-PerCommit-IsolateWinVulkanSDK" |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 40 | |
Eric Boren | 170c39c | 2017-11-15 11:22:57 -0500 | [diff] [blame] | 41 | DEFAULT_OS_DEBIAN = "Debian-9.1" |
| 42 | DEFAULT_OS_LINUX_GCE = "Debian-9.2" |
Ben Wagner | 3f67914 | 2017-11-27 13:02:25 -0500 | [diff] [blame] | 43 | DEFAULT_OS_MAC = "Mac-10.13.1" |
Eric Boren | 170c39c | 2017-11-15 11:22:57 -0500 | [diff] [blame] | 44 | DEFAULT_OS_UBUNTU = "Ubuntu-14.04" |
| 45 | DEFAULT_OS_WIN = "Windows-2016Server-14393" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 46 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 47 | // Name prefix for upload jobs. |
| 48 | PREFIX_UPLOAD = "Upload" |
| 49 | ) |
| 50 | |
| 51 | var ( |
| 52 | // "Constants" |
| 53 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 54 | // Top-level list of all jobs to run at each commit; loaded from |
| 55 | // jobs.json. |
| 56 | JOBS []string |
| 57 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 58 | // General configuration information. |
| 59 | CONFIG struct { |
Kevin Lubick | c795a4c | 2017-10-09 15:26:19 -0400 | [diff] [blame] | 60 | GsBucketCoverage string `json:"gs_bucket_coverage"` |
| 61 | GsBucketGm string `json:"gs_bucket_gm"` |
| 62 | GsBucketNano string `json:"gs_bucket_nano"` |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 63 | GsBucketCalm string `json:"gs_bucket_calm"` |
Kevin Lubick | c795a4c | 2017-10-09 15:26:19 -0400 | [diff] [blame] | 64 | NoUpload []string `json:"no_upload"` |
| 65 | Pool string `json:"pool"` |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 68 | // alternateSwarmDimensions can be set in an init function to override the default swarming bot |
| 69 | // dimensions for the given task. |
| 70 | alternateSwarmDimensions func(parts map[string]string) []string |
| 71 | |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 72 | // internalHardwareLabelFn can be set in an init function to provide an |
| 73 | // internal_hardware_label variable to the recipe. |
Eric Boren | 4dc4aaf | 2017-09-15 14:09:07 -0400 | [diff] [blame] | 74 | internalHardwareLabelFn func(parts map[string]string) *int |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 75 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 76 | // Defines the structure of job names. |
| 77 | jobNameSchema *JobNameSchema |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 78 | |
Eric Boren | f4a5fc7 | 2017-06-06 08:27:09 -0400 | [diff] [blame] | 79 | // Git 2.13. |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 80 | cipdGit1 = &specs.CipdPackage{ |
| 81 | Name: fmt.Sprintf("infra/git/${platform}"), |
| 82 | Path: "git", |
| 83 | Version: fmt.Sprintf("version:2.13.0.chromium9"), |
Eric Boren | f4a5fc7 | 2017-06-06 08:27:09 -0400 | [diff] [blame] | 84 | } |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 85 | cipdGit2 = &specs.CipdPackage{ |
| 86 | Name: fmt.Sprintf("infra/tools/git/${platform}"), |
| 87 | Path: "git", |
| 88 | Version: fmt.Sprintf("git_revision:a78b5f3658c0578a017db48df97d20ac09822bcd"), |
| 89 | } |
Eric Boren | f4a5fc7 | 2017-06-06 08:27:09 -0400 | [diff] [blame] | 90 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 91 | // Flags. |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 92 | 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.") |
| 93 | assetsDir = flag.String("assets_dir", "", "Directory containing assets.") |
| 94 | cfgFile = flag.String("cfg_file", "", "JSON file containing general configuration information.") |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 95 | jobsFile = flag.String("jobs", "", "JSON file containing jobs to run.") |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 96 | ) |
| 97 | |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 98 | // internalHardwareLabel returns the internal ID for the bot, if any. |
Eric Boren | 4dc4aaf | 2017-09-15 14:09:07 -0400 | [diff] [blame] | 99 | func internalHardwareLabel(parts map[string]string) *int { |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 100 | if internalHardwareLabelFn != nil { |
| 101 | return internalHardwareLabelFn(parts) |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 102 | } |
| 103 | return nil |
| 104 | } |
| 105 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 106 | // linuxGceDimensions are the Swarming dimensions for Linux GCE |
| 107 | // instances. |
| 108 | func linuxGceDimensions() []string { |
| 109 | return []string{ |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 110 | // Specify CPU to avoid running builds on bots with a more unique CPU. |
| 111 | "cpu:x86-64-Haswell_GCE", |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 112 | "gpu:none", |
Eric Boren | 170c39c | 2017-11-15 11:22:57 -0500 | [diff] [blame] | 113 | fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE), |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 114 | fmt.Sprintf("pool:%s", CONFIG.Pool), |
| 115 | } |
| 116 | } |
| 117 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 118 | // deriveCompileTaskName returns the name of a compile task based on the given |
| 119 | // job name. |
| 120 | func deriveCompileTaskName(jobName string, parts map[string]string) string { |
| 121 | if parts["role"] == "Housekeeper" { |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 122 | return "Build-Debian9-GCC-x86_64-Release-Shared" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 123 | } else if parts["role"] == "Test" || parts["role"] == "Perf" { |
| 124 | task_os := parts["os"] |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 125 | ec := []string{} |
| 126 | if val := parts["extra_config"]; val != "" { |
| 127 | ec = strings.Split(val, "_") |
Mike Klein | 0c5fdcb | 2017-11-13 12:40:46 -0500 | [diff] [blame] | 128 | ignore := []string{"Skpbench", "AbandonGpuContext", "PreAbandonGpuContext", "Valgrind", "ReleaseAndAbandonGpuContext", "CCPR", "FSAA", "FAAA", "FDAA", "NativeFonts", "GDI"} |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 129 | keep := make([]string, 0, len(ec)) |
| 130 | for _, part := range ec { |
| 131 | if !util.In(part, ignore) { |
| 132 | keep = append(keep, part) |
| 133 | } |
| 134 | } |
| 135 | ec = keep |
Eric Boren | 6ec17e3 | 2017-04-26 14:25:29 -0400 | [diff] [blame] | 136 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 137 | if task_os == "Android" { |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 138 | if !util.In("Android", ec) { |
| 139 | ec = append([]string{"Android"}, ec...) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 140 | } |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 141 | task_os = "Debian9" |
Kevin Lubick | dcd2a90 | 2017-03-08 14:01:01 -0500 | [diff] [blame] | 142 | } else if task_os == "Chromecast" { |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 143 | task_os = "Debian9" |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 144 | ec = append([]string{"Chromecast"}, ec...) |
Kevin Lubick | cb6f398 | 2017-04-07 10:04:08 -0400 | [diff] [blame] | 145 | } else if strings.Contains(task_os, "ChromeOS") { |
Kevin Lubick | b718fbb | 2017-11-02 09:34:08 -0400 | [diff] [blame] | 146 | ec = append([]string{"Chromebook", "GLES"}, ec...) |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 147 | task_os = "Debian9" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 148 | } else if task_os == "iOS" { |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 149 | ec = append([]string{task_os}, ec...) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 150 | task_os = "Mac" |
| 151 | } else if strings.Contains(task_os, "Win") { |
| 152 | task_os = "Win" |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 153 | } else if strings.Contains(task_os, "Ubuntu") || strings.Contains(task_os, "Debian") { |
| 154 | task_os = "Debian9" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 155 | } |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 156 | jobNameMap := map[string]string{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 157 | "role": "Build", |
| 158 | "os": task_os, |
| 159 | "compiler": parts["compiler"], |
| 160 | "target_arch": parts["arch"], |
| 161 | "configuration": parts["configuration"], |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 162 | } |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 163 | if len(ec) > 0 { |
| 164 | jobNameMap["extra_config"] = strings.Join(ec, "_") |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 165 | } |
| 166 | name, err := jobNameSchema.MakeJobName(jobNameMap) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 167 | if err != nil { |
| 168 | glog.Fatal(err) |
| 169 | } |
| 170 | return name |
| 171 | } else { |
| 172 | return jobName |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // swarmDimensions generates swarming bot dimensions for the given task. |
| 177 | func swarmDimensions(parts map[string]string) []string { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 178 | if alternateSwarmDimensions != nil { |
| 179 | return alternateSwarmDimensions(parts) |
| 180 | } |
| 181 | return defaultSwarmDimensions(parts) |
| 182 | } |
| 183 | |
| 184 | // defaultSwarmDimensions generates default swarming bot dimensions for the given task. |
| 185 | func defaultSwarmDimensions(parts map[string]string) []string { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 186 | d := map[string]string{ |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 187 | "pool": CONFIG.Pool, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 188 | } |
| 189 | if os, ok := parts["os"]; ok { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 190 | d["os"], ok = map[string]string{ |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 191 | "Android": "Android", |
| 192 | "Chromecast": "Android", |
Kevin Lubick | cb6f398 | 2017-04-07 10:04:08 -0400 | [diff] [blame] | 193 | "ChromeOS": "ChromeOS", |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 194 | "Debian9": DEFAULT_OS_DEBIAN, |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 195 | "Mac": DEFAULT_OS_MAC, |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 196 | "Ubuntu14": DEFAULT_OS_UBUNTU, |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 197 | "Ubuntu16": "Ubuntu-16.10", |
Eric Boren | 810c2b6 | 2017-07-11 08:11:15 -0400 | [diff] [blame] | 198 | "Ubuntu17": "Ubuntu-17.04", |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 199 | "Win": DEFAULT_OS_WIN, |
Ben Wagner | 40226b4 | 2017-05-02 13:13:13 -0400 | [diff] [blame] | 200 | "Win10": "Windows-10-15063", |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 201 | "Win2k8": "Windows-2008ServerR2-SP1", |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 202 | "Win2016": DEFAULT_OS_WIN, |
Ben Wagner | 56738d8 | 2017-04-18 15:38:15 -0400 | [diff] [blame] | 203 | "Win7": "Windows-7-SP1", |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 204 | "Win8": "Windows-8.1-SP0", |
Stephan Altmueller | ddad85b | 2017-05-19 13:08:19 -0400 | [diff] [blame] | 205 | "iOS": "iOS-10.3.1", |
Eric Boren | 54ff2fc | 2016-12-02 12:09:10 -0500 | [diff] [blame] | 206 | }[os] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 207 | if !ok { |
| 208 | glog.Fatalf("Entry %q not found in OS mapping.", os) |
| 209 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 210 | } else { |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 211 | d["os"] = DEFAULT_OS_DEBIAN |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 212 | } |
Yuqian Li | ab246cb | 2017-11-02 13:48:23 -0400 | [diff] [blame] | 213 | if parts["role"] == "Test" || parts["role"] == "Perf" || parts["role"] == "Calmbench" { |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 214 | if strings.Contains(parts["os"], "Android") || strings.Contains(parts["os"], "Chromecast") { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 215 | // For Android, the device type is a better dimension |
| 216 | // than CPU or GPU. |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 217 | deviceInfo, ok := map[string][]string{ |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 218 | "AndroidOne": {"sprout", "MOB30Q"}, |
| 219 | "Chorizo": {"chorizo", "1.24_82923"}, |
Ben Wagner | 0762bdf | 2017-11-28 09:41:48 -0500 | [diff] [blame] | 220 | "GalaxyS6": {"zerofltetmo", "NRD90M_G920TUVU5FQK1"}, |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 221 | "GalaxyS7_G930A": {"heroqlteatt", "NRD90M_G930AUCS4BQC2"}, |
| 222 | "GalaxyS7_G930FD": {"herolte", "NRD90M_G930FXXU1DQAS"}, |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 223 | "MotoG4": {"athene", "NPJ25.93-14"}, |
Ben Wagner | ee3123c | 2017-12-06 16:29:04 -0500 | [diff] [blame] | 224 | "NVIDIA_Shield": {"foster", "NRD90M_1915764_848"}, |
| 225 | "Nexus10": {"manta", "LMY49J_2640980"}, |
| 226 | "Nexus5": {"hammerhead", "M4B30Z_3437181"}, |
Ben Wagner | eb549c8 | 2017-11-17 08:59:44 -0500 | [diff] [blame] | 227 | "Nexus5x": {"bullhead", "OPR6.170623.023"}, |
Ben Wagner | ee3123c | 2017-12-06 16:29:04 -0500 | [diff] [blame] | 228 | "Nexus7": {"grouper", "LMY47V_1836172"}, // 2012 Nexus 7 |
Ben Wagner | 9539a8c | 2017-11-02 14:09:32 -0400 | [diff] [blame] | 229 | "NexusPlayer": {"fugu", "OPR6.170623.021"}, |
Kevin Lubick | 832b222 | 2017-09-26 14:07:38 -0400 | [diff] [blame] | 230 | "Pixel": {"sailfish", "OPR3.170623.008"}, |
Kevin Lubick | b018f7b | 2017-10-31 14:44:08 -0400 | [diff] [blame] | 231 | "Pixel2XL": {"taimen", "OPD1.170816.023"}, |
Kevin Lubick | 674027a | 2017-10-31 09:47:38 -0400 | [diff] [blame] | 232 | "PixelC": {"dragon", "OPR1.170623.034"}, |
Kevin Lubick | 832b222 | 2017-09-26 14:07:38 -0400 | [diff] [blame] | 233 | "PixelXL": {"marlin", "OPR3.170623.008"}, |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 234 | }[parts["model"]] |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 235 | if !ok { |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 236 | glog.Fatalf("Entry %q not found in Android mapping.", parts["model"]) |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 237 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 238 | d["device_type"] = deviceInfo[0] |
| 239 | d["device_os"] = deviceInfo[1] |
Kevin Lubick | 4fd283e | 2017-12-07 11:19:31 -0500 | [diff] [blame] | 240 | // TODO(kjlubick): Remove the python dimension after we have removed the |
| 241 | // Nexus5x devices from the local lab (on Monday, Dec 11, 2017 should be fine). |
Kevin Lubick | 0f727ff | 2017-12-06 15:05:29 -0500 | [diff] [blame] | 242 | d["python"] = "2.7.9" // This indicates a RPI, e.g. in Skolo. Golo is 2.7.12 |
Kevin Lubick | 4fd283e | 2017-12-07 11:19:31 -0500 | [diff] [blame] | 243 | if parts["model"] == "Nexus5x" { |
| 244 | d["python"] = "2.7.12" |
| 245 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 246 | } else if strings.Contains(parts["os"], "iOS") { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 247 | device, ok := map[string]string{ |
Eric Boren | 792079c | 2016-11-09 14:03:20 -0500 | [diff] [blame] | 248 | "iPadMini4": "iPad5,1", |
Stephan Altmueller | 63e843d | 2017-04-25 11:38:38 -0400 | [diff] [blame] | 249 | "iPhone6": "iPhone7,2", |
| 250 | "iPhone7": "iPhone9,1", |
| 251 | "iPadPro": "iPad6,3", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 252 | }[parts["model"]] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 253 | if !ok { |
| 254 | glog.Fatalf("Entry %q not found in iOS mapping.", parts["model"]) |
| 255 | } |
| 256 | d["device"] = device |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 257 | } else if parts["cpu_or_gpu"] == "CPU" { |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 258 | modelMapping, ok := map[string]map[string]string{ |
| 259 | "AVX": { |
| 260 | "MacMini7.1": "x86-64-E5-2697_v2", |
| 261 | "Golo": "x86-64-E5-2670", |
| 262 | }, |
| 263 | "AVX2": { |
Ben Wagner | 85fb42a | 2017-11-07 16:57:37 -0500 | [diff] [blame] | 264 | "GCE": "x86-64-Haswell_GCE", |
Mike Klein | 9a01a21 | 2017-11-03 12:19:54 -0400 | [diff] [blame] | 265 | "NUC5i7RYH": "x86-64-i7-5557U", |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 266 | }, |
Ben Wagner | b268d23 | 2017-09-28 16:38:34 -0400 | [diff] [blame] | 267 | "AVX512": { |
| 268 | "GCE": "x86-64-Skylake_GCE", |
| 269 | }, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 270 | }[parts["cpu_or_gpu_value"]] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 271 | if !ok { |
| 272 | glog.Fatalf("Entry %q not found in CPU mapping.", parts["cpu_or_gpu_value"]) |
| 273 | } |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 274 | cpu, ok := modelMapping[parts["model"]] |
| 275 | if !ok { |
| 276 | glog.Fatalf("Entry %q not found in %q model mapping.", parts["model"], parts["cpu_or_gpu_value"]) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 277 | } |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 278 | d["cpu"] = cpu |
Eric Boren | 170c39c | 2017-11-15 11:22:57 -0500 | [diff] [blame] | 279 | if parts["model"] == "GCE" && d["os"] == DEFAULT_OS_DEBIAN { |
| 280 | d["os"] = DEFAULT_OS_LINUX_GCE |
| 281 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 282 | } else { |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 283 | if strings.Contains(parts["os"], "Win") { |
| 284 | gpu, ok := map[string]string{ |
Ben Wagner | 0d2b091 | 2017-08-15 12:43:55 -0400 | [diff] [blame] | 285 | "GT610": "10de:104a-22.21.13.8205", |
Ben Wagner | 85fb42a | 2017-11-07 16:57:37 -0500 | [diff] [blame] | 286 | "GTX1070": "10de:1ba1-23.21.13.8813", |
| 287 | "GTX660": "10de:11c0-23.21.13.8813", |
| 288 | "GTX960": "10de:1401-23.21.13.8813", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 289 | "IntelHD530": "8086:1912-21.20.16.4590", |
Ben Wagner | 5698b00 | 2017-08-04 11:25:33 -0400 | [diff] [blame] | 290 | "IntelHD4400": "8086:0a16-20.19.15.4703", |
Ben Wagner | 3c28653 | 2017-08-11 10:35:57 -0400 | [diff] [blame] | 291 | "IntelHD4600": "8086:0412-20.19.15.4703", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 292 | "IntelIris540": "8086:1926-21.20.16.4590", |
Ben Wagner | 3c28653 | 2017-08-11 10:35:57 -0400 | [diff] [blame] | 293 | "IntelIris6100": "8086:162b-20.19.15.4703", |
Ben Wagner | 2040ed2 | 2017-11-22 11:22:22 -0500 | [diff] [blame] | 294 | "RadeonHD7770": "1002:683d-22.19.165.512", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 295 | "RadeonR9M470X": "1002:6646-22.19.165.512", |
Ben Wagner | ae532f6 | 2017-08-02 23:24:16 -0400 | [diff] [blame] | 296 | "QuadroP400": "10de:1cb3-22.21.13.8205", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 297 | }[parts["cpu_or_gpu_value"]] |
| 298 | if !ok { |
| 299 | glog.Fatalf("Entry %q not found in Win GPU mapping.", parts["cpu_or_gpu_value"]) |
| 300 | } |
| 301 | d["gpu"] = gpu |
Ben Wagner | 0843589 | 2017-02-18 23:28:26 -0500 | [diff] [blame] | 302 | |
Ben Wagner | 4b1df02 | 2017-06-15 12:28:04 -0400 | [diff] [blame] | 303 | // Specify cpu dimension for NUCs and ShuttleCs. We temporarily have two |
| 304 | // types of machines with a GTX960. |
| 305 | cpu, ok := map[string]string{ |
| 306 | "NUC6i7KYK": "x86-64-i7-6770HQ", |
| 307 | "ShuttleC": "x86-64-i7-6700K", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 308 | }[parts["model"]] |
| 309 | if ok { |
Ben Wagner | 4b1df02 | 2017-06-15 12:28:04 -0400 | [diff] [blame] | 310 | d["cpu"] = cpu |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 311 | } |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 312 | } else if strings.Contains(parts["os"], "Ubuntu") || strings.Contains(parts["os"], "Debian") { |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 313 | gpu, ok := map[string]string{ |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 314 | // Intel drivers come from CIPD, so no need to specify the version here. |
| 315 | "IntelBayTrail": "8086:0f31", |
| 316 | "IntelHD2000": "8086:0102", |
| 317 | "IntelHD405": "8086:22b1", |
| 318 | "IntelIris540": "8086:1926", |
Ben Wagner | c274ec4 | 2017-08-03 22:29:22 -0400 | [diff] [blame] | 319 | "QuadroP400": "10de:1cb3-384.59", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 320 | }[parts["cpu_or_gpu_value"]] |
| 321 | if !ok { |
| 322 | glog.Fatalf("Entry %q not found in Ubuntu GPU mapping.", parts["cpu_or_gpu_value"]) |
| 323 | } |
| 324 | d["gpu"] = gpu |
| 325 | } else if strings.Contains(parts["os"], "Mac") { |
| 326 | gpu, ok := map[string]string{ |
Ben Wagner | cc4221b | 2017-08-17 17:29:04 -0400 | [diff] [blame] | 327 | "IntelIris5100": "8086:0a2e", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 328 | }[parts["cpu_or_gpu_value"]] |
| 329 | if !ok { |
| 330 | glog.Fatalf("Entry %q not found in Mac GPU mapping.", parts["cpu_or_gpu_value"]) |
| 331 | } |
| 332 | d["gpu"] = gpu |
| 333 | } else if strings.Contains(parts["os"], "ChromeOS") { |
Kevin Lubick | 64ca6be | 2017-12-04 15:43:31 -0500 | [diff] [blame] | 334 | version, ok := map[string]string{ |
| 335 | "MaliT604": "9901.12.0", |
| 336 | "MaliT764": "10172.0.0", |
| 337 | "MaliT860": "10172.0.0", |
Kevin Lubick | 0b1b9c2 | 2017-12-08 14:14:38 -0500 | [diff] [blame^] | 338 | "PowerVRGX6250": "10176.5.0", |
Kevin Lubick | 64ca6be | 2017-12-04 15:43:31 -0500 | [diff] [blame] | 339 | "TegraK1": "10172.0.0", |
| 340 | "IntelHDGraphics615": "10032.17.0", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 341 | }[parts["cpu_or_gpu_value"]] |
| 342 | if !ok { |
| 343 | glog.Fatalf("Entry %q not found in ChromeOS GPU mapping.", parts["cpu_or_gpu_value"]) |
| 344 | } |
Kevin Lubick | 64ca6be | 2017-12-04 15:43:31 -0500 | [diff] [blame] | 345 | d["gpu"] = parts["cpu_or_gpu_value"] |
| 346 | d["release_version"] = version |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 347 | } else { |
| 348 | glog.Fatalf("Unknown GPU mapping for OS %q.", parts["os"]) |
Ben Wagner | 0843589 | 2017-02-18 23:28:26 -0500 | [diff] [blame] | 349 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 350 | } |
| 351 | } else { |
| 352 | d["gpu"] = "none" |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 353 | if d["os"] == DEFAULT_OS_DEBIAN { |
Kevin Lubick | 4610a9b | 2017-03-22 15:54:54 -0400 | [diff] [blame] | 354 | return linuxGceDimensions() |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 355 | } else if d["os"] == DEFAULT_OS_WIN { |
| 356 | // Windows CPU bots. |
Ben Wagner | a78f1bc | 2017-09-26 18:19:56 -0400 | [diff] [blame] | 357 | d["cpu"] = "x86-64-Haswell_GCE" |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 358 | } else if d["os"] == DEFAULT_OS_MAC { |
| 359 | // Mac CPU bots. |
Ben Wagner | a78f1bc | 2017-09-26 18:19:56 -0400 | [diff] [blame] | 360 | d["cpu"] = "x86-64-E5-2697_v2" |
Kevin Lubick | 4610a9b | 2017-03-22 15:54:54 -0400 | [diff] [blame] | 361 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 362 | } |
Kevin Lubick | 4610a9b | 2017-03-22 15:54:54 -0400 | [diff] [blame] | 363 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 364 | rv := make([]string, 0, len(d)) |
| 365 | for k, v := range d { |
| 366 | rv = append(rv, fmt.Sprintf("%s:%s", k, v)) |
| 367 | } |
| 368 | sort.Strings(rv) |
| 369 | return rv |
| 370 | } |
| 371 | |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 372 | // relpath returns the relative path to the given file from the config file. |
| 373 | func relpath(f string) string { |
| 374 | _, filename, _, _ := runtime.Caller(0) |
| 375 | dir := path.Dir(filename) |
| 376 | rel := dir |
| 377 | if *cfgFile != "" { |
| 378 | rel = path.Dir(*cfgFile) |
| 379 | } |
| 380 | rv, err := filepath.Rel(rel, path.Join(dir, f)) |
| 381 | if err != nil { |
| 382 | sklog.Fatal(err) |
| 383 | } |
| 384 | return rv |
| 385 | } |
| 386 | |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 387 | // bundleRecipes generates the task to bundle and isolate the recipes. |
| 388 | func bundleRecipes(b *specs.TasksCfgBuilder) string { |
| 389 | b.MustAddTask(BUNDLE_RECIPES_NAME, &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 390 | CipdPackages: []*specs.CipdPackage{cipdGit1, cipdGit2}, |
| 391 | Dimensions: linuxGceDimensions(), |
| 392 | ExtraArgs: []string{ |
| 393 | "--workdir", "../../..", "bundle_recipes", |
| 394 | fmt.Sprintf("buildername=%s", BUNDLE_RECIPES_NAME), |
| 395 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 396 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 397 | Isolate: relpath("bundle_recipes.isolate"), |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 398 | Priority: 0.7, |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 399 | }) |
| 400 | return BUNDLE_RECIPES_NAME |
| 401 | } |
| 402 | |
Eric Boren | 23a6ec6 | 2017-04-07 08:31:22 -0400 | [diff] [blame] | 403 | // useBundledRecipes returns true iff the given bot should use bundled recipes |
| 404 | // instead of syncing recipe DEPS itself. |
| 405 | func useBundledRecipes(parts map[string]string) bool { |
| 406 | // Use bundled recipes for all test/perf tasks. |
| 407 | return true |
| 408 | } |
| 409 | |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 410 | type isolateAssetCfg struct { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 411 | isolateFile string |
| 412 | cipdPkg string |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | var ISOLATE_ASSET_MAPPING = map[string]isolateAssetCfg{ |
| 416 | ISOLATE_SKIMAGE_NAME: { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 417 | isolateFile: "isolate_skimage.isolate", |
| 418 | cipdPkg: "skimage", |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 419 | }, |
| 420 | ISOLATE_SKP_NAME: { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 421 | isolateFile: "isolate_skp.isolate", |
| 422 | cipdPkg: "skp", |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 423 | }, |
| 424 | ISOLATE_SVG_NAME: { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 425 | isolateFile: "isolate_svg.isolate", |
| 426 | cipdPkg: "svg", |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 427 | }, |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 428 | ISOLATE_NDK_LINUX_NAME: { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 429 | isolateFile: "isolate_ndk_linux.isolate", |
| 430 | cipdPkg: "android_ndk_linux", |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 431 | }, |
| 432 | ISOLATE_WIN_TOOLCHAIN_NAME: { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 433 | isolateFile: "isolate_win_toolchain.isolate", |
| 434 | cipdPkg: "win_toolchain", |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 435 | }, |
| 436 | ISOLATE_WIN_VULKAN_SDK_NAME: { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 437 | isolateFile: "isolate_win_vulkan_sdk.isolate", |
| 438 | cipdPkg: "win_vulkan_sdk", |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 439 | }, |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 440 | } |
| 441 | |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 442 | // bundleRecipes generates the task to bundle and isolate the recipes. |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 443 | func isolateCIPDAsset(b *specs.TasksCfgBuilder, name string) string { |
| 444 | b.MustAddTask(name, &specs.TaskSpec{ |
| 445 | CipdPackages: []*specs.CipdPackage{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 446 | b.MustGetCipdPackageFromAsset(ISOLATE_ASSET_MAPPING[name].cipdPkg), |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 447 | }, |
| 448 | Dimensions: linuxGceDimensions(), |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 449 | Isolate: relpath(ISOLATE_ASSET_MAPPING[name].isolateFile), |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 450 | Priority: 0.7, |
| 451 | }) |
| 452 | return name |
| 453 | } |
| 454 | |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 455 | // getIsolatedCIPDDeps returns the slice of Isolate_* tasks a given task needs. |
| 456 | // This allows us to save time on I/O bound bots, like the RPIs. |
| 457 | func getIsolatedCIPDDeps(parts map[string]string) []string { |
| 458 | deps := []string{} |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 459 | // Only do this on the RPIs for now. Other, faster machines shouldn't see much |
| 460 | // benefit and we don't need the extra complexity, for now |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 461 | rpiOS := []string{"Android", "ChromeOS", "iOS"} |
| 462 | |
| 463 | if o := parts["os"]; strings.Contains(o, "Chromecast") { |
| 464 | // Chromecasts don't have enough disk space to fit all of the content, |
| 465 | // so we do a subset of the skps. |
| 466 | deps = append(deps, ISOLATE_SKP_NAME) |
| 467 | } else if e := parts["extra_config"]; strings.Contains(e, "Skpbench") { |
| 468 | // Skpbench only needs skps |
| 469 | deps = append(deps, ISOLATE_SKP_NAME) |
| 470 | } else if util.In(o, rpiOS) { |
| 471 | deps = append(deps, ISOLATE_SKP_NAME) |
| 472 | deps = append(deps, ISOLATE_SVG_NAME) |
| 473 | deps = append(deps, ISOLATE_SKIMAGE_NAME) |
| 474 | } |
| 475 | |
| 476 | return deps |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 477 | } |
| 478 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 479 | // compile generates a compile task. Returns the name of the last task in the |
| 480 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 481 | func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 482 | // Collect the necessary CIPD packages. |
| 483 | pkgs := []*specs.CipdPackage{} |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 484 | deps := []string{} |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 485 | |
| 486 | // Android bots require a toolchain. |
| 487 | if strings.Contains(name, "Android") { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 488 | if strings.Contains(name, "Mac") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 489 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_darwin")) |
Mike Klein | 86c2c0f | 2016-11-02 13:13:16 -0400 | [diff] [blame] | 490 | } else if strings.Contains(name, "Win") { |
Mike Klein | e9215f0 | 2016-11-02 15:44:26 -0400 | [diff] [blame] | 491 | pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows") |
| 492 | pkg.Path = "n" |
| 493 | pkgs = append(pkgs, pkg) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 494 | } else { |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 495 | deps = append(deps, isolateCIPDAsset(b, ISOLATE_NDK_LINUX_NAME)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 496 | } |
Kevin Lubick | dcd2a90 | 2017-03-08 14:01:01 -0500 | [diff] [blame] | 497 | } else if strings.Contains(name, "Chromecast") { |
| 498 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("cast_toolchain")) |
Kevin Lubick | ffce079 | 2017-05-24 15:30:35 -0400 | [diff] [blame] | 499 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles")) |
Kevin Lubick | 261ea19 | 2017-04-05 07:32:45 -0400 | [diff] [blame] | 500 | } else if strings.Contains(name, "Chromebook") { |
| 501 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
Kevin Lubick | b718fbb | 2017-11-02 09:34:08 -0400 | [diff] [blame] | 502 | if parts["target_arch"] == "x86_64" { |
| 503 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_x86_64_gles")) |
| 504 | } else if parts["target_arch"] == "arm" { |
| 505 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("armhf_sysroot")) |
| 506 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles")) |
| 507 | } |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 508 | } else if strings.Contains(name, "Debian") { |
Kevin Lubick | 9c7dcac | 2017-01-18 09:24:56 -0500 | [diff] [blame] | 509 | if strings.Contains(name, "Clang") { |
| 510 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 511 | } |
| 512 | if strings.Contains(name, "Vulkan") { |
| 513 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk")) |
| 514 | } |
Kevin Lubick | ebf648e | 2017-09-21 13:45:16 -0400 | [diff] [blame] | 515 | if strings.Contains(name, "EMCC") { |
| 516 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("emscripten_sdk")) |
| 517 | } |
Mike Klein | 27dcee1 | 2016-11-09 16:31:42 -0500 | [diff] [blame] | 518 | } else if strings.Contains(name, "Win") { |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 519 | deps = append(deps, isolateCIPDAsset(b, ISOLATE_WIN_TOOLCHAIN_NAME)) |
Mike Klein | 8e3c42b | 2017-07-31 14:57:20 -0400 | [diff] [blame] | 520 | if strings.Contains(name, "Clang") { |
| 521 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_win")) |
| 522 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 523 | if strings.Contains(name, "Vulkan") { |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 524 | deps = append(deps, isolateCIPDAsset(b, ISOLATE_WIN_VULKAN_SDK_NAME)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 525 | } |
| 526 | } |
| 527 | |
Stephan Altmueller | 5f3b940 | 2017-03-20 13:38:45 -0400 | [diff] [blame] | 528 | dimensions := swarmDimensions(parts) |
Stephan Altmueller | 5f3b940 | 2017-03-20 13:38:45 -0400 | [diff] [blame] | 529 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 530 | // Add the task. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 531 | b.MustAddTask(name, &specs.TaskSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 532 | CipdPackages: pkgs, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 533 | Dimensions: dimensions, |
| 534 | Dependencies: deps, |
| 535 | ExtraArgs: []string{ |
| 536 | "--workdir", "../../..", "compile", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 537 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 538 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 539 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 540 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 541 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 542 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 543 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 544 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 545 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 546 | Isolate: relpath("compile_skia.isolate"), |
| 547 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 548 | }) |
Eric Boren | 8615fe5 | 2016-12-12 14:30:12 -0500 | [diff] [blame] | 549 | // All compile tasks are runnable as their own Job. Assert that the Job |
| 550 | // is listed in JOBS. |
| 551 | if !util.In(name, JOBS) { |
| 552 | glog.Fatalf("Job %q is missing from the JOBS list!", name) |
| 553 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 554 | return name |
| 555 | } |
| 556 | |
| 557 | // recreateSKPs generates a RecreateSKPs task. Returns the name of the last |
| 558 | // task in the generated chain of tasks, which the Job should add as a |
| 559 | // dependency. |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 560 | func recreateSKPs(b *specs.TasksCfgBuilder, name string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 561 | b.MustAddTask(name, &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 562 | CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")}, |
| 563 | Dimensions: linuxGceDimensions(), |
| 564 | ExecutionTimeout: 4 * time.Hour, |
| 565 | ExtraArgs: []string{ |
| 566 | "--workdir", "../../..", "recreate_skps", |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 567 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 568 | fmt.Sprintf("buildername=%s", name), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 569 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 570 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 571 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 572 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 573 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 574 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 575 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 576 | IoTimeout: 40 * time.Minute, |
| 577 | Isolate: relpath("compile_skia.isolate"), |
| 578 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 579 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 580 | return name |
| 581 | } |
| 582 | |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 583 | // updateMetaConfig generates a UpdateMetaConfig task. Returns the name of the |
| 584 | // last task in the generated chain of tasks, which the Job should add as a |
| 585 | // dependency. |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 586 | func updateMetaConfig(b *specs.TasksCfgBuilder, name string) string { |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 587 | b.MustAddTask(name, &specs.TaskSpec{ |
Stephan Altmueller | ddad85b | 2017-05-19 13:08:19 -0400 | [diff] [blame] | 588 | CipdPackages: []*specs.CipdPackage{}, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 589 | Dimensions: linuxGceDimensions(), |
| 590 | ExtraArgs: []string{ |
| 591 | "--workdir", "../../..", "update_meta_config", |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 592 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 593 | fmt.Sprintf("buildername=%s", name), |
| 594 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 595 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 596 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
| 597 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 598 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 599 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 600 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 601 | Isolate: relpath("meta_config.isolate"), |
| 602 | Priority: 0.8, |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 603 | }) |
| 604 | return name |
| 605 | } |
| 606 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 607 | // ctSKPs generates a CT SKPs task. Returns the name of the last task in the |
| 608 | // generated chain of tasks, which the Job should add as a dependency. |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 609 | func ctSKPs(b *specs.TasksCfgBuilder, name string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 610 | b.MustAddTask(name, &specs.TaskSpec{ |
Ben Wagner | 21c3fb9 | 2017-08-04 14:13:27 -0400 | [diff] [blame] | 611 | CipdPackages: []*specs.CipdPackage{}, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 612 | Dimensions: []string{ |
| 613 | "pool:SkiaCT", |
| 614 | fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE), |
| 615 | }, |
| 616 | ExecutionTimeout: 24 * time.Hour, |
| 617 | ExtraArgs: []string{ |
| 618 | "--workdir", "../../..", "ct_skps", |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 619 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 620 | fmt.Sprintf("buildername=%s", name), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 621 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 622 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 623 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 624 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 625 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 626 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 627 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 628 | IoTimeout: time.Hour, |
| 629 | Isolate: relpath("ct_skps_skia.isolate"), |
| 630 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 631 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 632 | return name |
| 633 | } |
| 634 | |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 635 | // checkGeneratedFiles verifies that no generated SKSL files have been edited |
| 636 | // by hand. |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 637 | func checkGeneratedFiles(b *specs.TasksCfgBuilder, name string) string { |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 638 | b.MustAddTask(name, &specs.TaskSpec{ |
| 639 | CipdPackages: []*specs.CipdPackage{}, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 640 | Dimensions: linuxGceDimensions(), |
| 641 | ExtraArgs: []string{ |
| 642 | "--workdir", "../../..", "check_generated_files", |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 643 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 644 | fmt.Sprintf("buildername=%s", name), |
| 645 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 646 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 647 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
| 648 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 649 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 650 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 651 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 652 | Isolate: relpath("compile_skia.isolate"), |
| 653 | Priority: 0.8, |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 654 | }) |
| 655 | return name |
| 656 | } |
| 657 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 658 | // housekeeper generates a Housekeeper task. Returns the name of the last task |
| 659 | // in the generated chain of tasks, which the Job should add as a dependency. |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 660 | func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string { |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 661 | b.MustAddTask(name, &specs.TaskSpec{ |
Eric Boren | 22f5ef7 | 2016-12-02 11:01:33 -0500 | [diff] [blame] | 662 | CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")}, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 663 | Dependencies: []string{compileTaskName}, |
| 664 | Dimensions: linuxGceDimensions(), |
| 665 | ExtraArgs: []string{ |
| 666 | "--workdir", "../../..", "housekeeper", |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 667 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 668 | fmt.Sprintf("buildername=%s", name), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 669 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 670 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 671 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 672 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 673 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 674 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 675 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 676 | Isolate: relpath("housekeeper_skia.isolate"), |
| 677 | Priority: 0.8, |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 678 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 679 | return name |
| 680 | } |
| 681 | |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 682 | // infra generates an infra_tests task. Returns the name of the last task in the |
| 683 | // generated chain of tasks, which the Job should add as a dependency. |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 684 | func infra(b *specs.TasksCfgBuilder, name string) string { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 685 | b.MustAddTask(name, &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 686 | CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")}, |
| 687 | Dimensions: linuxGceDimensions(), |
| 688 | ExtraArgs: []string{ |
| 689 | "--workdir", "../../..", "infra", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 690 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 691 | fmt.Sprintf("buildername=%s", name), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 692 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 693 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 694 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 695 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 696 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 697 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 698 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 699 | Isolate: relpath("infra_skia.isolate"), |
| 700 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 701 | }) |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 702 | return name |
| 703 | } |
| 704 | |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 705 | // calmbench generates a calmbench task. Returns the name of the last task in the |
| 706 | // generated chain of tasks, which the Job should add as a dependency. |
| 707 | func calmbench(b *specs.TasksCfgBuilder, name string, parts map[string]string) string { |
| 708 | s := &specs.TaskSpec{ |
| 709 | CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("clang_linux")}, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 710 | Dimensions: swarmDimensions(parts), |
| 711 | ExtraArgs: []string{ |
| 712 | "--workdir", "../../..", "calmbench", |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 713 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 714 | fmt.Sprintf("buildername=%s", name), |
| 715 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 716 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 717 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
| 718 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 719 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 720 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 721 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 722 | Isolate: relpath("infra_skia.isolate"), |
| 723 | Priority: 0.8, |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | s.Dependencies = append(s.Dependencies, ISOLATE_SKP_NAME, ISOLATE_SVG_NAME) |
| 727 | |
| 728 | b.MustAddTask(name, s) |
| 729 | |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 730 | // Upload results if necessary. |
| 731 | if strings.Contains(name, "Release") && doUpload(name) { |
| 732 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
| 733 | b.MustAddTask(uploadName, &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 734 | Dependencies: []string{name}, |
| 735 | Dimensions: linuxGceDimensions(), |
| 736 | ExtraArgs: []string{ |
| 737 | "--workdir", "../../..", "upload_calmbench_results", |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 738 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 739 | fmt.Sprintf("buildername=%s", name), |
| 740 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 741 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 742 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
| 743 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 744 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 745 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 746 | fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketCalm), |
| 747 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 748 | // We're using the same isolate as upload_nano_results |
| 749 | Isolate: relpath("upload_nano_results.isolate"), |
| 750 | Priority: 0.8, |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 751 | }) |
| 752 | return uploadName |
| 753 | } |
| 754 | |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 755 | return name |
| 756 | } |
| 757 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 758 | // doUpload indicates whether the given Job should upload its results. |
| 759 | func doUpload(name string) bool { |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 760 | for _, s := range CONFIG.NoUpload { |
| 761 | m, err := regexp.MatchString(s, name) |
| 762 | if err != nil { |
| 763 | glog.Fatal(err) |
| 764 | } |
| 765 | if m { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 766 | return false |
| 767 | } |
| 768 | } |
| 769 | return true |
| 770 | } |
| 771 | |
| 772 | // test generates a Test task. Returns the name of the last task in the |
| 773 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 774 | 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] | 775 | s := &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 776 | CipdPackages: pkgs, |
| 777 | Dependencies: []string{compileTaskName}, |
| 778 | Dimensions: swarmDimensions(parts), |
| 779 | ExecutionTimeout: 4 * time.Hour, |
| 780 | Expiration: 20 * time.Hour, |
| 781 | ExtraArgs: []string{ |
| 782 | "--workdir", "../../..", "test", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 783 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
Eric Boren | 9a9e387 | 2017-11-29 12:33:22 -0500 | [diff] [blame] | 784 | fmt.Sprintf("buildbucket_build_id=%s", specs.PLACEHOLDER_BUILDBUCKET_BUILD_ID), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 785 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 786 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 787 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 788 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 789 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 790 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 791 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 792 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 793 | IoTimeout: 40 * time.Minute, |
| 794 | Isolate: relpath("test_skia.isolate"), |
| 795 | MaxAttempts: 1, |
| 796 | Priority: 0.8, |
| 797 | } |
| 798 | if useBundledRecipes(parts) { |
| 799 | s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME) |
| 800 | if strings.Contains(parts["os"], "Win") { |
| 801 | s.Isolate = relpath("test_skia_bundled_win.isolate") |
| 802 | } else { |
| 803 | s.Isolate = relpath("test_skia_bundled_unix.isolate") |
| 804 | } |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 805 | } |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 806 | if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 { |
| 807 | s.Dependencies = append(s.Dependencies, deps...) |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 808 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 809 | if strings.Contains(parts["extra_config"], "Valgrind") { |
| 810 | s.ExecutionTimeout = 9 * time.Hour |
| 811 | s.Expiration = 48 * time.Hour |
| 812 | s.IoTimeout = time.Hour |
Eric Boren | d696df7 | 2017-05-31 15:09:10 -0400 | [diff] [blame] | 813 | s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind")) |
Kevin Lubick | ea61382 | 2017-12-04 10:20:23 -0500 | [diff] [blame] | 814 | s.Dimensions = append(s.Dimensions, "valgrind:1") |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 815 | } else if strings.Contains(parts["extra_config"], "MSAN") { |
| 816 | s.ExecutionTimeout = 9 * time.Hour |
Ben Wagner | a6b2ba2 | 2017-06-08 10:34:17 -0400 | [diff] [blame] | 817 | } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" { |
| 818 | // skia:6737 |
| 819 | s.ExecutionTimeout = 6 * time.Hour |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 820 | } |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 821 | iid := internalHardwareLabel(parts) |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 822 | if iid != nil { |
Eric Boren | 4dc4aaf | 2017-09-15 14:09:07 -0400 | [diff] [blame] | 823 | s.ExtraArgs = append(s.ExtraArgs, fmt.Sprintf("internal_hardware_label=%d", *iid)) |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 824 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 825 | b.MustAddTask(name, s) |
| 826 | |
Kevin Lubick | c795a4c | 2017-10-09 15:26:19 -0400 | [diff] [blame] | 827 | // Upload results if necessary. TODO(kjlubick): If we do coverage analysis at the same |
| 828 | // time as normal tests (which would be nice), cfg.json needs to have Coverage removed. |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 829 | if doUpload(name) { |
| 830 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 831 | b.MustAddTask(uploadName, &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 832 | Dependencies: []string{name}, |
| 833 | Dimensions: linuxGceDimensions(), |
| 834 | ExtraArgs: []string{ |
| 835 | "--workdir", "../../..", "upload_dm_results", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 836 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 837 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 838 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 839 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 840 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 841 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 842 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 843 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
Eric Boren | 965861b | 2017-02-06 15:38:41 -0500 | [diff] [blame] | 844 | fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketGm), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 845 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 846 | Isolate: relpath("upload_dm_results.isolate"), |
| 847 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 848 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 849 | return uploadName |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | return name |
| 853 | } |
| 854 | |
| 855 | func coverage(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string { |
| 856 | shards := 1 |
| 857 | deps := []string{} |
| 858 | |
| 859 | tf := parts["test_filter"] |
| 860 | if strings.Contains(tf, "Shard") { |
| 861 | // Expected Shard_NN |
| 862 | shardstr := strings.Split(tf, "_")[1] |
| 863 | var err error |
| 864 | shards, err = strconv.Atoi(shardstr) |
| 865 | if err != nil { |
| 866 | glog.Fatalf("Expected int for number of shards %q in %s: %s", shardstr, name, err) |
| 867 | } |
| 868 | } |
| 869 | for i := 0; i < shards; i++ { |
| 870 | n := strings.Replace(name, tf, fmt.Sprintf("shard_%02d_%02d", i, shards), 1) |
| 871 | s := &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 872 | CipdPackages: pkgs, |
| 873 | Dependencies: []string{compileTaskName}, |
| 874 | Dimensions: swarmDimensions(parts), |
| 875 | ExecutionTimeout: 4 * time.Hour, |
| 876 | Expiration: 20 * time.Hour, |
| 877 | ExtraArgs: []string{ |
| 878 | "--workdir", "../../..", "test", |
Kevin Lubick | c795a4c | 2017-10-09 15:26:19 -0400 | [diff] [blame] | 879 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 880 | fmt.Sprintf("buildername=%s", n), |
Kevin Lubick | c795a4c | 2017-10-09 15:26:19 -0400 | [diff] [blame] | 881 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 882 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 883 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
| 884 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 885 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 886 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
Kevin Lubick | c795a4c | 2017-10-09 15:26:19 -0400 | [diff] [blame] | 887 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 888 | IoTimeout: 40 * time.Minute, |
| 889 | Isolate: relpath("test_skia.isolate"), |
| 890 | MaxAttempts: 1, |
| 891 | Priority: 0.8, |
| 892 | } |
| 893 | if useBundledRecipes(parts) { |
| 894 | s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME) |
| 895 | if strings.Contains(parts["os"], "Win") { |
| 896 | s.Isolate = relpath("test_skia_bundled_win.isolate") |
| 897 | } else { |
| 898 | s.Isolate = relpath("test_skia_bundled_unix.isolate") |
| 899 | } |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 900 | } |
| 901 | if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 { |
| 902 | s.Dependencies = append(s.Dependencies, deps...) |
| 903 | } |
| 904 | b.MustAddTask(n, s) |
| 905 | deps = append(deps, n) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 906 | } |
Kevin Lubick | c795a4c | 2017-10-09 15:26:19 -0400 | [diff] [blame] | 907 | |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 908 | uploadName := fmt.Sprintf("%s%s%s", "Upload", jobNameSchema.Sep, name) |
| 909 | // We need clang_linux to get access to the llvm-profdata and llvm-cov binaries |
| 910 | // which are used to deal with the raw coverage data output by the Test step. |
| 911 | pkgs = append([]*specs.CipdPackage{}, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 912 | deps = append(deps, compileTaskName) |
| 913 | |
| 914 | b.MustAddTask(uploadName, &specs.TaskSpec{ |
| 915 | // A dependency on compileTaskName makes the TaskScheduler link the |
| 916 | // isolated output of the compile step to the input of the upload step, |
| 917 | // which gives us access to the instrumented binary. The binary is |
| 918 | // needed to figure out symbol names and line numbers. |
| 919 | Dependencies: deps, |
| 920 | Dimensions: linuxGceDimensions(), |
| 921 | CipdPackages: pkgs, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 922 | ExtraArgs: []string{ |
| 923 | "--workdir", "../../..", "upload_coverage_results", |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 924 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| 925 | fmt.Sprintf("buildername=%s", name), |
| 926 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 927 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| 928 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
| 929 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| 930 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 931 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| 932 | fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketCoverage), |
| 933 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 934 | Isolate: relpath("upload_coverage_results.isolate"), |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 935 | Priority: 0.8, |
| 936 | }) |
| 937 | return uploadName |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | // perf generates a Perf task. Returns the name of the last task in the |
| 941 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 942 | 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] | 943 | recipe := "perf" |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 944 | isolate := relpath("perf_skia.isolate") |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 945 | if strings.Contains(parts["extra_config"], "Skpbench") { |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 946 | recipe = "skpbench" |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 947 | isolate = relpath("skpbench_skia.isolate") |
| 948 | if useBundledRecipes(parts) { |
| 949 | if strings.Contains(parts["os"], "Win") { |
| 950 | isolate = relpath("skpbench_skia_bundled_win.isolate") |
| 951 | } else { |
| 952 | isolate = relpath("skpbench_skia_bundled_unix.isolate") |
| 953 | } |
| 954 | } |
| 955 | } else if useBundledRecipes(parts) { |
| 956 | if strings.Contains(parts["os"], "Win") { |
| 957 | isolate = relpath("perf_skia_bundled_win.isolate") |
| 958 | } else { |
| 959 | isolate = relpath("perf_skia_bundled_unix.isolate") |
| 960 | } |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 961 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 962 | s := &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 963 | CipdPackages: pkgs, |
| 964 | Dependencies: []string{compileTaskName}, |
| 965 | Dimensions: swarmDimensions(parts), |
| 966 | ExecutionTimeout: 4 * time.Hour, |
| 967 | Expiration: 20 * time.Hour, |
| 968 | ExtraArgs: []string{ |
| 969 | "--workdir", "../../..", recipe, |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 970 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 971 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 972 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 973 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 974 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 975 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 976 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 977 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 978 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 979 | IoTimeout: 40 * time.Minute, |
| 980 | Isolate: isolate, |
| 981 | MaxAttempts: 1, |
| 982 | Priority: 0.8, |
| 983 | } |
| 984 | if useBundledRecipes(parts) { |
| 985 | s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME) |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 986 | } |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 987 | if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 { |
| 988 | s.Dependencies = append(s.Dependencies, deps...) |
| 989 | } |
| 990 | |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 991 | if strings.Contains(parts["extra_config"], "Valgrind") { |
| 992 | s.ExecutionTimeout = 9 * time.Hour |
| 993 | s.Expiration = 48 * time.Hour |
| 994 | s.IoTimeout = time.Hour |
Eric Boren | c5a073d | 2017-06-01 07:13:33 -0400 | [diff] [blame] | 995 | s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind")) |
Kevin Lubick | ea61382 | 2017-12-04 10:20:23 -0500 | [diff] [blame] | 996 | s.Dimensions = append(s.Dimensions, "valgrind:1") |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 997 | } else if strings.Contains(parts["extra_config"], "MSAN") { |
| 998 | s.ExecutionTimeout = 9 * time.Hour |
Ben Wagner | a6b2ba2 | 2017-06-08 10:34:17 -0400 | [diff] [blame] | 999 | } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" { |
| 1000 | // skia:6737 |
| 1001 | s.ExecutionTimeout = 6 * time.Hour |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1002 | } |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 1003 | iid := internalHardwareLabel(parts) |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 1004 | if iid != nil { |
Eric Boren | 4dc4aaf | 2017-09-15 14:09:07 -0400 | [diff] [blame] | 1005 | s.ExtraArgs = append(s.ExtraArgs, fmt.Sprintf("internal_hardware_label=%d", *iid)) |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 1006 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1007 | b.MustAddTask(name, s) |
| 1008 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1009 | // Upload results if necessary. |
| 1010 | if strings.Contains(name, "Release") && doUpload(name) { |
| 1011 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1012 | b.MustAddTask(uploadName, &specs.TaskSpec{ |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1013 | Dependencies: []string{name}, |
| 1014 | Dimensions: linuxGceDimensions(), |
| 1015 | ExtraArgs: []string{ |
| 1016 | "--workdir", "../../..", "upload_nano_results", |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 1017 | fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1018 | fmt.Sprintf("buildername=%s", name), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1019 | fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| 1020 | fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
Eric Boren | 0941950 | 2017-04-21 09:37:37 -0400 | [diff] [blame] | 1021 | fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO), |
borenet | 98b2e7a | 2016-10-13 06:23:45 -0700 | [diff] [blame] | 1022 | fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
skia.buildbots | 2478c73 | 2016-11-04 14:37:26 -0400 | [diff] [blame] | 1023 | fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| 1024 | fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
Eric Boren | 965861b | 2017-02-06 15:38:41 -0500 | [diff] [blame] | 1025 | fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketNano), |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1026 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1027 | Isolate: relpath("upload_nano_results.isolate"), |
| 1028 | Priority: 0.8, |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1029 | }) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1030 | return uploadName |
| 1031 | } |
| 1032 | return name |
| 1033 | } |
| 1034 | |
| 1035 | // process generates tasks and jobs for the given job name. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1036 | func process(b *specs.TasksCfgBuilder, name string) { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1037 | deps := []string{} |
| 1038 | |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 1039 | // Bundle Recipes. |
| 1040 | if name == BUNDLE_RECIPES_NAME { |
| 1041 | deps = append(deps, bundleRecipes(b)) |
| 1042 | } |
| 1043 | |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1044 | // Isolate CIPD assets. |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1045 | if _, ok := ISOLATE_ASSET_MAPPING[name]; ok { |
| 1046 | deps = append(deps, isolateCIPDAsset(b, name)) |
| 1047 | } |
| 1048 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1049 | parts, err := jobNameSchema.ParseJobName(name) |
| 1050 | if err != nil { |
| 1051 | glog.Fatal(err) |
| 1052 | } |
| 1053 | |
| 1054 | // RecreateSKPs. |
| 1055 | if strings.Contains(name, "RecreateSKPs") { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1056 | deps = append(deps, recreateSKPs(b, name)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1057 | } |
| 1058 | |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 1059 | // UpdateMetaConfig bot. |
| 1060 | if strings.Contains(name, "UpdateMetaConfig") { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1061 | deps = append(deps, updateMetaConfig(b, name)) |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 1062 | } |
| 1063 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1064 | // CT bots. |
| 1065 | if strings.Contains(name, "-CT_") { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1066 | deps = append(deps, ctSKPs(b, name)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1067 | } |
| 1068 | |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 1069 | // Infra tests. |
| 1070 | if name == "Housekeeper-PerCommit-InfraTests" { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1071 | deps = append(deps, infra(b, name)) |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1074 | // Compile bots. |
| 1075 | if parts["role"] == "Build" { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1076 | deps = append(deps, compile(b, name, parts)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1077 | } |
| 1078 | |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 1079 | // Calmbench bots. |
| 1080 | if parts["role"] == "Calmbench" { |
Kevin Lubick | d2b8af1 | 2017-10-30 10:05:52 -0400 | [diff] [blame] | 1081 | deps = append(deps, calmbench(b, name, parts)) |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 1082 | } |
| 1083 | |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 1084 | // Most remaining bots need a compile task. |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1085 | compileTaskName := deriveCompileTaskName(name, parts) |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 1086 | compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName) |
| 1087 | if err != nil { |
| 1088 | glog.Fatal(err) |
| 1089 | } |
Eric Boren | 628e78b | 2016-11-17 11:33:27 -0500 | [diff] [blame] | 1090 | // These bots do not need a compile task. |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 1091 | if parts["role"] != "Build" && parts["role"] != "Calmbench" && |
Eric Boren | b8ab7f7 | 2017-04-10 11:00:09 -0400 | [diff] [blame] | 1092 | name != "Housekeeper-PerCommit-BundleRecipes" && |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 1093 | name != "Housekeeper-PerCommit-InfraTests" && |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 1094 | name != "Housekeeper-PerCommit-CheckGeneratedFiles" && |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 1095 | !strings.Contains(name, "RecreateSKPs") && |
Ravi Mistry | 01b48e7 | 2017-05-17 14:28:06 -0400 | [diff] [blame] | 1096 | !strings.Contains(name, "UpdateMetaConfig") && |
Ben Wagner | 50b8468 | 2017-06-12 13:03:29 -0400 | [diff] [blame] | 1097 | !strings.Contains(name, "-CT_") && |
| 1098 | !strings.Contains(name, "Housekeeper-PerCommit-Isolate") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1099 | compile(b, compileTaskName, compileTaskParts) |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 1100 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1101 | |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 1102 | // Housekeepers. |
Eric Boren | 22f5ef7 | 2016-12-02 11:01:33 -0500 | [diff] [blame] | 1103 | if name == "Housekeeper-PerCommit" { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1104 | deps = append(deps, housekeeper(b, name, compileTaskName)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1105 | } |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 1106 | if name == "Housekeeper-PerCommit-CheckGeneratedFiles" { |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1107 | deps = append(deps, checkGeneratedFiles(b, name)) |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 1108 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1109 | |
| 1110 | // Common assets needed by the remaining bots. |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1111 | |
| 1112 | pkgs := []*specs.CipdPackage{} |
| 1113 | |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 1114 | if deps := getIsolatedCIPDDeps(parts); len(deps) == 0 { |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1115 | pkgs = []*specs.CipdPackage{ |
| 1116 | b.MustGetCipdPackageFromAsset("skimage"), |
| 1117 | b.MustGetCipdPackageFromAsset("skp"), |
| 1118 | b.MustGetCipdPackageFromAsset("svg"), |
| 1119 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1120 | } |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 1121 | |
Ben Wagner | 5655ba4 | 2017-10-02 10:48:32 -0400 | [diff] [blame] | 1122 | if strings.Contains(name, "Ubuntu") || strings.Contains(name, "Debian") { |
| 1123 | if strings.Contains(name, "SAN") { |
| 1124 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 1125 | } |
Kevin Lubick | 35115eb | 2017-02-17 10:25:34 -0500 | [diff] [blame] | 1126 | if strings.Contains(name, "Vulkan") { |
| 1127 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk")) |
| 1128 | } |
Ben Wagner | 5655ba4 | 2017-10-02 10:48:32 -0400 | [diff] [blame] | 1129 | if strings.Contains(name, "Intel") && strings.Contains(name, "GPU") { |
| 1130 | if strings.Contains(name, "Release") { |
| 1131 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_release")) |
| 1132 | } else { |
| 1133 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_debug")) |
| 1134 | } |
Kevin Lubick | 0a51b48 | 2017-02-06 12:45:29 -0500 | [diff] [blame] | 1135 | } |
| 1136 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1137 | |
| 1138 | // Test bots. |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 1139 | |
| 1140 | if parts["role"] == "Test" { |
| 1141 | if strings.Contains(parts["extra_config"], "Coverage") { |
| 1142 | deps = append(deps, coverage(b, name, parts, compileTaskName, pkgs)) |
| 1143 | } else if !strings.Contains(name, "-CT_") { |
| 1144 | deps = append(deps, test(b, name, parts, compileTaskName, pkgs)) |
| 1145 | } |
| 1146 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | // Perf bots. |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 1150 | if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1151 | deps = append(deps, perf(b, name, parts, compileTaskName, pkgs)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1152 | } |
| 1153 | |
| 1154 | // Add the Job spec. |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 1155 | j := &specs.JobSpec{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1156 | Priority: 0.8, |
| 1157 | TaskSpecs: deps, |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 1158 | Trigger: specs.TRIGGER_ANY_BRANCH, |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 1159 | } |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 1160 | if strings.Contains(name, "-Nightly-") { |
| 1161 | j.Trigger = specs.TRIGGER_NIGHTLY |
Ravi Mistry | f06dae8 | 2017-10-16 10:31:41 -0400 | [diff] [blame] | 1162 | } else if strings.Contains(name, "-Weekly-") || strings.Contains(name, "CT_DM_1m_SKPs") { |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 1163 | j.Trigger = specs.TRIGGER_WEEKLY |
| 1164 | } else if strings.Contains(name, "Flutter") || strings.Contains(name, "PDFium") || strings.Contains(name, "CommandBuffer") { |
| 1165 | j.Trigger = specs.TRIGGER_MASTER_ONLY |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 1166 | } |
Eric Boren | 8615fe5 | 2016-12-12 14:30:12 -0500 | [diff] [blame] | 1167 | b.MustAddJob(name, j) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1168 | } |
| 1169 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 1170 | func loadJson(flag *string, defaultFlag string, val interface{}) { |
| 1171 | if *flag == "" { |
| 1172 | *flag = defaultFlag |
| 1173 | } |
| 1174 | b, err := ioutil.ReadFile(*flag) |
| 1175 | if err != nil { |
| 1176 | glog.Fatal(err) |
| 1177 | } |
| 1178 | if err := json.Unmarshal(b, val); err != nil { |
| 1179 | glog.Fatal(err) |
| 1180 | } |
| 1181 | } |
| 1182 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1183 | // Regenerate the tasks.json file. |
| 1184 | func main() { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1185 | b := specs.MustNewTasksCfgBuilder() |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 1186 | b.SetAssetsDir(*assetsDir) |
| 1187 | infraBots := path.Join(b.CheckoutRoot(), "infra", "bots") |
| 1188 | |
| 1189 | // Load the jobs from a JSON file. |
| 1190 | loadJson(jobsFile, path.Join(infraBots, "jobs.json"), &JOBS) |
| 1191 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 1192 | // Load general config information from a JSON file. |
| 1193 | loadJson(cfgFile, path.Join(infraBots, "cfg.json"), &CONFIG) |
| 1194 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1195 | // Create the JobNameSchema. |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 1196 | if *builderNameSchemaFile == "" { |
| 1197 | *builderNameSchemaFile = path.Join(b.CheckoutRoot(), "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json") |
| 1198 | } |
| 1199 | schema, err := NewJobNameSchema(*builderNameSchemaFile) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1200 | if err != nil { |
| 1201 | glog.Fatal(err) |
| 1202 | } |
| 1203 | jobNameSchema = schema |
| 1204 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1205 | // Create Tasks and Jobs. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1206 | for _, name := range JOBS { |
| 1207 | process(b, name) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1208 | } |
| 1209 | |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1210 | b.MustFinish() |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1211 | } |
| 1212 | |
| 1213 | // TODO(borenet): The below really belongs in its own file, probably next to the |
| 1214 | // builder_name_schema.json file. |
| 1215 | |
| 1216 | // JobNameSchema is a struct used for (de)constructing Job names in a |
| 1217 | // predictable format. |
| 1218 | type JobNameSchema struct { |
| 1219 | Schema map[string][]string `json:"builder_name_schema"` |
| 1220 | Sep string `json:"builder_name_sep"` |
| 1221 | } |
| 1222 | |
| 1223 | // NewJobNameSchema returns a JobNameSchema instance based on the given JSON |
| 1224 | // file. |
| 1225 | func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) { |
| 1226 | var rv JobNameSchema |
| 1227 | f, err := os.Open(jsonFile) |
| 1228 | if err != nil { |
| 1229 | return nil, err |
| 1230 | } |
| 1231 | defer util.Close(f) |
| 1232 | if err := json.NewDecoder(f).Decode(&rv); err != nil { |
| 1233 | return nil, err |
| 1234 | } |
| 1235 | return &rv, nil |
| 1236 | } |
| 1237 | |
| 1238 | // ParseJobName splits the given Job name into its component parts, according |
| 1239 | // to the schema. |
| 1240 | func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) { |
| 1241 | split := strings.Split(n, s.Sep) |
| 1242 | if len(split) < 2 { |
| 1243 | return nil, fmt.Errorf("Invalid job name: %q", n) |
| 1244 | } |
| 1245 | role := split[0] |
| 1246 | split = split[1:] |
| 1247 | keys, ok := s.Schema[role] |
| 1248 | if !ok { |
| 1249 | return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role) |
| 1250 | } |
| 1251 | extraConfig := "" |
| 1252 | if len(split) == len(keys)+1 { |
| 1253 | extraConfig = split[len(split)-1] |
| 1254 | split = split[:len(split)-1] |
| 1255 | } |
| 1256 | if len(split) != len(keys) { |
| 1257 | return nil, fmt.Errorf("Invalid job name; %q has incorrect number of parts.", n) |
| 1258 | } |
| 1259 | rv := make(map[string]string, len(keys)+2) |
| 1260 | rv["role"] = role |
| 1261 | if extraConfig != "" { |
| 1262 | rv["extra_config"] = extraConfig |
| 1263 | } |
| 1264 | for i, k := range keys { |
| 1265 | rv[k] = split[i] |
| 1266 | } |
| 1267 | return rv, nil |
| 1268 | } |
| 1269 | |
| 1270 | // MakeJobName assembles the given parts of a Job name, according to the schema. |
| 1271 | func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) { |
| 1272 | role, ok := parts["role"] |
| 1273 | if !ok { |
| 1274 | return "", fmt.Errorf("Invalid job parts; jobs must have a role.") |
| 1275 | } |
| 1276 | keys, ok := s.Schema[role] |
| 1277 | if !ok { |
| 1278 | return "", fmt.Errorf("Invalid job parts; unknown role %q", role) |
| 1279 | } |
| 1280 | rvParts := make([]string, 0, len(parts)) |
| 1281 | rvParts = append(rvParts, role) |
| 1282 | for _, k := range keys { |
| 1283 | v, ok := parts[k] |
| 1284 | if !ok { |
| 1285 | return "", fmt.Errorf("Invalid job parts; missing %q", k) |
| 1286 | } |
| 1287 | rvParts = append(rvParts, v) |
| 1288 | } |
| 1289 | if _, ok := parts["extra_config"]; ok { |
| 1290 | rvParts = append(rvParts, parts["extra_config"]) |
| 1291 | } |
| 1292 | return strings.Join(rvParts, s.Sep), nil |
| 1293 | } |