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 | |
Eric Boren | cb0b98b | 2018-06-08 08:25:57 -0400 | [diff] [blame] | 26 | "github.com/golang/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 ( |
Ben Wagner | 1cefc09 | 2019-01-04 11:36:53 -0500 | [diff] [blame] | 33 | BUNDLE_RECIPES_NAME = "Housekeeper-PerCommit-BundleRecipes" |
| 34 | ISOLATE_GCLOUD_LINUX_NAME = "Housekeeper-PerCommit-IsolateGCloudLinux" |
| 35 | ISOLATE_GO_DEPS_NAME = "Housekeeper-PerCommit-IsolateGoDeps" |
| 36 | ISOLATE_SKIMAGE_NAME = "Housekeeper-PerCommit-IsolateSkImage" |
| 37 | ISOLATE_SKP_NAME = "Housekeeper-PerCommit-IsolateSKP" |
| 38 | ISOLATE_SVG_NAME = "Housekeeper-PerCommit-IsolateSVG" |
| 39 | ISOLATE_NDK_LINUX_NAME = "Housekeeper-PerCommit-IsolateAndroidNDKLinux" |
| 40 | ISOLATE_SDK_LINUX_NAME = "Housekeeper-PerCommit-IsolateAndroidSDKLinux" |
| 41 | ISOLATE_WIN_TOOLCHAIN_NAME = "Housekeeper-PerCommit-IsolateWinToolchain" |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 42 | |
Ben Wagner | 1676ec2 | 2018-04-06 17:39:06 -0400 | [diff] [blame] | 43 | DEFAULT_OS_DEBIAN = "Debian-9.4" |
| 44 | DEFAULT_OS_LINUX_GCE = DEFAULT_OS_DEBIAN |
Ben Wagner | e8d2a45 | 2018-08-06 10:00:54 -0400 | [diff] [blame] | 45 | DEFAULT_OS_MAC = "Mac-10.13.6" |
Eric Boren | 170c39c | 2017-11-15 11:22:57 -0500 | [diff] [blame] | 46 | DEFAULT_OS_UBUNTU = "Ubuntu-14.04" |
| 47 | DEFAULT_OS_WIN = "Windows-2016Server-14393" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 48 | |
Eric Boren | eb70238 | 2018-04-19 09:36:45 -0400 | [diff] [blame] | 49 | DEFAULT_PROJECT = "skia" |
| 50 | |
Ben Wagner | 297e86b | 2018-05-14 12:38:09 -0400 | [diff] [blame] | 51 | // Small is a 2-core machine. |
| 52 | // TODO(dogben): Would n1-standard-1 or n1-standard-2 be sufficient? |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 53 | MACHINE_TYPE_SMALL = "n1-highmem-2" |
Ben Wagner | 297e86b | 2018-05-14 12:38:09 -0400 | [diff] [blame] | 54 | // Medium is a 16-core machine |
| 55 | MACHINE_TYPE_MEDIUM = "n1-standard-16" |
| 56 | // Large is a 64-core machine. (We use "highcpu" because we don't need more than 57GB memory for |
| 57 | // any of our tasks.) |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 58 | MACHINE_TYPE_LARGE = "n1-highcpu-64" |
| 59 | |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 60 | // Swarming output dirs. |
Kevin Lubick | 2f9c1cc | 2018-09-24 11:22:55 -0400 | [diff] [blame] | 61 | OUTPUT_NONE = "output_ignored" // This will result in outputs not being isolated. |
| 62 | OUTPUT_BUILD = "build" |
| 63 | OUTPUT_TEST = "test" |
| 64 | OUTPUT_PERF = "perf" |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 65 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 66 | // Name prefix for upload jobs. |
| 67 | PREFIX_UPLOAD = "Upload" |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 68 | |
| 69 | SERVICE_ACCOUNT_BOOKMAKER = "skia-bookmaker@skia-swarming-bots.iam.gserviceaccount.com" |
| 70 | SERVICE_ACCOUNT_COMPILE = "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com" |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 71 | SERVICE_ACCOUNT_HOUSEKEEPER = "skia-external-housekeeper@skia-swarming-bots.iam.gserviceaccount.com" |
| 72 | SERVICE_ACCOUNT_RECREATE_SKPS = "skia-recreate-skps@skia-swarming-bots.iam.gserviceaccount.com" |
Eric Boren | 84ae641 | 2018-09-27 14:55:03 -0400 | [diff] [blame] | 73 | SERVICE_ACCOUNT_UPDATE_GO_DEPS = "skia-recreate-skps@skia-swarming-bots.iam.gserviceaccount.com" |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 74 | SERVICE_ACCOUNT_UPDATE_META_CONFIG = "skia-update-meta-config@skia-swarming-bots.iam.gserviceaccount.com" |
| 75 | SERVICE_ACCOUNT_UPLOAD_BINARY = "skia-external-binary-uploader@skia-swarming-bots.iam.gserviceaccount.com" |
| 76 | SERVICE_ACCOUNT_UPLOAD_CALMBENCH = "skia-external-calmbench-upload@skia-swarming-bots.iam.gserviceaccount.com" |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 77 | SERVICE_ACCOUNT_UPLOAD_GM = "skia-external-gm-uploader@skia-swarming-bots.iam.gserviceaccount.com" |
| 78 | SERVICE_ACCOUNT_UPLOAD_NANO = "skia-external-nano-uploader@skia-swarming-bots.iam.gserviceaccount.com" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 79 | ) |
| 80 | |
| 81 | var ( |
| 82 | // "Constants" |
| 83 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 84 | // Top-level list of all jobs to run at each commit; loaded from |
| 85 | // jobs.json. |
| 86 | JOBS []string |
| 87 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 88 | // General configuration information. |
| 89 | CONFIG struct { |
Kevin Lubick | 2f9c1cc | 2018-09-24 11:22:55 -0400 | [diff] [blame] | 90 | GsBucketGm string `json:"gs_bucket_gm"` |
| 91 | GoldHashesURL string `json:"gold_hashes_url"` |
| 92 | GsBucketNano string `json:"gs_bucket_nano"` |
| 93 | GsBucketCalm string `json:"gs_bucket_calm"` |
| 94 | NoUpload []string `json:"no_upload"` |
| 95 | Pool string `json:"pool"` |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Eric Boren | eb70238 | 2018-04-19 09:36:45 -0400 | [diff] [blame] | 98 | // alternateProject can be set in an init function to override the default project ID. |
| 99 | alternateProject string |
| 100 | |
Ben Wagner | 053d046 | 2018-04-17 12:45:29 -0400 | [diff] [blame] | 101 | // alternateServiceAccount can be set in an init function to override the normal service accounts. |
| 102 | // Takes one of SERVICE_ACCOUNT_* constants as an argument and returns the service account that |
| 103 | // should be used, or uses sklog.Fatal to indicate a problem. |
| 104 | alternateServiceAccount func(serviceAccountEnum string) string |
| 105 | |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 106 | // alternateSwarmDimensions can be set in an init function to override the default swarming bot |
| 107 | // dimensions for the given task. |
| 108 | alternateSwarmDimensions func(parts map[string]string) []string |
| 109 | |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 110 | // internalHardwareLabelFn can be set in an init function to provide an |
| 111 | // internal_hardware_label variable to the recipe. |
Eric Boren | 4dc4aaf | 2017-09-15 14:09:07 -0400 | [diff] [blame] | 112 | internalHardwareLabelFn func(parts map[string]string) *int |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 113 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 114 | // Defines the structure of job names. |
| 115 | jobNameSchema *JobNameSchema |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 116 | |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 117 | // Named caches used by tasks. |
| 118 | CACHES_GIT = []*specs.Cache{ |
| 119 | &specs.Cache{ |
| 120 | Name: "git", |
| 121 | Path: "cache/git", |
| 122 | }, |
| 123 | &specs.Cache{ |
| 124 | Name: "git_cache", |
| 125 | Path: "cache/git_cache", |
| 126 | }, |
| 127 | } |
Ben Wagner | bb7d381 | 2018-12-18 23:42:11 -0500 | [diff] [blame] | 128 | CACHES_GO = []*specs.Cache{ |
| 129 | &specs.Cache{ |
| 130 | Name: "go_cache", |
| 131 | Path: "cache/go_cache", |
| 132 | }, |
| 133 | } |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 134 | CACHES_WORKDIR = []*specs.Cache{ |
| 135 | &specs.Cache{ |
| 136 | Name: "work", |
| 137 | Path: "cache/work", |
| 138 | }, |
| 139 | } |
Kevin Lubick | 30cc00c | 2018-08-03 10:26:00 -0400 | [diff] [blame] | 140 | CACHES_DOCKER = []*specs.Cache{ |
| 141 | &specs.Cache{ |
| 142 | Name: "docker", |
| 143 | Path: "cache/docker", |
| 144 | }, |
| 145 | } |
Ben Wagner | 702fe01 | 2018-06-15 09:19:13 -0400 | [diff] [blame] | 146 | // Versions of the following copied from |
| 147 | // https://chrome-internal.googlesource.com/infradata/config/+/master/configs/cr-buildbucket/swarming_task_template_canary.json#42 |
| 148 | // to test the fix for chromium:836196. |
| 149 | // (In the future we may want to use versions from |
| 150 | // https://chrome-internal.googlesource.com/infradata/config/+/master/configs/cr-buildbucket/swarming_task_template.json#42) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 151 | // TODO(borenet): Roll these versions automatically! |
| 152 | CIPD_PKGS_PYTHON = []*specs.CipdPackage{ |
| 153 | &specs.CipdPackage{ |
| 154 | Name: "infra/tools/luci/vpython/${platform}", |
| 155 | Path: "cipd_bin_packages", |
Eric Boren | 69d199c | 2019-01-15 14:52:54 -0500 | [diff] [blame] | 156 | Version: "git_revision:96f81e737868d43124b4661cf1c325296ca04944", |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 157 | }, |
Eric Boren | f4a5fc7 | 2017-06-06 08:27:09 -0400 | [diff] [blame] | 158 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 159 | |
Eric Boren | aa03752 | 2018-06-18 16:02:15 -0400 | [diff] [blame] | 160 | CIPD_PKGS_CPYTHON = []*specs.CipdPackage{ |
| 161 | &specs.CipdPackage{ |
| 162 | Name: "infra/python/cpython/${platform}", |
| 163 | Path: "cipd_bin_packages", |
| 164 | Version: "version:2.7.14.chromium14", |
| 165 | }, |
| 166 | } |
| 167 | |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 168 | CIPD_PKGS_KITCHEN = append([]*specs.CipdPackage{ |
| 169 | &specs.CipdPackage{ |
| 170 | Name: "infra/tools/luci/kitchen/${platform}", |
| 171 | Path: ".", |
Eric Boren | 69d199c | 2019-01-15 14:52:54 -0500 | [diff] [blame] | 172 | Version: "git_revision:d8f38ca9494b5af249942631f9cee45927f6b4bc", |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 173 | }, |
| 174 | &specs.CipdPackage{ |
Ben Wagner | cd7ace2 | 2018-06-11 15:48:35 -0400 | [diff] [blame] | 175 | Name: "infra/tools/luci-auth/${platform}", |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 176 | Path: "cipd_bin_packages", |
Eric Boren | ccb0a30 | 2019-01-10 08:34:11 -0500 | [diff] [blame] | 177 | Version: "git_revision:2c805f1c716f6c5ad2126b27ec88b8585a09481e", |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 178 | }, |
| 179 | }, CIPD_PKGS_PYTHON...) |
| 180 | |
| 181 | CIPD_PKGS_GIT = []*specs.CipdPackage{ |
| 182 | &specs.CipdPackage{ |
| 183 | Name: "infra/git/${platform}", |
| 184 | Path: "cipd_bin_packages", |
Eric Boren | e42cef5 | 2018-06-20 07:11:38 -0400 | [diff] [blame] | 185 | Version: "version:2.17.1.chromium15", |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 186 | }, |
| 187 | &specs.CipdPackage{ |
| 188 | Name: "infra/tools/git/${platform}", |
| 189 | Path: "cipd_bin_packages", |
Eric Boren | ccb0a30 | 2019-01-10 08:34:11 -0500 | [diff] [blame] | 190 | Version: "git_revision:c9c8a52bfeaf8bc00ece22fdfd447822c8fcad77", |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 191 | }, |
| 192 | &specs.CipdPackage{ |
| 193 | Name: "infra/tools/luci/git-credential-luci/${platform}", |
| 194 | Path: "cipd_bin_packages", |
Eric Boren | ccb0a30 | 2019-01-10 08:34:11 -0500 | [diff] [blame] | 195 | Version: "git_revision:2c805f1c716f6c5ad2126b27ec88b8585a09481e", |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 196 | }, |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 197 | } |
Eric Boren | f4a5fc7 | 2017-06-06 08:27:09 -0400 | [diff] [blame] | 198 | |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 199 | CIPD_PKGS_GSUTIL = []*specs.CipdPackage{ |
| 200 | &specs.CipdPackage{ |
| 201 | Name: "infra/gsutil", |
| 202 | Path: "cipd_bin_packages", |
| 203 | Version: "version:4.28", |
| 204 | }, |
| 205 | } |
| 206 | |
Ben Wagner | cdfa16d | 2018-08-03 10:07:47 -0400 | [diff] [blame] | 207 | CIPD_PKGS_XCODE = []*specs.CipdPackage{ |
| 208 | // https://chromium.googlesource.com/chromium/tools/build/+/e19b7d9390e2bb438b566515b141ed2b9ed2c7c2/scripts/slave/recipe_modules/ios/api.py#317 |
| 209 | // This package is really just an installer for XCode. |
| 210 | &specs.CipdPackage{ |
Ben Wagner | 6676079 | 2018-08-09 12:52:16 -0400 | [diff] [blame] | 211 | Name: "infra/tools/mac_toolchain/${platform}", |
| 212 | Path: "mac_toolchain", |
| 213 | // When this is updated, also update |
| 214 | // https://skia.googlesource.com/skcms.git/+/f1e2b45d18facbae2dece3aca673fe1603077846/infra/bots/gen_tasks.go#56 |
Ben Wagner | cdfa16d | 2018-08-03 10:07:47 -0400 | [diff] [blame] | 215 | Version: "git_revision:796d2b92cff93fc2059623ce0a66284373ceea0a", |
| 216 | }, |
| 217 | } |
| 218 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 219 | // Flags. |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 220 | 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.") |
| 221 | assetsDir = flag.String("assets_dir", "", "Directory containing assets.") |
| 222 | cfgFile = flag.String("cfg_file", "", "JSON file containing general configuration information.") |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 223 | jobsFile = flag.String("jobs", "", "JSON file containing jobs to run.") |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 224 | ) |
| 225 | |
Eric Boren | eb70238 | 2018-04-19 09:36:45 -0400 | [diff] [blame] | 226 | // Build the LogDog annotation URL. |
| 227 | func logdogAnnotationUrl() string { |
| 228 | project := DEFAULT_PROJECT |
| 229 | if alternateProject != "" { |
| 230 | project = alternateProject |
| 231 | } |
| 232 | return fmt.Sprintf("logdog://logs.chromium.org/%s/%s/+/annotations", project, specs.PLACEHOLDER_TASK_ID) |
| 233 | } |
| 234 | |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 235 | // Create a properties JSON string. |
| 236 | func props(p map[string]string) string { |
| 237 | d := make(map[string]interface{}, len(p)+1) |
| 238 | for k, v := range p { |
| 239 | d[k] = interface{}(v) |
| 240 | } |
| 241 | d["$kitchen"] = struct { |
| 242 | DevShell bool `json:"devshell"` |
| 243 | GitAuth bool `json:"git_auth"` |
| 244 | }{ |
| 245 | DevShell: true, |
| 246 | GitAuth: true, |
| 247 | } |
| 248 | |
| 249 | j, err := json.Marshal(d) |
| 250 | if err != nil { |
| 251 | sklog.Fatal(err) |
| 252 | } |
| 253 | return strings.Replace(string(j), "\\u003c", "<", -1) |
| 254 | } |
| 255 | |
| 256 | // kitchenTask returns a specs.TaskSpec instance which uses Kitchen to run a |
| 257 | // recipe. |
| 258 | func kitchenTask(name, recipe, isolate, serviceAccount string, dimensions []string, extraProps map[string]string, outputDir string) *specs.TaskSpec { |
| 259 | if serviceAccount != "" && alternateServiceAccount != nil { |
| 260 | serviceAccount = alternateServiceAccount(serviceAccount) |
| 261 | } |
| 262 | cipd := append([]*specs.CipdPackage{}, CIPD_PKGS_KITCHEN...) |
Eric Boren | aa03752 | 2018-06-18 16:02:15 -0400 | [diff] [blame] | 263 | if strings.Contains(name, "Win") { |
| 264 | cipd = append(cipd, CIPD_PKGS_CPYTHON...) |
| 265 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 266 | properties := map[string]string{ |
| 267 | "buildbucket_build_id": specs.PLACEHOLDER_BUILDBUCKET_BUILD_ID, |
| 268 | "buildername": name, |
| 269 | "patch_issue": specs.PLACEHOLDER_ISSUE, |
Eric Boren | 2f62de0 | 2018-05-03 09:56:48 -0400 | [diff] [blame] | 270 | "patch_ref": specs.PLACEHOLDER_PATCH_REF, |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 271 | "patch_repo": specs.PLACEHOLDER_PATCH_REPO, |
| 272 | "patch_set": specs.PLACEHOLDER_PATCHSET, |
| 273 | "patch_storage": specs.PLACEHOLDER_PATCH_STORAGE, |
| 274 | "repository": specs.PLACEHOLDER_REPO, |
| 275 | "revision": specs.PLACEHOLDER_REVISION, |
| 276 | "swarm_out_dir": outputDir, |
| 277 | } |
| 278 | for k, v := range extraProps { |
| 279 | properties[k] = v |
| 280 | } |
| 281 | var outputs []string = nil |
| 282 | if outputDir != OUTPUT_NONE { |
| 283 | outputs = []string{outputDir} |
| 284 | } |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 285 | task := &specs.TaskSpec{ |
| 286 | Caches: []*specs.Cache{ |
| 287 | &specs.Cache{ |
| 288 | Name: "vpython", |
| 289 | Path: "cache/vpython", |
| 290 | }, |
| 291 | }, |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 292 | CipdPackages: cipd, |
| 293 | Command: []string{ |
| 294 | "./kitchen${EXECUTABLE_SUFFIX}", "cook", |
| 295 | "-checkout-dir", "recipe_bundle", |
| 296 | "-mode", "swarming", |
| 297 | "-luci-system-account", "system", |
| 298 | "-cache-dir", "cache", |
| 299 | "-temp-dir", "tmp", |
| 300 | "-known-gerrit-host", "android.googlesource.com", |
| 301 | "-known-gerrit-host", "boringssl.googlesource.com", |
| 302 | "-known-gerrit-host", "chromium.googlesource.com", |
| 303 | "-known-gerrit-host", "dart.googlesource.com", |
| 304 | "-known-gerrit-host", "fuchsia.googlesource.com", |
| 305 | "-known-gerrit-host", "go.googlesource.com", |
| 306 | "-known-gerrit-host", "llvm.googlesource.com", |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 307 | "-known-gerrit-host", "skia.googlesource.com", |
| 308 | "-known-gerrit-host", "webrtc.googlesource.com", |
| 309 | "-output-result-json", "${ISOLATED_OUTDIR}/build_result_filename", |
| 310 | "-workdir", ".", |
| 311 | "-recipe", recipe, |
| 312 | "-properties", props(properties), |
Eric Boren | eb70238 | 2018-04-19 09:36:45 -0400 | [diff] [blame] | 313 | "-logdog-annotation-url", logdogAnnotationUrl(), |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 314 | }, |
| 315 | Dependencies: []string{BUNDLE_RECIPES_NAME}, |
| 316 | Dimensions: dimensions, |
| 317 | EnvPrefixes: map[string][]string{ |
Kevin Lubick | 37baac1 | 2018-10-09 16:25:27 -0400 | [diff] [blame] | 318 | "PATH": []string{"cipd_bin_packages", "cipd_bin_packages/bin"}, |
Eric Boren | 7c42e01 | 2018-08-20 09:45:02 -0400 | [diff] [blame] | 319 | "VPYTHON_VIRTUALENV_ROOT": []string{"cache/vpython"}, |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 320 | }, |
| 321 | ExtraTags: map[string]string{ |
Eric Boren | eb70238 | 2018-04-19 09:36:45 -0400 | [diff] [blame] | 322 | "log_location": logdogAnnotationUrl(), |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 323 | }, |
| 324 | Isolate: relpath(isolate), |
Ben Wagner | 73e2ced | 2018-12-17 12:44:30 -0500 | [diff] [blame] | 325 | MaxAttempts: attempts(name), |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 326 | Outputs: outputs, |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 327 | ServiceAccount: serviceAccount, |
| 328 | } |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 329 | timeout(task, time.Hour) |
| 330 | return task |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 331 | } |
| 332 | |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 333 | // internalHardwareLabel returns the internal ID for the bot, if any. |
Eric Boren | 4dc4aaf | 2017-09-15 14:09:07 -0400 | [diff] [blame] | 334 | func internalHardwareLabel(parts map[string]string) *int { |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 335 | if internalHardwareLabelFn != nil { |
| 336 | return internalHardwareLabelFn(parts) |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 337 | } |
| 338 | return nil |
| 339 | } |
| 340 | |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 341 | // linuxGceDimensions are the Swarming dimensions for Linux GCE instances. |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 342 | func linuxGceDimensions(machineType string) []string { |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 343 | return []string{ |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 344 | // Specify CPU to avoid running builds on bots with a more unique CPU. |
| 345 | "cpu:x86-64-Haswell_GCE", |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 346 | "gpu:none", |
Ben Wagner | 82a3342 | 2018-04-26 18:02:23 -0400 | [diff] [blame] | 347 | // Currently all Linux GCE tasks run on 16-CPU machines. |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 348 | fmt.Sprintf("machine_type:%s", machineType), |
Eric Boren | 170c39c | 2017-11-15 11:22:57 -0500 | [diff] [blame] | 349 | fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE), |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 350 | fmt.Sprintf("pool:%s", CONFIG.Pool), |
| 351 | } |
| 352 | } |
| 353 | |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 354 | func wasmGceDimensions() []string { |
| 355 | // There's limited parallelism for WASM builds, so we can get away with the medium |
| 356 | // instance instead of the beefy large instance. |
| 357 | // Docker being intsalled is the most important part. |
| 358 | return append(linuxGceDimensions(MACHINE_TYPE_MEDIUM), "docker_installed:true") |
| 359 | } |
| 360 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 361 | // deriveCompileTaskName returns the name of a compile task based on the given |
| 362 | // job name. |
| 363 | func deriveCompileTaskName(jobName string, parts map[string]string) string { |
Ravi Mistry | d4731e9 | 2018-01-02 14:54:43 -0500 | [diff] [blame] | 364 | if strings.Contains(jobName, "Bookmaker") { |
Ravi Mistry | edc4f3e | 2017-12-08 12:58:20 -0500 | [diff] [blame] | 365 | return "Build-Debian9-GCC-x86_64-Release" |
Yuqian Li | 4a577af | 2018-01-05 11:13:43 -0500 | [diff] [blame] | 366 | } else if parts["role"] == "Test" || parts["role"] == "Perf" || parts["role"] == "Calmbench" { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 367 | task_os := parts["os"] |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 368 | ec := []string{} |
| 369 | if val := parts["extra_config"]; val != "" { |
| 370 | ec = strings.Split(val, "_") |
Mike Klein | c24e0c1 | 2018-08-17 13:24:51 -0400 | [diff] [blame] | 371 | ignore := []string{"Skpbench", "AbandonGpuContext", "PreAbandonGpuContext", "Valgrind", "ReleaseAndAbandonGpuContext", "CCPR", "FSAA", "FAAA", "FDAA", "NativeFonts", "GDI", "NoGPUThreads", "ProcDump", "DDL1", "DDL3", "T8888", "DDLTotal", "DDLRecord", "9x9", "BonusConfigs"} |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 372 | keep := make([]string, 0, len(ec)) |
| 373 | for _, part := range ec { |
| 374 | if !util.In(part, ignore) { |
| 375 | keep = append(keep, part) |
| 376 | } |
| 377 | } |
| 378 | ec = keep |
Eric Boren | 6ec17e3 | 2017-04-26 14:25:29 -0400 | [diff] [blame] | 379 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 380 | if task_os == "Android" { |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 381 | if !util.In("Android", ec) { |
| 382 | ec = append([]string{"Android"}, ec...) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 383 | } |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 384 | task_os = "Debian9" |
Kevin Lubick | dcd2a90 | 2017-03-08 14:01:01 -0500 | [diff] [blame] | 385 | } else if task_os == "Chromecast" { |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 386 | task_os = "Debian9" |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 387 | ec = append([]string{"Chromecast"}, ec...) |
Kevin Lubick | cb6f398 | 2017-04-07 10:04:08 -0400 | [diff] [blame] | 388 | } else if strings.Contains(task_os, "ChromeOS") { |
Kevin Lubick | b718fbb | 2017-11-02 09:34:08 -0400 | [diff] [blame] | 389 | ec = append([]string{"Chromebook", "GLES"}, ec...) |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 390 | task_os = "Debian9" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 391 | } else if task_os == "iOS" { |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 392 | ec = append([]string{task_os}, ec...) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 393 | task_os = "Mac" |
| 394 | } else if strings.Contains(task_os, "Win") { |
| 395 | task_os = "Win" |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 396 | } else if strings.Contains(task_os, "Ubuntu") || strings.Contains(task_os, "Debian") { |
| 397 | task_os = "Debian9" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 398 | } |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 399 | jobNameMap := map[string]string{ |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 400 | "role": "Build", |
| 401 | "os": task_os, |
| 402 | "compiler": parts["compiler"], |
| 403 | "target_arch": parts["arch"], |
| 404 | "configuration": parts["configuration"], |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 405 | } |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 406 | if strings.Contains(jobName, "PathKit") { |
| 407 | ec = []string{"PathKit"} |
| 408 | } |
Kevin Lubick | 8e9750d | 2018-10-09 09:36:35 -0400 | [diff] [blame] | 409 | if strings.Contains(jobName, "CanvasKit") { |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 410 | if parts["cpu_or_gpu"] == "CPU" { |
| 411 | ec = []string{"CanvasKit_CPU"} |
| 412 | } else { |
| 413 | ec = []string{"CanvasKit"} |
| 414 | } |
| 415 | |
Kevin Lubick | 8e9750d | 2018-10-09 09:36:35 -0400 | [diff] [blame] | 416 | } |
Ben Wagner | 988d15e | 2017-04-27 13:08:50 -0400 | [diff] [blame] | 417 | if len(ec) > 0 { |
| 418 | jobNameMap["extra_config"] = strings.Join(ec, "_") |
Eric Boren | 5083130 | 2016-11-18 13:10:51 -0500 | [diff] [blame] | 419 | } |
| 420 | name, err := jobNameSchema.MakeJobName(jobNameMap) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 421 | if err != nil { |
| 422 | glog.Fatal(err) |
| 423 | } |
| 424 | return name |
Kevin Lubick | 4968843 | 2018-10-08 13:58:47 -0400 | [diff] [blame] | 425 | } else if parts["role"] == "BuildStats" { |
| 426 | return strings.Replace(jobName, "BuildStats", "Build", 1) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 427 | } else { |
| 428 | return jobName |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | // swarmDimensions generates swarming bot dimensions for the given task. |
| 433 | func swarmDimensions(parts map[string]string) []string { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 434 | if alternateSwarmDimensions != nil { |
| 435 | return alternateSwarmDimensions(parts) |
| 436 | } |
| 437 | return defaultSwarmDimensions(parts) |
| 438 | } |
| 439 | |
| 440 | // defaultSwarmDimensions generates default swarming bot dimensions for the given task. |
| 441 | func defaultSwarmDimensions(parts map[string]string) []string { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 442 | d := map[string]string{ |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 443 | "pool": CONFIG.Pool, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 444 | } |
| 445 | if os, ok := parts["os"]; ok { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 446 | d["os"], ok = map[string]string{ |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 447 | "Android": "Android", |
| 448 | "Chromecast": "Android", |
Kevin Lubick | cb6f398 | 2017-04-07 10:04:08 -0400 | [diff] [blame] | 449 | "ChromeOS": "ChromeOS", |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 450 | "Debian9": DEFAULT_OS_DEBIAN, |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 451 | "Mac": DEFAULT_OS_MAC, |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 452 | "Ubuntu14": DEFAULT_OS_UBUNTU, |
Eric Boren | 810c2b6 | 2017-07-11 08:11:15 -0400 | [diff] [blame] | 453 | "Ubuntu17": "Ubuntu-17.04", |
Ben Wagner | 2aa9a22 | 2018-11-06 13:45:40 -0500 | [diff] [blame] | 454 | "Ubuntu18": "Ubuntu-18.04", |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 455 | "Win": DEFAULT_OS_WIN, |
Ben Wagner | b62fc90 | 2019-01-03 15:50:55 -0500 | [diff] [blame] | 456 | "Win10": "Windows-10-17763.195", |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 457 | "Win2k8": "Windows-2008ServerR2-SP1", |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 458 | "Win2016": DEFAULT_OS_WIN, |
Ben Wagner | 56738d8 | 2017-04-18 15:38:15 -0400 | [diff] [blame] | 459 | "Win7": "Windows-7-SP1", |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 460 | "Win8": "Windows-8.1-SP0", |
Stephan Altmueller | 0edb982 | 2018-08-16 18:11:57 -0400 | [diff] [blame] | 461 | "iOS": "iOS-11.4.1", |
Eric Boren | 54ff2fc | 2016-12-02 12:09:10 -0500 | [diff] [blame] | 462 | }[os] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 463 | if !ok { |
| 464 | glog.Fatalf("Entry %q not found in OS mapping.", os) |
| 465 | } |
Ben Wagner | bc98920 | 2018-02-28 14:22:27 -0500 | [diff] [blame] | 466 | if os == "Win10" && parts["model"] == "Golo" { |
Ben Wagner | f6148b6 | 2018-03-15 13:53:25 -0400 | [diff] [blame] | 467 | // ChOps-owned machines have Windows 10 v1709, but a slightly different version than Skolo. |
| 468 | d["os"] = "Windows-10-16299.309" |
Ben Wagner | b3c90fc | 2018-02-23 11:17:03 -0500 | [diff] [blame] | 469 | } |
Ben Wagner | e1c37a7 | 2018-04-24 16:59:48 -0400 | [diff] [blame] | 470 | if d["os"] == DEFAULT_OS_WIN { |
| 471 | // TODO(dogben): Temporarily add image dimension during upgrade. |
Ben Wagner | 5c7a3ac | 2019-01-17 15:57:45 -0500 | [diff] [blame] | 472 | d["image"] = "windows-server-2016-dc-v20190108" |
Ben Wagner | e1c37a7 | 2018-04-24 16:59:48 -0400 | [diff] [blame] | 473 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 474 | } else { |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 475 | d["os"] = DEFAULT_OS_DEBIAN |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 476 | } |
Yuqian Li | ab246cb | 2017-11-02 13:48:23 -0400 | [diff] [blame] | 477 | if parts["role"] == "Test" || parts["role"] == "Perf" || parts["role"] == "Calmbench" { |
Kevin Lubick | 291547d | 2017-03-21 09:25:34 -0400 | [diff] [blame] | 478 | if strings.Contains(parts["os"], "Android") || strings.Contains(parts["os"], "Chromecast") { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 479 | // For Android, the device type is a better dimension |
| 480 | // than CPU or GPU. |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 481 | deviceInfo, ok := map[string][]string{ |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 482 | "AndroidOne": {"sprout", "MOB30Q"}, |
Kevin Lubick | c2f3e8d | 2018-01-24 15:48:26 -0500 | [diff] [blame] | 483 | "Chorizo": {"chorizo", "1.30_109591"}, |
Ben Wagner | 0762bdf | 2017-11-28 09:41:48 -0500 | [diff] [blame] | 484 | "GalaxyS6": {"zerofltetmo", "NRD90M_G920TUVU5FQK1"}, |
Ben Wagner | 17d1896 | 2018-09-13 15:05:15 -0400 | [diff] [blame] | 485 | "GalaxyS7_G930FD": {"herolte", "R16NW_G930FXXS2ERH6"}, // This is Oreo. |
Ben Wagner | 9e97231 | 2018-11-29 10:00:36 -0500 | [diff] [blame] | 486 | "GalaxyS9": {"starlte", "R16NW_G960FXXU2BRJ8"}, // This is Oreo. |
Ben Wagner | 8d8f45d | 2018-06-04 17:32:04 -0400 | [diff] [blame] | 487 | "MotoG4": {"athene", "NPJS25.93-14.7-8"}, |
Ben Wagner | 7efa13d | 2018-08-28 15:52:38 -0400 | [diff] [blame] | 488 | "NVIDIA_Shield": {"foster", "OPR6.170623.010"}, |
Ben Wagner | ee3123c | 2017-12-06 16:29:04 -0500 | [diff] [blame] | 489 | "Nexus5": {"hammerhead", "M4B30Z_3437181"}, |
Ben Wagner | eb549c8 | 2017-11-17 08:59:44 -0500 | [diff] [blame] | 490 | "Nexus5x": {"bullhead", "OPR6.170623.023"}, |
Ben Wagner | ee3123c | 2017-12-06 16:29:04 -0500 | [diff] [blame] | 491 | "Nexus7": {"grouper", "LMY47V_1836172"}, // 2012 Nexus 7 |
Ben Wagner | 2a510c9 | 2018-04-11 12:36:56 -0400 | [diff] [blame] | 492 | "NexusPlayer": {"fugu", "OPR2.170623.027"}, |
Kevin Lubick | 8fe1b04 | 2018-08-21 13:00:14 -0400 | [diff] [blame] | 493 | "Pixel": {"sailfish", "PPR1.180610.009"}, |
Kevin Lubick | 1118cfd | 2018-08-24 10:24:54 -0400 | [diff] [blame] | 494 | "Pixel2XL": {"taimen", "PPR1.180610.009"}, |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 495 | }[parts["model"]] |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 496 | if !ok { |
Ben Wagner | 3668278 | 2017-06-14 10:01:45 -0400 | [diff] [blame] | 497 | glog.Fatalf("Entry %q not found in Android mapping.", parts["model"]) |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 498 | } |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 499 | d["device_type"] = deviceInfo[0] |
| 500 | d["device_os"] = deviceInfo[1] |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 501 | } else if strings.Contains(parts["os"], "iOS") { |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 502 | device, ok := map[string]string{ |
Eric Boren | 792079c | 2016-11-09 14:03:20 -0500 | [diff] [blame] | 503 | "iPadMini4": "iPad5,1", |
Stephan Altmueller | 63e843d | 2017-04-25 11:38:38 -0400 | [diff] [blame] | 504 | "iPhone6": "iPhone7,2", |
| 505 | "iPhone7": "iPhone9,1", |
| 506 | "iPadPro": "iPad6,3", |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 507 | }[parts["model"]] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 508 | if !ok { |
| 509 | glog.Fatalf("Entry %q not found in iOS mapping.", parts["model"]) |
| 510 | } |
| 511 | d["device"] = device |
Ben Wagner | d26e446 | 2018-05-22 10:46:15 -0400 | [diff] [blame] | 512 | } else if strings.Contains(parts["extra_config"], "SwiftShader") { |
| 513 | if parts["model"] != "GCE" || d["os"] != DEFAULT_OS_DEBIAN || parts["cpu_or_gpu_value"] != "SwiftShader" { |
| 514 | glog.Fatalf("Please update defaultSwarmDimensions for SwiftShader %s %s %s.", parts["os"], parts["model"], parts["cpu_or_gpu_value"]) |
| 515 | } |
| 516 | d["cpu"] = "x86-64-Haswell_GCE" |
| 517 | d["os"] = DEFAULT_OS_LINUX_GCE |
| 518 | d["machine_type"] = MACHINE_TYPE_SMALL |
Kevin Lubick | 35b87a5 | 2018-10-08 15:07:42 -0400 | [diff] [blame] | 519 | } else if strings.Contains(parts["extra_config"], "SKQP") && parts["cpu_or_gpu_value"] == "Emulator" { |
| 520 | if parts["model"] != "NUC7i5BNK" || d["os"] != DEFAULT_OS_DEBIAN { |
| 521 | glog.Fatalf("Please update defaultSwarmDimensions for SKQP::Emulator %s %s.", parts["os"], parts["model"]) |
| 522 | } |
| 523 | d["cpu"] = "x86-64-i5-7260U" |
| 524 | d["os"] = "Debian-9.4" |
| 525 | // KVM means Kernel-based Virtual Machine, that is, can this vm virtualize commands |
| 526 | // For us, this means, can we run an x86 android emulator on it. |
| 527 | // kjlubick tried running this on GCE, but it was a bit too slow on the large install. |
| 528 | // So, we run on bare metal machines in the Skolo (that should also have KVM). |
| 529 | d["kvm"] = "1" |
| 530 | d["docker_installed"] = "true" |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 531 | } else if parts["cpu_or_gpu"] == "CPU" { |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 532 | modelMapping, ok := map[string]map[string]string{ |
| 533 | "AVX": { |
Ben Wagner | 7ea5428 | 2018-08-22 14:07:48 -0400 | [diff] [blame] | 534 | "Golo": "x86-64-E5-2670", |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 535 | }, |
| 536 | "AVX2": { |
Ben Wagner | 35eb7fa | 2018-08-06 11:27:17 -0400 | [diff] [blame] | 537 | "GCE": "x86-64-Haswell_GCE", |
| 538 | "MacBookPro11.5": "x86-64-i7-4870HQ", |
| 539 | "NUC5i7RYH": "x86-64-i7-5557U", |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 540 | }, |
Ben Wagner | b268d23 | 2017-09-28 16:38:34 -0400 | [diff] [blame] | 541 | "AVX512": { |
| 542 | "GCE": "x86-64-Skylake_GCE", |
| 543 | }, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 544 | }[parts["cpu_or_gpu_value"]] |
Ben Wagner | 3d2a2f7 | 2017-06-13 17:01:16 -0400 | [diff] [blame] | 545 | if !ok { |
| 546 | glog.Fatalf("Entry %q not found in CPU mapping.", parts["cpu_or_gpu_value"]) |
| 547 | } |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 548 | cpu, ok := modelMapping[parts["model"]] |
| 549 | if !ok { |
| 550 | 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] | 551 | } |
Ben Wagner | 4c9842e | 2017-09-25 12:56:53 -0400 | [diff] [blame] | 552 | d["cpu"] = cpu |
Eric Boren | 170c39c | 2017-11-15 11:22:57 -0500 | [diff] [blame] | 553 | if parts["model"] == "GCE" && d["os"] == DEFAULT_OS_DEBIAN { |
| 554 | d["os"] = DEFAULT_OS_LINUX_GCE |
| 555 | } |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 556 | if parts["model"] == "GCE" && d["cpu"] == "x86-64-Haswell_GCE" { |
Kevin Lubick | 2f9c1cc | 2018-09-24 11:22:55 -0400 | [diff] [blame] | 557 | d["machine_type"] = MACHINE_TYPE_MEDIUM |
Ben Wagner | f53e6c9 | 2017-12-14 13:15:01 -0500 | [diff] [blame] | 558 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 559 | } else { |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 560 | if strings.Contains(parts["extra_config"], "CanvasKit") { |
| 561 | // GPU is defined for the WebGL version of CanvasKit, but |
| 562 | // it can still run on a GCE instance. |
| 563 | return wasmGceDimensions() |
| 564 | } else if strings.Contains(parts["os"], "Win") { |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 565 | gpu, ok := map[string]string{ |
Ben Wagner | f6148b6 | 2018-03-15 13:53:25 -0400 | [diff] [blame] | 566 | "GT610": "10de:104a-23.21.13.9101", |
Ben Wagner | f713dd1 | 2018-10-26 14:09:52 -0400 | [diff] [blame] | 567 | "GTX660": "10de:11c0-25.21.14.1634", |
| 568 | "GTX960": "10de:1401-25.21.14.1634", |
Greg Daniel | 900e5c8 | 2018-08-28 10:59:24 -0400 | [diff] [blame] | 569 | "IntelHD4400": "8086:0a16-20.19.15.4963", |
Ben Wagner | 7b069fa | 2018-12-03 13:02:01 -0500 | [diff] [blame] | 570 | "IntelIris540": "8086:1926-25.20.100.6444", |
Greg Daniel | 900e5c8 | 2018-08-28 10:59:24 -0400 | [diff] [blame] | 571 | "IntelIris6100": "8086:162b-20.19.15.4963", |
Ben Wagner | b73cb3f | 2019-01-04 13:18:10 -0500 | [diff] [blame] | 572 | "IntelIris655": "8086:3ea5-25.20.100.6444", |
Ben Wagner | 1f0fb09 | 2018-08-27 18:09:52 -0400 | [diff] [blame] | 573 | "RadeonHD7770": "1002:683d-24.20.13001.1010", |
| 574 | "RadeonR9M470X": "1002:6646-24.20.13001.1010", |
Ben Wagner | ce7a16b | 2018-11-14 21:16:00 -0500 | [diff] [blame] | 575 | "QuadroP400": "10de:1cb3-25.21.14.1678", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 576 | }[parts["cpu_or_gpu_value"]] |
| 577 | if !ok { |
| 578 | glog.Fatalf("Entry %q not found in Win GPU mapping.", parts["cpu_or_gpu_value"]) |
| 579 | } |
| 580 | d["gpu"] = gpu |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 581 | } else if strings.Contains(parts["os"], "Ubuntu") || strings.Contains(parts["os"], "Debian") { |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 582 | gpu, ok := map[string]string{ |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 583 | // Intel drivers come from CIPD, so no need to specify the version here. |
| 584 | "IntelBayTrail": "8086:0f31", |
| 585 | "IntelHD2000": "8086:0102", |
| 586 | "IntelHD405": "8086:22b1", |
Ben Wagner | ab10c82 | 2017-12-19 15:14:12 -0500 | [diff] [blame] | 587 | "IntelIris640": "8086:5926", |
Ben Wagner | c274ec4 | 2017-08-03 22:29:22 -0400 | [diff] [blame] | 588 | "QuadroP400": "10de:1cb3-384.59", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 589 | }[parts["cpu_or_gpu_value"]] |
| 590 | if !ok { |
| 591 | glog.Fatalf("Entry %q not found in Ubuntu GPU mapping.", parts["cpu_or_gpu_value"]) |
| 592 | } |
Ben Wagner | 2aa9a22 | 2018-11-06 13:45:40 -0500 | [diff] [blame] | 593 | if parts["os"] == "Ubuntu18" && parts["cpu_or_gpu_value"] == "QuadroP400" { |
| 594 | // Ubuntu18 has a slightly newer GPU driver. |
| 595 | gpu = "10de:1cb3-390.87" |
| 596 | } |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 597 | d["gpu"] = gpu |
| 598 | } else if strings.Contains(parts["os"], "Mac") { |
| 599 | gpu, ok := map[string]string{ |
Ben Wagner | 1d8726f | 2018-02-02 14:47:31 -0500 | [diff] [blame] | 600 | "IntelHD6000": "8086:1626", |
Ben Wagner | df43005 | 2018-02-08 16:57:04 -0500 | [diff] [blame] | 601 | "IntelHD615": "8086:591e", |
Ben Wagner | cc4221b | 2017-08-17 17:29:04 -0400 | [diff] [blame] | 602 | "IntelIris5100": "8086:0a2e", |
Ben Wagner | eeeb328 | 2018-05-15 16:45:42 -0400 | [diff] [blame] | 603 | "RadeonHD8870M": "1002:6821-4.0.20-3.2.8", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 604 | }[parts["cpu_or_gpu_value"]] |
| 605 | if !ok { |
| 606 | glog.Fatalf("Entry %q not found in Mac GPU mapping.", parts["cpu_or_gpu_value"]) |
| 607 | } |
| 608 | d["gpu"] = gpu |
Ben Wagner | e7b8fea | 2018-02-09 10:29:09 -0500 | [diff] [blame] | 609 | // Yuck. We have two different types of MacMini7,1 with the same GPU but different CPUs. |
| 610 | if parts["cpu_or_gpu_value"] == "IntelIris5100" { |
| 611 | // Run all tasks on Golo machines for now. |
| 612 | d["cpu"] = "x86-64-i7-4578U" |
| 613 | } |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 614 | } else if strings.Contains(parts["os"], "ChromeOS") { |
Kevin Lubick | 64ca6be | 2017-12-04 15:43:31 -0500 | [diff] [blame] | 615 | version, ok := map[string]string{ |
Kevin Lubick | ff8387f | 2018-05-01 10:43:35 -0400 | [diff] [blame] | 616 | "MaliT604": "10575.22.0", |
Kevin Lubick | e114e59 | 2018-05-01 08:53:52 -0400 | [diff] [blame] | 617 | "MaliT764": "10575.22.0", |
Kevin Lubick | e467d4e | 2018-05-01 13:12:58 -0400 | [diff] [blame] | 618 | "MaliT860": "10575.22.0", |
| 619 | "PowerVRGX6250": "10575.22.0", |
| 620 | "TegraK1": "10575.22.0", |
| 621 | "IntelHDGraphics615": "10575.22.0", |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 622 | }[parts["cpu_or_gpu_value"]] |
| 623 | if !ok { |
| 624 | glog.Fatalf("Entry %q not found in ChromeOS GPU mapping.", parts["cpu_or_gpu_value"]) |
| 625 | } |
Kevin Lubick | 64ca6be | 2017-12-04 15:43:31 -0500 | [diff] [blame] | 626 | d["gpu"] = parts["cpu_or_gpu_value"] |
| 627 | d["release_version"] = version |
Ben Wagner | 1d06078 | 2017-06-14 10:34:18 -0400 | [diff] [blame] | 628 | } else { |
| 629 | glog.Fatalf("Unknown GPU mapping for OS %q.", parts["os"]) |
Ben Wagner | 0843589 | 2017-02-18 23:28:26 -0500 | [diff] [blame] | 630 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 631 | } |
| 632 | } else { |
| 633 | d["gpu"] = "none" |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 634 | if d["os"] == DEFAULT_OS_DEBIAN { |
Kevin Lubick | 8e9750d | 2018-10-09 09:36:35 -0400 | [diff] [blame] | 635 | if strings.Contains(parts["extra_config"], "PathKit") || strings.Contains(parts["extra_config"], "CanvasKit") { |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 636 | return wasmGceDimensions() |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 637 | } |
Kevin Lubick | 3655e40 | 2018-10-12 16:58:52 -0400 | [diff] [blame] | 638 | if parts["role"] == "BuildStats" { |
| 639 | // Doesn't require a lot of resources |
| 640 | return linuxGceDimensions(MACHINE_TYPE_MEDIUM) |
| 641 | } |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 642 | // Use many-core machines for Build tasks. |
| 643 | return linuxGceDimensions(MACHINE_TYPE_LARGE) |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 644 | } else if d["os"] == DEFAULT_OS_WIN { |
| 645 | // Windows CPU bots. |
Ben Wagner | a78f1bc | 2017-09-26 18:19:56 -0400 | [diff] [blame] | 646 | d["cpu"] = "x86-64-Haswell_GCE" |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 647 | // Use many-core machines for Build tasks. |
| 648 | d["machine_type"] = MACHINE_TYPE_LARGE |
Ben Wagner | d3fdcc9 | 2017-11-14 13:30:04 -0500 | [diff] [blame] | 649 | } else if d["os"] == DEFAULT_OS_MAC { |
| 650 | // Mac CPU bots. |
Ben Wagner | a78f1bc | 2017-09-26 18:19:56 -0400 | [diff] [blame] | 651 | d["cpu"] = "x86-64-E5-2697_v2" |
Kevin Lubick | 4610a9b | 2017-03-22 15:54:54 -0400 | [diff] [blame] | 652 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 653 | } |
Kevin Lubick | 4610a9b | 2017-03-22 15:54:54 -0400 | [diff] [blame] | 654 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 655 | rv := make([]string, 0, len(d)) |
| 656 | for k, v := range d { |
| 657 | rv = append(rv, fmt.Sprintf("%s:%s", k, v)) |
| 658 | } |
| 659 | sort.Strings(rv) |
| 660 | return rv |
| 661 | } |
| 662 | |
Eric Boren | 7e3a364 | 2017-06-14 15:25:31 -0400 | [diff] [blame] | 663 | // relpath returns the relative path to the given file from the config file. |
| 664 | func relpath(f string) string { |
| 665 | _, filename, _, _ := runtime.Caller(0) |
| 666 | dir := path.Dir(filename) |
| 667 | rel := dir |
| 668 | if *cfgFile != "" { |
| 669 | rel = path.Dir(*cfgFile) |
| 670 | } |
| 671 | rv, err := filepath.Rel(rel, path.Join(dir, f)) |
| 672 | if err != nil { |
| 673 | sklog.Fatal(err) |
| 674 | } |
| 675 | return rv |
| 676 | } |
| 677 | |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 678 | // bundleRecipes generates the task to bundle and isolate the recipes. |
| 679 | func bundleRecipes(b *specs.TasksCfgBuilder) string { |
Eric Boren | 6392442 | 2018-06-21 09:02:30 -0400 | [diff] [blame] | 680 | pkgs := append([]*specs.CipdPackage{}, CIPD_PKGS_GIT...) |
| 681 | pkgs = append(pkgs, CIPD_PKGS_PYTHON...) |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 682 | b.MustAddTask(BUNDLE_RECIPES_NAME, &specs.TaskSpec{ |
Eric Boren | 6392442 | 2018-06-21 09:02:30 -0400 | [diff] [blame] | 683 | CipdPackages: pkgs, |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 684 | Command: []string{ |
| 685 | "/bin/bash", "skia/infra/bots/bundle_recipes.sh", specs.PLACEHOLDER_ISOLATED_OUTDIR, |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 686 | }, |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 687 | Dimensions: linuxGceDimensions(MACHINE_TYPE_SMALL), |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 688 | EnvPrefixes: map[string][]string{ |
| 689 | "PATH": []string{"cipd_bin_packages", "cipd_bin_packages/bin"}, |
| 690 | }, |
Ben Wagner | c062b6b | 2018-07-24 17:10:46 -0400 | [diff] [blame] | 691 | Isolate: relpath("swarm_recipe.isolate"), |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 692 | }) |
| 693 | return BUNDLE_RECIPES_NAME |
| 694 | } |
| 695 | |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 696 | type isolateAssetCfg struct { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 697 | cipdPkg string |
| 698 | path string |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | var ISOLATE_ASSET_MAPPING = map[string]isolateAssetCfg{ |
Stephan Altmueller | 88df8d2 | 2018-03-07 14:44:44 -0500 | [diff] [blame] | 702 | ISOLATE_GCLOUD_LINUX_NAME: { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 703 | cipdPkg: "gcloud_linux", |
| 704 | path: "gcloud_linux", |
Stephan Altmueller | 88df8d2 | 2018-03-07 14:44:44 -0500 | [diff] [blame] | 705 | }, |
Eric Boren | 9d83458 | 2018-08-03 14:29:03 -0400 | [diff] [blame] | 706 | ISOLATE_GO_DEPS_NAME: { |
| 707 | cipdPkg: "go_deps", |
| 708 | path: "go_deps", |
| 709 | }, |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 710 | ISOLATE_SKIMAGE_NAME: { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 711 | cipdPkg: "skimage", |
| 712 | path: "skimage", |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 713 | }, |
| 714 | ISOLATE_SKP_NAME: { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 715 | cipdPkg: "skp", |
| 716 | path: "skp", |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 717 | }, |
| 718 | ISOLATE_SVG_NAME: { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 719 | cipdPkg: "svg", |
| 720 | path: "svg", |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 721 | }, |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 722 | ISOLATE_NDK_LINUX_NAME: { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 723 | cipdPkg: "android_ndk_linux", |
| 724 | path: "android_ndk_linux", |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 725 | }, |
Stephan Altmueller | 2a55217 | 2018-02-20 11:40:25 -0500 | [diff] [blame] | 726 | ISOLATE_SDK_LINUX_NAME: { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 727 | cipdPkg: "android_sdk_linux", |
| 728 | path: "android_sdk_linux", |
Stephan Altmueller | 2a55217 | 2018-02-20 11:40:25 -0500 | [diff] [blame] | 729 | }, |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 730 | ISOLATE_WIN_TOOLCHAIN_NAME: { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 731 | cipdPkg: "win_toolchain", |
Brian Osman | ef3d04e | 2018-12-12 13:28:09 -0500 | [diff] [blame] | 732 | path: "win_toolchain", |
Kevin Lubick | 814b149 | 2017-11-29 14:45:14 -0500 | [diff] [blame] | 733 | }, |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 734 | } |
| 735 | |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 736 | // isolateCIPDAsset generates a task to isolate the given CIPD asset. |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 737 | func isolateCIPDAsset(b *specs.TasksCfgBuilder, name string) string { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 738 | asset := ISOLATE_ASSET_MAPPING[name] |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 739 | b.MustAddTask(name, &specs.TaskSpec{ |
| 740 | CipdPackages: []*specs.CipdPackage{ |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 741 | b.MustGetCipdPackageFromAsset(asset.cipdPkg), |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 742 | }, |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 743 | Command: []string{"/bin/cp", "-rL", asset.path, "${ISOLATED_OUTDIR}"}, |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 744 | Dimensions: linuxGceDimensions(MACHINE_TYPE_SMALL), |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 745 | Isolate: relpath("empty.isolate"), |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 746 | }) |
| 747 | return name |
| 748 | } |
| 749 | |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 750 | // getIsolatedCIPDDeps returns the slice of Isolate_* tasks a given task needs. |
| 751 | // This allows us to save time on I/O bound bots, like the RPIs. |
| 752 | func getIsolatedCIPDDeps(parts map[string]string) []string { |
| 753 | deps := []string{} |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 754 | // Only do this on the RPIs for now. Other, faster machines shouldn't see much |
| 755 | // benefit and we don't need the extra complexity, for now |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 756 | rpiOS := []string{"Android", "ChromeOS", "iOS"} |
| 757 | |
| 758 | if o := parts["os"]; strings.Contains(o, "Chromecast") { |
| 759 | // Chromecasts don't have enough disk space to fit all of the content, |
| 760 | // so we do a subset of the skps. |
| 761 | deps = append(deps, ISOLATE_SKP_NAME) |
| 762 | } else if e := parts["extra_config"]; strings.Contains(e, "Skpbench") { |
| 763 | // Skpbench only needs skps |
| 764 | deps = append(deps, ISOLATE_SKP_NAME) |
| 765 | } else if util.In(o, rpiOS) { |
| 766 | deps = append(deps, ISOLATE_SKP_NAME) |
| 767 | deps = append(deps, ISOLATE_SVG_NAME) |
| 768 | deps = append(deps, ISOLATE_SKIMAGE_NAME) |
| 769 | } |
| 770 | |
| 771 | return deps |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 772 | } |
| 773 | |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 774 | // usesGit adds attributes to tasks which use git. |
| 775 | func usesGit(t *specs.TaskSpec, name string) { |
| 776 | t.Caches = append(t.Caches, CACHES_GIT...) |
| 777 | if !strings.Contains(name, "NoDEPS") { |
| 778 | t.Caches = append(t.Caches, CACHES_WORKDIR...) |
| 779 | } |
| 780 | t.CipdPackages = append(t.CipdPackages, CIPD_PKGS_GIT...) |
| 781 | } |
| 782 | |
Ben Wagner | bb7d381 | 2018-12-18 23:42:11 -0500 | [diff] [blame] | 783 | // usesGo adds attributes to tasks which use go. Recipes should use |
| 784 | // "with api.context(env=api.infra.go_env)". |
| 785 | // (Not needed for tasks that just want to run Go code from the infra repo -- instead use go_deps.) |
| 786 | func usesGo(b *specs.TasksCfgBuilder, t *specs.TaskSpec) { |
| 787 | t.Caches = append(t.Caches, CACHES_GO...) |
| 788 | t.CipdPackages = append(t.CipdPackages, b.MustGetCipdPackageFromAsset("go")) |
| 789 | t.Dependencies = append(t.Dependencies, isolateCIPDAsset(b, ISOLATE_GO_DEPS_NAME)) |
| 790 | } |
| 791 | |
Kevin Lubick | 30cc00c | 2018-08-03 10:26:00 -0400 | [diff] [blame] | 792 | // usesDocker adds attributes to tasks which use docker. |
| 793 | func usesDocker(t *specs.TaskSpec, name string) { |
Kevin Lubick | 40654f2 | 2019-01-02 09:50:19 -0500 | [diff] [blame] | 794 | if strings.Contains(name, "EMCC") || strings.Contains(name, "SKQP") || strings.Contains(name, "LottieWeb") { |
Kevin Lubick | 30cc00c | 2018-08-03 10:26:00 -0400 | [diff] [blame] | 795 | t.Caches = append(t.Caches, CACHES_DOCKER...) |
| 796 | } |
| 797 | } |
| 798 | |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 799 | // timeout sets the timeout(s) for this task. |
| 800 | func timeout(task *specs.TaskSpec, timeout time.Duration) { |
| 801 | task.ExecutionTimeout = timeout |
| 802 | task.IoTimeout = timeout // With kitchen, step logs don't count toward IoTimeout. |
| 803 | } |
| 804 | |
Ben Wagner | 73e2ced | 2018-12-17 12:44:30 -0500 | [diff] [blame] | 805 | // attempts returns the desired MaxAttempts for this task. |
| 806 | func attempts(name string) int { |
| 807 | if strings.Contains(name, "Android_Framework") { |
| 808 | // The reason for this has been lost to time. |
| 809 | return 1 |
| 810 | } |
| 811 | if !(strings.HasPrefix(name, "Build-") || strings.HasPrefix(name, "Upload-")) { |
| 812 | for _, extraConfig := range []string{"ASAN", "MSAN", "TSAN", "UBSAN", "Valgrind"} { |
| 813 | if strings.Contains(name, extraConfig) { |
| 814 | // Sanitizers often find non-deterministic issues that retries would hide. |
| 815 | return 1 |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | // Retry by default to hide random bot/hardware failures. |
| 820 | return 2 |
| 821 | } |
| 822 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 823 | // compile generates a compile task. Returns the name of the last task in the |
| 824 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 825 | func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 826 | task := kitchenTask(name, "compile", "swarm_recipe.isolate", SERVICE_ACCOUNT_COMPILE, swarmDimensions(parts), nil, OUTPUT_BUILD) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 827 | usesGit(task, name) |
Kevin Lubick | 30cc00c | 2018-08-03 10:26:00 -0400 | [diff] [blame] | 828 | usesDocker(task, name) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 829 | |
| 830 | // Android bots require a toolchain. |
| 831 | if strings.Contains(name, "Android") { |
Ravi Mistry | 5e96742 | 2018-02-01 13:38:13 -0500 | [diff] [blame] | 832 | if parts["extra_config"] == "Android_Framework" { |
| 833 | // Do not need a toolchain when building the |
| 834 | // Android Framework. |
| 835 | } else if strings.Contains(name, "Mac") { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 836 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("android_ndk_darwin")) |
Mike Klein | 86c2c0f | 2016-11-02 13:13:16 -0400 | [diff] [blame] | 837 | } else if strings.Contains(name, "Win") { |
Mike Klein | e9215f0 | 2016-11-02 15:44:26 -0400 | [diff] [blame] | 838 | pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows") |
| 839 | pkg.Path = "n" |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 840 | task.CipdPackages = append(task.CipdPackages, pkg) |
Kevin Lubick | 35b87a5 | 2018-10-08 15:07:42 -0400 | [diff] [blame] | 841 | } else if !strings.Contains(name, "SKQP") { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 842 | task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_NDK_LINUX_NAME)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 843 | } |
Kevin Lubick | dcd2a90 | 2017-03-08 14:01:01 -0500 | [diff] [blame] | 844 | } else if strings.Contains(name, "Chromecast") { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 845 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("cast_toolchain")) |
| 846 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("chromebook_arm_gles")) |
Kevin Lubick | 261ea19 | 2017-04-05 07:32:45 -0400 | [diff] [blame] | 847 | } else if strings.Contains(name, "Chromebook") { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 848 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("clang_linux")) |
Kevin Lubick | b718fbb | 2017-11-02 09:34:08 -0400 | [diff] [blame] | 849 | if parts["target_arch"] == "x86_64" { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 850 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("chromebook_x86_64_gles")) |
Kevin Lubick | b718fbb | 2017-11-02 09:34:08 -0400 | [diff] [blame] | 851 | } else if parts["target_arch"] == "arm" { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 852 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("armhf_sysroot")) |
| 853 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("chromebook_arm_gles")) |
Kevin Lubick | b718fbb | 2017-11-02 09:34:08 -0400 | [diff] [blame] | 854 | } |
Eric Boren | bb198fb | 2017-06-28 11:45:54 -0400 | [diff] [blame] | 855 | } else if strings.Contains(name, "Debian") { |
Kevin Lubick | 9c7dcac | 2017-01-18 09:24:56 -0500 | [diff] [blame] | 856 | if strings.Contains(name, "Clang") { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 857 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("clang_linux")) |
Kevin Lubick | 9c7dcac | 2017-01-18 09:24:56 -0500 | [diff] [blame] | 858 | } |
Ben Wagner | 9bd736b | 2018-04-04 15:35:01 -0400 | [diff] [blame] | 859 | if parts["target_arch"] == "mips64el" || parts["target_arch"] == "loongson3a" { |
| 860 | if parts["compiler"] != "GCC" { |
| 861 | glog.Fatalf("mips64el toolchain is GCC, but compiler is %q in %q", parts["compiler"], name) |
| 862 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 863 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("mips64el_toolchain_linux")) |
Ben Wagner | 9bd736b | 2018-04-04 15:35:01 -0400 | [diff] [blame] | 864 | } |
Ben Wagner | bbdee1b | 2018-04-19 17:53:03 -0400 | [diff] [blame] | 865 | if strings.Contains(name, "SwiftShader") { |
| 866 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("cmake_linux")) |
| 867 | } |
Ben Wagner | 55a7d22 | 2018-06-28 20:41:04 -0400 | [diff] [blame] | 868 | if strings.Contains(name, "OpenCL") { |
| 869 | task.CipdPackages = append(task.CipdPackages, |
| 870 | b.MustGetCipdPackageFromAsset("opencl_headers"), |
| 871 | b.MustGetCipdPackageFromAsset("opencl_ocl_icd_linux"), |
| 872 | ) |
| 873 | } |
Mike Klein | 27dcee1 | 2016-11-09 16:31:42 -0500 | [diff] [blame] | 874 | } else if strings.Contains(name, "Win") { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 875 | task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_WIN_TOOLCHAIN_NAME)) |
Mike Klein | 8e3c42b | 2017-07-31 14:57:20 -0400 | [diff] [blame] | 876 | if strings.Contains(name, "Clang") { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 877 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("clang_win")) |
Mike Klein | 8e3c42b | 2017-07-31 14:57:20 -0400 | [diff] [blame] | 878 | } |
Ben Wagner | 30a4e3d | 2018-08-07 16:58:15 -0400 | [diff] [blame] | 879 | if strings.Contains(name, "OpenCL") { |
| 880 | task.CipdPackages = append(task.CipdPackages, |
| 881 | b.MustGetCipdPackageFromAsset("opencl_headers"), |
| 882 | ) |
| 883 | } |
Ben Wagner | cdfa16d | 2018-08-03 10:07:47 -0400 | [diff] [blame] | 884 | } else if strings.Contains(name, "Mac") { |
| 885 | task.CipdPackages = append(task.CipdPackages, CIPD_PKGS_XCODE...) |
| 886 | task.Caches = append(task.Caches, &specs.Cache{ |
| 887 | Name: "xcode", |
| 888 | Path: "cache/Xcode.app", |
| 889 | }) |
| 890 | if strings.Contains(name, "CommandBuffer") { |
| 891 | timeout(task, 2*time.Hour) |
| 892 | } |
| 893 | if strings.Contains(name, "MoltenVK") { |
| 894 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("moltenvk")) |
| 895 | } |
Chris Dalton | 2b937f5 | 2018-05-17 10:17:10 -0600 | [diff] [blame] | 896 | } |
| 897 | |
Eric Boren | bd2e1f1 | 2018-04-17 11:28:46 +0000 | [diff] [blame] | 898 | // Add the task. |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 899 | b.MustAddTask(name, task) |
| 900 | |
Eric Boren | 8615fe5 | 2016-12-12 14:30:12 -0500 | [diff] [blame] | 901 | // All compile tasks are runnable as their own Job. Assert that the Job |
| 902 | // is listed in JOBS. |
| 903 | if !util.In(name, JOBS) { |
| 904 | glog.Fatalf("Job %q is missing from the JOBS list!", name) |
| 905 | } |
Ravi Mistry | 6f13622 | 2017-12-12 17:08:24 -0500 | [diff] [blame] | 906 | |
| 907 | // Upload the skiaserve binary only for Linux Android compile bots. |
| 908 | // See skbug.com/7399 for context. |
| 909 | if parts["configuration"] == "Release" && |
| 910 | parts["extra_config"] == "Android" && |
| 911 | !strings.Contains(parts["os"], "Win") && |
| 912 | !strings.Contains(parts["os"], "Mac") { |
| 913 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 914 | task := kitchenTask(uploadName, "upload_skiaserve", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_BINARY, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 915 | task.Dependencies = append(task.Dependencies, name) |
| 916 | b.MustAddTask(uploadName, task) |
Ravi Mistry | 6f13622 | 2017-12-12 17:08:24 -0500 | [diff] [blame] | 917 | return uploadName |
| 918 | } |
| 919 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 920 | return name |
| 921 | } |
| 922 | |
| 923 | // recreateSKPs generates a RecreateSKPs task. Returns the name of the last |
| 924 | // task in the generated chain of tasks, which the Job should add as a |
| 925 | // dependency. |
Eric Boren | 2768861 | 2018-04-16 13:21:01 +0000 | [diff] [blame] | 926 | func recreateSKPs(b *specs.TasksCfgBuilder, name string) string { |
Ravi Mistry | 5a12d05 | 2018-05-15 17:19:42 -0400 | [diff] [blame] | 927 | dims := []string{ |
| 928 | "pool:SkiaCT", |
| 929 | fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE), |
| 930 | } |
| 931 | task := kitchenTask(name, "recreate_skps", "swarm_recipe.isolate", SERVICE_ACCOUNT_RECREATE_SKPS, dims, nil, OUTPUT_NONE) |
Eric Boren | e7950e3 | 2018-04-26 08:49:38 -0400 | [diff] [blame] | 932 | task.CipdPackages = append(task.CipdPackages, CIPD_PKGS_GIT...) |
Ben Wagner | bb7d381 | 2018-12-18 23:42:11 -0500 | [diff] [blame] | 933 | usesGo(b, task) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 934 | timeout(task, 4*time.Hour) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 935 | b.MustAddTask(name, task) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 936 | return name |
| 937 | } |
| 938 | |
Eric Boren | 84ae641 | 2018-09-27 14:55:03 -0400 | [diff] [blame] | 939 | // updateGoDEPS generates an UpdateGoDEPS task. Returns the name of the last |
| 940 | // task in the generated chain of tasks, which the Job should add as a |
| 941 | // dependency. |
| 942 | func updateGoDEPS(b *specs.TasksCfgBuilder, name string) string { |
| 943 | dims := linuxGceDimensions(MACHINE_TYPE_LARGE) |
| 944 | task := kitchenTask(name, "update_go_deps", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPDATE_GO_DEPS, dims, nil, OUTPUT_NONE) |
| 945 | task.CipdPackages = append(task.CipdPackages, CIPD_PKGS_GIT...) |
Ben Wagner | bb7d381 | 2018-12-18 23:42:11 -0500 | [diff] [blame] | 946 | usesGo(b, task) |
Eric Boren | 84ae641 | 2018-09-27 14:55:03 -0400 | [diff] [blame] | 947 | b.MustAddTask(name, task) |
| 948 | return name |
| 949 | } |
| 950 | |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 951 | // checkGeneratedFiles verifies that no generated SKSL files have been edited |
| 952 | // by hand. |
Eric Boren | 2768861 | 2018-04-16 13:21:01 +0000 | [diff] [blame] | 953 | func checkGeneratedFiles(b *specs.TasksCfgBuilder, name string) string { |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 954 | task := kitchenTask(name, "check_generated_files", "swarm_recipe.isolate", SERVICE_ACCOUNT_COMPILE, linuxGceDimensions(MACHINE_TYPE_LARGE), nil, OUTPUT_NONE) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 955 | task.Caches = append(task.Caches, CACHES_WORKDIR...) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 956 | b.MustAddTask(name, task) |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 957 | return name |
| 958 | } |
| 959 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 960 | // housekeeper generates a Housekeeper task. Returns the name of the last task |
| 961 | // in the generated chain of tasks, which the Job should add as a dependency. |
Kevin Lubick | 37baac1 | 2018-10-09 16:25:27 -0400 | [diff] [blame] | 962 | func housekeeper(b *specs.TasksCfgBuilder, name string) string { |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 963 | task := kitchenTask(name, "housekeeper", "swarm_recipe.isolate", SERVICE_ACCOUNT_HOUSEKEEPER, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 964 | usesGit(task, name) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 965 | b.MustAddTask(name, task) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 966 | return name |
| 967 | } |
| 968 | |
Ravi Mistry | edc4f3e | 2017-12-08 12:58:20 -0500 | [diff] [blame] | 969 | // bookmaker generates a Bookmaker task. Returns the name of the last task |
| 970 | // in the generated chain of tasks, which the Job should add as a dependency. |
| 971 | func bookmaker(b *specs.TasksCfgBuilder, name, compileTaskName string) string { |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 972 | task := kitchenTask(name, "bookmaker", "swarm_recipe.isolate", SERVICE_ACCOUNT_BOOKMAKER, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 973 | task.Caches = append(task.Caches, CACHES_WORKDIR...) |
Eric Boren | e7950e3 | 2018-04-26 08:49:38 -0400 | [diff] [blame] | 974 | task.CipdPackages = append(task.CipdPackages, CIPD_PKGS_GIT...) |
Ben Wagner | 4358802 | 2018-12-18 23:16:07 -0500 | [diff] [blame] | 975 | task.Dependencies = append(task.Dependencies, compileTaskName, isolateCIPDAsset(b, ISOLATE_GO_DEPS_NAME)) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 976 | timeout(task, 2*time.Hour) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 977 | b.MustAddTask(name, task) |
Ravi Mistry | edc4f3e | 2017-12-08 12:58:20 -0500 | [diff] [blame] | 978 | return name |
| 979 | } |
| 980 | |
Ravi Mistry | 5e96742 | 2018-02-01 13:38:13 -0500 | [diff] [blame] | 981 | // androidFrameworkCompile generates an Android Framework Compile task. Returns |
| 982 | // the name of the last task in the generated chain of tasks, which the Job |
| 983 | // should add as a dependency. |
| 984 | func androidFrameworkCompile(b *specs.TasksCfgBuilder, name string) string { |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 985 | task := kitchenTask(name, "android_compile", "swarm_recipe.isolate", SERVICE_ACCOUNT_COMPILE, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 986 | timeout(task, time.Hour) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 987 | b.MustAddTask(name, task) |
Ravi Mistry | 5e96742 | 2018-02-01 13:38:13 -0500 | [diff] [blame] | 988 | return name |
| 989 | } |
| 990 | |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 991 | // infra generates an infra_tests task. Returns the name of the last task in the |
| 992 | // generated chain of tasks, which the Job should add as a dependency. |
Eric Boren | 2768861 | 2018-04-16 13:21:01 +0000 | [diff] [blame] | 993 | func infra(b *specs.TasksCfgBuilder, name string) string { |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 994 | task := kitchenTask(name, "infra", "swarm_recipe.isolate", SERVICE_ACCOUNT_COMPILE, linuxGceDimensions(MACHINE_TYPE_SMALL), nil, OUTPUT_NONE) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 995 | usesGit(task, name) |
Ben Wagner | bb7d381 | 2018-12-18 23:42:11 -0500 | [diff] [blame] | 996 | usesGo(b, task) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 997 | b.MustAddTask(name, task) |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 998 | return name |
| 999 | } |
| 1000 | |
Kevin Lubick | 4968843 | 2018-10-08 13:58:47 -0400 | [diff] [blame] | 1001 | func buildstats(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string) string { |
| 1002 | task := kitchenTask(name, "compute_buildstats", "swarm_recipe.isolate", "", swarmDimensions(parts), nil, OUTPUT_PERF) |
| 1003 | task.Dependencies = append(task.Dependencies, compileTaskName) |
Kevin Lubick | 6ca0d8a | 2018-10-09 13:31:33 -0400 | [diff] [blame] | 1004 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("bloaty")) |
Kevin Lubick | 4968843 | 2018-10-08 13:58:47 -0400 | [diff] [blame] | 1005 | b.MustAddTask(name, task) |
| 1006 | |
Kevin Lubick | 8875baf | 2018-10-18 13:35:04 -0400 | [diff] [blame] | 1007 | // Upload release results (for tracking in perf) |
| 1008 | // We have some jobs that are FYI (e.g. Debug-CanvasKit) |
| 1009 | if strings.Contains(name, "Release") { |
| 1010 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
| 1011 | extraProps := map[string]string{ |
| 1012 | "gs_bucket": CONFIG.GsBucketNano, |
| 1013 | } |
| 1014 | uploadTask := kitchenTask(name, "upload_buildstats_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_NANO, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE) |
| 1015 | uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...) |
| 1016 | uploadTask.Dependencies = append(uploadTask.Dependencies, name) |
| 1017 | b.MustAddTask(uploadName, uploadTask) |
| 1018 | return uploadName |
Kevin Lubick | 4968843 | 2018-10-08 13:58:47 -0400 | [diff] [blame] | 1019 | } |
Kevin Lubick | 4968843 | 2018-10-08 13:58:47 -0400 | [diff] [blame] | 1020 | |
| 1021 | return name |
| 1022 | } |
| 1023 | |
Yuqian Li | 4a577af | 2018-01-05 11:13:43 -0500 | [diff] [blame] | 1024 | func getParentRevisionName(compileTaskName string, parts map[string]string) string { |
| 1025 | if parts["extra_config"] == "" { |
| 1026 | return compileTaskName + "-ParentRevision" |
| 1027 | } else { |
| 1028 | return compileTaskName + "_ParentRevision" |
| 1029 | } |
| 1030 | } |
| 1031 | |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 1032 | // calmbench generates a calmbench task. Returns the name of the last task in the |
| 1033 | // generated chain of tasks, which the Job should add as a dependency. |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1034 | func calmbench(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName, compileParentName string) string { |
| 1035 | task := kitchenTask(name, "calmbench", "calmbench.isolate", "", swarmDimensions(parts), nil, OUTPUT_PERF) |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1036 | usesGit(task, name) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1037 | task.Dependencies = append(task.Dependencies, compileTaskName, compileParentName, ISOLATE_SKP_NAME, ISOLATE_SVG_NAME) |
Kevin Lubick | de1a1a2 | 2018-10-01 10:07:42 -0400 | [diff] [blame] | 1038 | if parts["cpu_or_gpu_value"] == "QuadroP400" { |
| 1039 | // Specify "rack" dimension for consistent test results. |
| 1040 | // See https://bugs.chromium.org/p/chromium/issues/detail?id=784662&desc=2#c34 |
| 1041 | // for more context. |
Ben Wagner | 2aa9a22 | 2018-11-06 13:45:40 -0500 | [diff] [blame] | 1042 | if parts["os"] == "Ubuntu18" { |
| 1043 | task.Dimensions = append(task.Dimensions, "rack:2") |
| 1044 | } else { |
| 1045 | task.Dimensions = append(task.Dimensions, "rack:1") |
| 1046 | } |
Kevin Lubick | de1a1a2 | 2018-10-01 10:07:42 -0400 | [diff] [blame] | 1047 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1048 | b.MustAddTask(name, task) |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 1049 | |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 1050 | // Upload results if necessary. |
| 1051 | if strings.Contains(name, "Release") && doUpload(name) { |
| 1052 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1053 | extraProps := map[string]string{ |
| 1054 | "gs_bucket": CONFIG.GsBucketCalm, |
| 1055 | } |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 1056 | uploadTask := kitchenTask(name, "upload_calmbench_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_CALMBENCH, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1057 | uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...) |
| 1058 | uploadTask.Dependencies = append(uploadTask.Dependencies, name) |
| 1059 | b.MustAddTask(uploadName, uploadTask) |
Yuqian Li | 2ebf3d1 | 2017-10-24 09:43:21 -0400 | [diff] [blame] | 1060 | return uploadName |
| 1061 | } |
| 1062 | |
Yuqian Li | c81aaaa | 2017-10-16 12:24:43 -0400 | [diff] [blame] | 1063 | return name |
| 1064 | } |
| 1065 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1066 | // doUpload indicates whether the given Job should upload its results. |
| 1067 | func doUpload(name string) bool { |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 1068 | for _, s := range CONFIG.NoUpload { |
| 1069 | m, err := regexp.MatchString(s, name) |
| 1070 | if err != nil { |
| 1071 | glog.Fatal(err) |
| 1072 | } |
| 1073 | if m { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1074 | return false |
| 1075 | } |
| 1076 | } |
| 1077 | return true |
| 1078 | } |
| 1079 | |
| 1080 | // test generates a Test task. Returns the name of the last task in the |
| 1081 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1082 | func test(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string { |
Stephan Altmueller | 88df8d2 | 2018-03-07 14:44:44 -0500 | [diff] [blame] | 1083 | recipe := "test" |
Stephan Altmueller | 88df8d2 | 2018-03-07 14:44:44 -0500 | [diff] [blame] | 1084 | if strings.Contains(name, "SKQP") { |
| 1085 | recipe = "skqp_test" |
Kevin Lubick | 35b87a5 | 2018-10-08 15:07:42 -0400 | [diff] [blame] | 1086 | if strings.Contains(name, "Emulator") { |
| 1087 | recipe = "test_skqp_emulator" |
| 1088 | } |
Ben Wagner | a5e7030 | 2018-06-28 17:43:08 -0400 | [diff] [blame] | 1089 | } else if strings.Contains(name, "OpenCL") { |
| 1090 | // TODO(dogben): Longer term we may not want this to be called a "Test" task, but until we start |
| 1091 | // running hs_bench or kx, it will be easier to fit into the current job name schema. |
| 1092 | recipe = "compute_test" |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 1093 | } else if strings.Contains(name, "PathKit") { |
| 1094 | recipe = "test_pathkit" |
Kevin Lubick | 8e9750d | 2018-10-09 09:36:35 -0400 | [diff] [blame] | 1095 | } else if strings.Contains(name, "CanvasKit") { |
| 1096 | recipe = "test_canvaskit" |
Kevin Lubick | 82999c0 | 2018-08-28 10:52:18 -0400 | [diff] [blame] | 1097 | } else if strings.Contains(name, "LottieWeb") { |
| 1098 | recipe = "test_lottie_web" |
Stephan Altmueller | 88df8d2 | 2018-03-07 14:44:44 -0500 | [diff] [blame] | 1099 | } |
Stephan Altmüller | 64cc576 | 2018-08-02 08:51:38 +0200 | [diff] [blame] | 1100 | extraProps := map[string]string{ |
| 1101 | "gold_hashes_url": CONFIG.GoldHashesURL, |
| 1102 | } |
Eric Boren | eb70238 | 2018-04-19 09:36:45 -0400 | [diff] [blame] | 1103 | iid := internalHardwareLabel(parts) |
| 1104 | if iid != nil { |
| 1105 | extraProps["internal_hardware_label"] = strconv.Itoa(*iid) |
| 1106 | } |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 1107 | isolate := "test_skia_bundled.isolate" |
Kevin Lubick | 8e9750d | 2018-10-09 09:36:35 -0400 | [diff] [blame] | 1108 | if strings.Contains(name, "CanvasKit") || strings.Contains(name, "Emulator") || strings.Contains(name, "LottieWeb") || strings.Contains(name, "PathKit") { |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 1109 | isolate = "swarm_recipe.isolate" |
| 1110 | } |
| 1111 | task := kitchenTask(name, recipe, isolate, "", swarmDimensions(parts), extraProps, OUTPUT_TEST) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1112 | task.CipdPackages = append(task.CipdPackages, pkgs...) |
Eric Boren | 8c172ba | 2018-07-19 13:27:49 -0400 | [diff] [blame] | 1113 | if strings.Contains(name, "Lottie") { |
| 1114 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("lottie-samples")) |
| 1115 | } |
Kevin Lubick | 82999c0 | 2018-08-28 10:52:18 -0400 | [diff] [blame] | 1116 | if !strings.Contains(name, "LottieWeb") { |
| 1117 | // Test.+LottieWeb doesn't require anything in Skia to be compiled. |
| 1118 | task.Dependencies = append(task.Dependencies, compileTaskName) |
| 1119 | } |
| 1120 | |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1121 | if strings.Contains(name, "Android_ASAN") { |
| 1122 | task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_NDK_LINUX_NAME)) |
Eric Boren | 9d78afd | 2017-12-07 14:54:05 +0000 | [diff] [blame] | 1123 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1124 | if strings.Contains(name, "SKQP") { |
Kevin Lubick | 35b87a5 | 2018-10-08 15:07:42 -0400 | [diff] [blame] | 1125 | if !strings.Contains(name, "Emulator") { |
| 1126 | task.Dependencies = append(task.Dependencies, isolateCIPDAsset(b, ISOLATE_GCLOUD_LINUX_NAME)) |
| 1127 | } |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 1128 | } |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 1129 | if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1130 | task.Dependencies = append(task.Dependencies, deps...) |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1131 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1132 | task.Expiration = 20 * time.Hour |
Ben Wagner | 73e2ced | 2018-12-17 12:44:30 -0500 | [diff] [blame] | 1133 | |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1134 | timeout(task, 4*time.Hour) |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1135 | if strings.Contains(parts["extra_config"], "Valgrind") { |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1136 | timeout(task, 9*time.Hour) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1137 | task.Expiration = 48 * time.Hour |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1138 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind")) |
| 1139 | task.Dimensions = append(task.Dimensions, "valgrind:1") |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1140 | } else if strings.Contains(parts["extra_config"], "MSAN") { |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1141 | timeout(task, 9*time.Hour) |
Ben Wagner | a6b2ba2 | 2017-06-08 10:34:17 -0400 | [diff] [blame] | 1142 | } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" { |
| 1143 | // skia:6737 |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1144 | timeout(task, 6*time.Hour) |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1145 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1146 | b.MustAddTask(name, task) |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1147 | |
Kevin Lubick | c795a4c | 2017-10-09 15:26:19 -0400 | [diff] [blame] | 1148 | // Upload results if necessary. TODO(kjlubick): If we do coverage analysis at the same |
| 1149 | // 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] | 1150 | if doUpload(name) { |
| 1151 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1152 | extraProps := map[string]string{ |
| 1153 | "gs_bucket": CONFIG.GsBucketGm, |
| 1154 | } |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 1155 | uploadTask := kitchenTask(name, "upload_dm_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_GM, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1156 | uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...) |
| 1157 | uploadTask.Dependencies = append(uploadTask.Dependencies, name) |
| 1158 | b.MustAddTask(uploadName, uploadTask) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1159 | return uploadName |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | return name |
| 1163 | } |
| 1164 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1165 | // perf generates a Perf task. Returns the name of the last task in the |
| 1166 | // generated chain of tasks, which the Job should add as a dependency. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1167 | 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] | 1168 | recipe := "perf" |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1169 | isolate := relpath("perf_skia_bundled.isolate") |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 1170 | if strings.Contains(parts["extra_config"], "Skpbench") { |
Eric Boren | 768f52f | 2017-04-10 08:14:33 -0400 | [diff] [blame] | 1171 | recipe = "skpbench" |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1172 | isolate = relpath("skpbench_skia_bundled.isolate") |
Kevin Lubick | 556350d | 2018-10-12 15:21:17 -0400 | [diff] [blame] | 1173 | } else if strings.Contains(name, "PathKit") { |
| 1174 | recipe = "perf_pathkit" |
Kevin Lubick | f2a146c | 2018-10-17 14:59:35 -0400 | [diff] [blame] | 1175 | } else if strings.Contains(name, "CanvasKit") { |
| 1176 | recipe = "perf_canvaskit" |
Kevin Lubick | b03b5ac | 2016-11-14 13:42:27 -0500 | [diff] [blame] | 1177 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1178 | task := kitchenTask(name, recipe, isolate, "", swarmDimensions(parts), nil, OUTPUT_PERF) |
| 1179 | task.CipdPackages = append(task.CipdPackages, pkgs...) |
| 1180 | task.Dependencies = append(task.Dependencies, compileTaskName) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1181 | task.Expiration = 20 * time.Hour |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1182 | timeout(task, 4*time.Hour) |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 1183 | if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1184 | task.Dependencies = append(task.Dependencies, deps...) |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 1185 | } |
| 1186 | |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1187 | if strings.Contains(parts["extra_config"], "Valgrind") { |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1188 | timeout(task, 9*time.Hour) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1189 | task.Expiration = 48 * time.Hour |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1190 | task.CipdPackages = append(task.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind")) |
| 1191 | task.Dimensions = append(task.Dimensions, "valgrind:1") |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1192 | } else if strings.Contains(parts["extra_config"], "MSAN") { |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1193 | timeout(task, 9*time.Hour) |
Ben Wagner | a6b2ba2 | 2017-06-08 10:34:17 -0400 | [diff] [blame] | 1194 | } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" { |
| 1195 | // skia:6737 |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1196 | timeout(task, 6*time.Hour) |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1197 | } |
Eric Boren | fd4d60e | 2017-09-15 10:35:44 -0400 | [diff] [blame] | 1198 | iid := internalHardwareLabel(parts) |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 1199 | if iid != nil { |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1200 | task.Command = append(task.Command, fmt.Sprintf("internal_hardware_label=%d", *iid)) |
Eric Boren | 053d7a4 | 2017-09-15 08:35:31 -0400 | [diff] [blame] | 1201 | } |
Kevin Lubick | de1a1a2 | 2018-10-01 10:07:42 -0400 | [diff] [blame] | 1202 | if parts["cpu_or_gpu_value"] == "QuadroP400" { |
| 1203 | // Specify "rack" dimension for consistent test results. |
| 1204 | // See https://bugs.chromium.org/p/chromium/issues/detail?id=784662&desc=2#c34 |
| 1205 | // for more context. |
Ben Wagner | 2aa9a22 | 2018-11-06 13:45:40 -0500 | [diff] [blame] | 1206 | if parts["os"] == "Ubuntu18" { |
| 1207 | task.Dimensions = append(task.Dimensions, "rack:2") |
| 1208 | } else { |
| 1209 | task.Dimensions = append(task.Dimensions, "rack:1") |
| 1210 | } |
Kevin Lubick | de1a1a2 | 2018-10-01 10:07:42 -0400 | [diff] [blame] | 1211 | } |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1212 | b.MustAddTask(name, task) |
Eric Boren | 4b254b9 | 2016-11-08 12:55:32 -0500 | [diff] [blame] | 1213 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1214 | // Upload results if necessary. |
| 1215 | if strings.Contains(name, "Release") && doUpload(name) { |
| 1216 | uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1217 | extraProps := map[string]string{ |
| 1218 | "gs_bucket": CONFIG.GsBucketNano, |
| 1219 | } |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 1220 | uploadTask := kitchenTask(name, "upload_nano_results", "swarm_recipe.isolate", SERVICE_ACCOUNT_UPLOAD_NANO, linuxGceDimensions(MACHINE_TYPE_SMALL), extraProps, OUTPUT_NONE) |
Eric Boren | 9599b0f | 2018-04-17 15:55:57 -0400 | [diff] [blame] | 1221 | uploadTask.CipdPackages = append(uploadTask.CipdPackages, CIPD_PKGS_GSUTIL...) |
| 1222 | uploadTask.Dependencies = append(uploadTask.Dependencies, name) |
| 1223 | b.MustAddTask(uploadName, uploadTask) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1224 | return uploadName |
| 1225 | } |
| 1226 | return name |
| 1227 | } |
| 1228 | |
Eric Boren | b66099b | 2018-04-25 15:09:22 -0400 | [diff] [blame] | 1229 | // Run the presubmit. |
| 1230 | func presubmit(b *specs.TasksCfgBuilder, name string) string { |
| 1231 | extraProps := map[string]string{ |
| 1232 | "category": "cq", |
| 1233 | "patch_gerrit_url": "https://skia-review.googlesource.com", |
| 1234 | "patch_project": "skia", |
Eric Boren | 2f62de0 | 2018-05-03 09:56:48 -0400 | [diff] [blame] | 1235 | "patch_ref": specs.PLACEHOLDER_PATCH_REF, |
Eric Boren | b66099b | 2018-04-25 15:09:22 -0400 | [diff] [blame] | 1236 | "reason": "CQ", |
| 1237 | "repo_name": "skia", |
| 1238 | } |
Ben Wagner | 297e86b | 2018-05-14 12:38:09 -0400 | [diff] [blame] | 1239 | // Use MACHINE_TYPE_LARGE because it seems to save time versus MEDIUM and we want presubmit to be |
| 1240 | // fast. |
Ben Wagner | e99a4b1 | 2018-05-04 11:18:01 -0400 | [diff] [blame] | 1241 | task := kitchenTask(name, "run_presubmit", "empty.isolate", SERVICE_ACCOUNT_COMPILE, linuxGceDimensions(MACHINE_TYPE_LARGE), extraProps, OUTPUT_NONE) |
Eric Boren | b66099b | 2018-04-25 15:09:22 -0400 | [diff] [blame] | 1242 | |
| 1243 | replaceArg := func(key, value string) { |
| 1244 | found := false |
| 1245 | for idx, arg := range task.Command { |
| 1246 | if arg == key { |
| 1247 | task.Command[idx+1] = value |
| 1248 | found = true |
| 1249 | } |
| 1250 | } |
| 1251 | if !found { |
| 1252 | task.Command = append(task.Command, key, value) |
| 1253 | } |
| 1254 | } |
| 1255 | replaceArg("-repository", "https://chromium.googlesource.com/chromium/tools/build") |
| 1256 | replaceArg("-revision", "HEAD") |
Eric Boren | 5cb5c74 | 2018-04-27 13:14:38 -0400 | [diff] [blame] | 1257 | usesGit(task, name) |
Eric Boren | b66099b | 2018-04-25 15:09:22 -0400 | [diff] [blame] | 1258 | task.Dependencies = []string{} // No bundled recipes for this one. |
| 1259 | b.MustAddTask(name, task) |
| 1260 | return name |
| 1261 | } |
| 1262 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1263 | // process generates tasks and jobs for the given job name. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1264 | func process(b *specs.TasksCfgBuilder, name string) { |
Ben Wagner | c062b6b | 2018-07-24 17:10:46 -0400 | [diff] [blame] | 1265 | var priority float64 // Leave as default for most jobs. |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1266 | deps := []string{} |
| 1267 | |
Eric Boren | 8b3f9e6 | 2017-04-04 09:06:16 -0400 | [diff] [blame] | 1268 | // Bundle Recipes. |
| 1269 | if name == BUNDLE_RECIPES_NAME { |
| 1270 | deps = append(deps, bundleRecipes(b)) |
| 1271 | } |
| 1272 | |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1273 | // Isolate CIPD assets. |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1274 | if _, ok := ISOLATE_ASSET_MAPPING[name]; ok { |
| 1275 | deps = append(deps, isolateCIPDAsset(b, name)) |
| 1276 | } |
| 1277 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1278 | parts, err := jobNameSchema.ParseJobName(name) |
| 1279 | if err != nil { |
| 1280 | glog.Fatal(err) |
| 1281 | } |
| 1282 | |
| 1283 | // RecreateSKPs. |
| 1284 | if strings.Contains(name, "RecreateSKPs") { |
Eric Boren | 2768861 | 2018-04-16 13:21:01 +0000 | [diff] [blame] | 1285 | deps = append(deps, recreateSKPs(b, name)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1286 | } |
| 1287 | |
Eric Boren | 84ae641 | 2018-09-27 14:55:03 -0400 | [diff] [blame] | 1288 | // Update Go DEPS. |
| 1289 | if strings.Contains(name, "UpdateGoDEPS") { |
| 1290 | deps = append(deps, updateGoDEPS(b, name)) |
| 1291 | } |
| 1292 | |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 1293 | // Infra tests. |
| 1294 | if name == "Housekeeper-PerCommit-InfraTests" { |
Eric Boren | 2768861 | 2018-04-16 13:21:01 +0000 | [diff] [blame] | 1295 | deps = append(deps, infra(b, name)) |
borenet | 2dbbfa5 | 2016-10-14 06:32:09 -0700 | [diff] [blame] | 1296 | } |
| 1297 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1298 | // Compile bots. |
| 1299 | if parts["role"] == "Build" { |
Ravi Mistry | 5e96742 | 2018-02-01 13:38:13 -0500 | [diff] [blame] | 1300 | if parts["extra_config"] == "Android_Framework" { |
| 1301 | // Android Framework compile tasks use a different recipe. |
| 1302 | deps = append(deps, androidFrameworkCompile(b, name)) |
| 1303 | } else { |
| 1304 | deps = append(deps, compile(b, name, parts)) |
| 1305 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1306 | } |
| 1307 | |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 1308 | // Most remaining bots need a compile task. |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1309 | compileTaskName := deriveCompileTaskName(name, parts) |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 1310 | compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName) |
| 1311 | if err != nil { |
| 1312 | glog.Fatal(err) |
| 1313 | } |
Yuqian Li | 4a577af | 2018-01-05 11:13:43 -0500 | [diff] [blame] | 1314 | compileParentName := getParentRevisionName(compileTaskName, compileTaskParts) |
| 1315 | compileParentParts, err := jobNameSchema.ParseJobName(compileParentName) |
| 1316 | if err != nil { |
| 1317 | glog.Fatal(err) |
| 1318 | } |
| 1319 | |
Eric Boren | 628e78b | 2016-11-17 11:33:27 -0500 | [diff] [blame] | 1320 | // These bots do not need a compile task. |
Yuqian Li | 4a577af | 2018-01-05 11:13:43 -0500 | [diff] [blame] | 1321 | if parts["role"] != "Build" && |
Eric Boren | 84ae641 | 2018-09-27 14:55:03 -0400 | [diff] [blame] | 1322 | name != "Housekeeper-Nightly-UpdateGoDEPS" && |
Eric Boren | b8ab7f7 | 2017-04-10 11:00:09 -0400 | [diff] [blame] | 1323 | name != "Housekeeper-PerCommit-BundleRecipes" && |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 1324 | name != "Housekeeper-PerCommit-InfraTests" && |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 1325 | name != "Housekeeper-PerCommit-CheckGeneratedFiles" && |
Eric Boren | b66099b | 2018-04-25 15:09:22 -0400 | [diff] [blame] | 1326 | name != "Housekeeper-OnDemand-Presubmit" && |
Kevin Lubick | 37baac1 | 2018-10-09 16:25:27 -0400 | [diff] [blame] | 1327 | name != "Housekeeper-PerCommit" && |
Ravi Mistry | 5e96742 | 2018-02-01 13:38:13 -0500 | [diff] [blame] | 1328 | !strings.Contains(name, "Android_Framework") && |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 1329 | !strings.Contains(name, "RecreateSKPs") && |
Kevin Lubick | 82999c0 | 2018-08-28 10:52:18 -0400 | [diff] [blame] | 1330 | !strings.Contains(name, "Housekeeper-PerCommit-Isolate") && |
| 1331 | !strings.Contains(name, "LottieWeb") { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1332 | compile(b, compileTaskName, compileTaskParts) |
Ben Wagner | 4c39c0d | 2018-01-10 11:14:52 -0500 | [diff] [blame] | 1333 | if parts["role"] == "Calmbench" { |
Yuqian Li | 4a577af | 2018-01-05 11:13:43 -0500 | [diff] [blame] | 1334 | compile(b, compileParentName, compileParentParts) |
| 1335 | } |
borenet | 5238343 | 2016-10-17 10:17:53 -0700 | [diff] [blame] | 1336 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1337 | |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 1338 | // Housekeepers. |
Eric Boren | 22f5ef7 | 2016-12-02 11:01:33 -0500 | [diff] [blame] | 1339 | if name == "Housekeeper-PerCommit" { |
Kevin Lubick | 37baac1 | 2018-10-09 16:25:27 -0400 | [diff] [blame] | 1340 | deps = append(deps, housekeeper(b, name)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1341 | } |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 1342 | if name == "Housekeeper-PerCommit-CheckGeneratedFiles" { |
Eric Boren | 2768861 | 2018-04-16 13:21:01 +0000 | [diff] [blame] | 1343 | deps = append(deps, checkGeneratedFiles(b, name)) |
Eric Boren | f7928b4 | 2017-07-28 07:35:28 -0400 | [diff] [blame] | 1344 | } |
Eric Boren | b66099b | 2018-04-25 15:09:22 -0400 | [diff] [blame] | 1345 | if name == "Housekeeper-OnDemand-Presubmit" { |
Ben Wagner | c062b6b | 2018-07-24 17:10:46 -0400 | [diff] [blame] | 1346 | priority = 1 |
Eric Boren | b66099b | 2018-04-25 15:09:22 -0400 | [diff] [blame] | 1347 | deps = append(deps, presubmit(b, name)) |
| 1348 | } |
Ravi Mistry | d4731e9 | 2018-01-02 14:54:43 -0500 | [diff] [blame] | 1349 | if strings.Contains(name, "Bookmaker") { |
Ravi Mistry | edc4f3e | 2017-12-08 12:58:20 -0500 | [diff] [blame] | 1350 | deps = append(deps, bookmaker(b, name, compileTaskName)) |
| 1351 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1352 | |
| 1353 | // Common assets needed by the remaining bots. |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1354 | |
| 1355 | pkgs := []*specs.CipdPackage{} |
| 1356 | |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 1357 | if deps := getIsolatedCIPDDeps(parts); len(deps) == 0 { |
Kevin Lubick | 0707294 | 2017-05-11 13:35:23 -0400 | [diff] [blame] | 1358 | pkgs = []*specs.CipdPackage{ |
| 1359 | b.MustGetCipdPackageFromAsset("skimage"), |
| 1360 | b.MustGetCipdPackageFromAsset("skp"), |
| 1361 | b.MustGetCipdPackageFromAsset("svg"), |
| 1362 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1363 | } |
Kevin Lubick | 9018952 | 2017-05-15 08:30:27 -0400 | [diff] [blame] | 1364 | |
Ben Wagner | 5655ba4 | 2017-10-02 10:48:32 -0400 | [diff] [blame] | 1365 | if strings.Contains(name, "Ubuntu") || strings.Contains(name, "Debian") { |
| 1366 | if strings.Contains(name, "SAN") { |
| 1367 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux")) |
| 1368 | } |
Kevin Lubick | 35115eb | 2017-02-17 10:25:34 -0500 | [diff] [blame] | 1369 | if strings.Contains(name, "Vulkan") { |
| 1370 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk")) |
| 1371 | } |
Ben Wagner | 5655ba4 | 2017-10-02 10:48:32 -0400 | [diff] [blame] | 1372 | if strings.Contains(name, "Intel") && strings.Contains(name, "GPU") { |
Kevin Lubick | 1b5ece0 | 2018-09-11 17:09:28 -0400 | [diff] [blame] | 1373 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("mesa_intel_driver_linux")) |
Kevin Lubick | 0a51b48 | 2017-02-06 12:45:29 -0500 | [diff] [blame] | 1374 | } |
Ben Wagner | a5e7030 | 2018-06-28 17:43:08 -0400 | [diff] [blame] | 1375 | if strings.Contains(name, "OpenCL") { |
| 1376 | pkgs = append(pkgs, |
| 1377 | b.MustGetCipdPackageFromAsset("opencl_ocl_icd_linux"), |
| 1378 | b.MustGetCipdPackageFromAsset("opencl_intel_neo_linux"), |
| 1379 | ) |
| 1380 | } |
Kevin Lubick | 0a51b48 | 2017-02-06 12:45:29 -0500 | [diff] [blame] | 1381 | } |
Ben Wagner | 299b882 | 2018-03-09 13:42:56 -0500 | [diff] [blame] | 1382 | if strings.Contains(name, "ProcDump") { |
| 1383 | pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("procdump_win")) |
| 1384 | } |
Kevin Lubick | 8e9750d | 2018-10-09 09:36:35 -0400 | [diff] [blame] | 1385 | if strings.Contains(name, "CanvasKit") || strings.Contains(name, "LottieWeb") || strings.Contains(name, "PathKit") { |
Kevin Lubick | 82999c0 | 2018-08-28 10:52:18 -0400 | [diff] [blame] | 1386 | // Docker-based tests that don't need the standard CIPD assets |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 1387 | pkgs = []*specs.CipdPackage{} |
| 1388 | } |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1389 | |
| 1390 | // Test bots. |
Kevin Lubick | 32f318b | 2017-10-17 13:40:52 -0400 | [diff] [blame] | 1391 | if parts["role"] == "Test" { |
Ravi Mistry | eea245c | 2018-10-09 10:31:11 -0400 | [diff] [blame] | 1392 | deps = append(deps, test(b, name, parts, compileTaskName, pkgs)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1393 | } |
| 1394 | |
| 1395 | // Perf bots. |
Ravi Mistry | eea245c | 2018-10-09 10:31:11 -0400 | [diff] [blame] | 1396 | if parts["role"] == "Perf" { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1397 | deps = append(deps, perf(b, name, parts, compileTaskName, pkgs)) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1398 | } |
| 1399 | |
Yuqian Li | 4a577af | 2018-01-05 11:13:43 -0500 | [diff] [blame] | 1400 | // Calmbench bots. |
| 1401 | if parts["role"] == "Calmbench" { |
| 1402 | deps = append(deps, calmbench(b, name, parts, compileTaskName, compileParentName)) |
| 1403 | } |
| 1404 | |
Kevin Lubick | 4968843 | 2018-10-08 13:58:47 -0400 | [diff] [blame] | 1405 | // BuildStats bots. This computes things like binary size. |
| 1406 | if parts["role"] == "BuildStats" { |
| 1407 | deps = append(deps, buildstats(b, name, parts, compileTaskName)) |
| 1408 | } |
| 1409 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1410 | // Add the Job spec. |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 1411 | j := &specs.JobSpec{ |
Ben Wagner | c062b6b | 2018-07-24 17:10:46 -0400 | [diff] [blame] | 1412 | Priority: priority, |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1413 | TaskSpecs: deps, |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 1414 | Trigger: specs.TRIGGER_ANY_BRANCH, |
Eric Boren | f5a90e8 | 2016-11-15 15:18:20 -0500 | [diff] [blame] | 1415 | } |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 1416 | if strings.Contains(name, "-Nightly-") { |
| 1417 | j.Trigger = specs.TRIGGER_NIGHTLY |
Ravi Mistry | eea245c | 2018-10-09 10:31:11 -0400 | [diff] [blame] | 1418 | } else if strings.Contains(name, "-Weekly-") { |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 1419 | j.Trigger = specs.TRIGGER_WEEKLY |
Eric Boren | 44a68b3 | 2018-05-04 08:59:16 -0400 | [diff] [blame] | 1420 | } else if strings.Contains(name, "Flutter") || strings.Contains(name, "CommandBuffer") { |
Eric Boren | ba937a4 | 2017-07-31 10:41:15 -0400 | [diff] [blame] | 1421 | j.Trigger = specs.TRIGGER_MASTER_ONLY |
Eric Boren | 1178ea0 | 2018-04-26 08:58:26 -0400 | [diff] [blame] | 1422 | } else if strings.Contains(name, "-OnDemand-") || strings.Contains(name, "Android_Framework") { |
Eric Boren | b66099b | 2018-04-25 15:09:22 -0400 | [diff] [blame] | 1423 | j.Trigger = specs.TRIGGER_ON_DEMAND |
Eric Boren | 71b762f | 2016-11-30 14:05:16 -0500 | [diff] [blame] | 1424 | } |
Eric Boren | 8615fe5 | 2016-12-12 14:30:12 -0500 | [diff] [blame] | 1425 | b.MustAddJob(name, j) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1426 | } |
| 1427 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 1428 | func loadJson(flag *string, defaultFlag string, val interface{}) { |
| 1429 | if *flag == "" { |
| 1430 | *flag = defaultFlag |
| 1431 | } |
| 1432 | b, err := ioutil.ReadFile(*flag) |
| 1433 | if err != nil { |
| 1434 | glog.Fatal(err) |
| 1435 | } |
| 1436 | if err := json.Unmarshal(b, val); err != nil { |
| 1437 | glog.Fatal(err) |
| 1438 | } |
| 1439 | } |
| 1440 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1441 | // Regenerate the tasks.json file. |
| 1442 | func main() { |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1443 | b := specs.MustNewTasksCfgBuilder() |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 1444 | b.SetAssetsDir(*assetsDir) |
| 1445 | infraBots := path.Join(b.CheckoutRoot(), "infra", "bots") |
| 1446 | |
| 1447 | // Load the jobs from a JSON file. |
| 1448 | loadJson(jobsFile, path.Join(infraBots, "jobs.json"), &JOBS) |
| 1449 | |
Eric Boren | 2722549 | 2017-02-01 15:56:55 -0500 | [diff] [blame] | 1450 | // Load general config information from a JSON file. |
| 1451 | loadJson(cfgFile, path.Join(infraBots, "cfg.json"), &CONFIG) |
| 1452 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1453 | // Create the JobNameSchema. |
Eric Boren | 1f8be68 | 2017-02-07 09:16:30 -0500 | [diff] [blame] | 1454 | if *builderNameSchemaFile == "" { |
| 1455 | *builderNameSchemaFile = path.Join(b.CheckoutRoot(), "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json") |
| 1456 | } |
| 1457 | schema, err := NewJobNameSchema(*builderNameSchemaFile) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1458 | if err != nil { |
| 1459 | glog.Fatal(err) |
| 1460 | } |
| 1461 | jobNameSchema = schema |
| 1462 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1463 | // Create Tasks and Jobs. |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1464 | for _, name := range JOBS { |
| 1465 | process(b, name) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1466 | } |
| 1467 | |
borenet | ed20a70 | 2016-10-20 11:04:31 -0700 | [diff] [blame] | 1468 | b.MustFinish() |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1469 | } |
| 1470 | |
| 1471 | // TODO(borenet): The below really belongs in its own file, probably next to the |
| 1472 | // builder_name_schema.json file. |
| 1473 | |
Eric Boren | 8ff86a6 | 2018-04-17 14:11:23 -0400 | [diff] [blame] | 1474 | // schema is a sub-struct of JobNameSchema. |
| 1475 | type schema struct { |
| 1476 | Keys []string `json:"keys"` |
| 1477 | OptionalKeys []string `json:"optional_keys"` |
| 1478 | RecurseRoles []string `json:"recurse_roles"` |
| 1479 | } |
| 1480 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1481 | // JobNameSchema is a struct used for (de)constructing Job names in a |
| 1482 | // predictable format. |
| 1483 | type JobNameSchema struct { |
Eric Boren | 8ff86a6 | 2018-04-17 14:11:23 -0400 | [diff] [blame] | 1484 | Schema map[string]*schema `json:"builder_name_schema"` |
| 1485 | Sep string `json:"builder_name_sep"` |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1486 | } |
| 1487 | |
| 1488 | // NewJobNameSchema returns a JobNameSchema instance based on the given JSON |
| 1489 | // file. |
| 1490 | func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) { |
| 1491 | var rv JobNameSchema |
| 1492 | f, err := os.Open(jsonFile) |
| 1493 | if err != nil { |
| 1494 | return nil, err |
| 1495 | } |
| 1496 | defer util.Close(f) |
| 1497 | if err := json.NewDecoder(f).Decode(&rv); err != nil { |
| 1498 | return nil, err |
| 1499 | } |
| 1500 | return &rv, nil |
| 1501 | } |
| 1502 | |
| 1503 | // ParseJobName splits the given Job name into its component parts, according |
| 1504 | // to the schema. |
| 1505 | func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) { |
Eric Boren | 8ff86a6 | 2018-04-17 14:11:23 -0400 | [diff] [blame] | 1506 | popFront := func(items []string) (string, []string, error) { |
| 1507 | if len(items) == 0 { |
| 1508 | return "", nil, fmt.Errorf("Invalid job name: %s (not enough parts)", n) |
| 1509 | } |
| 1510 | return items[0], items[1:], nil |
| 1511 | } |
| 1512 | |
| 1513 | result := map[string]string{} |
| 1514 | |
| 1515 | var parse func(int, string, []string) ([]string, error) |
| 1516 | parse = func(depth int, role string, parts []string) ([]string, error) { |
| 1517 | s, ok := s.Schema[role] |
| 1518 | if !ok { |
| 1519 | return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role) |
| 1520 | } |
| 1521 | if depth == 0 { |
| 1522 | result["role"] = role |
| 1523 | } else { |
| 1524 | result[fmt.Sprintf("sub-role-%d", depth)] = role |
| 1525 | } |
| 1526 | var err error |
| 1527 | for _, key := range s.Keys { |
| 1528 | var value string |
| 1529 | value, parts, err = popFront(parts) |
| 1530 | if err != nil { |
| 1531 | return nil, err |
| 1532 | } |
| 1533 | result[key] = value |
| 1534 | } |
| 1535 | for _, subRole := range s.RecurseRoles { |
| 1536 | if len(parts) > 0 && parts[0] == subRole { |
| 1537 | parts, err = parse(depth+1, parts[0], parts[1:]) |
| 1538 | if err != nil { |
| 1539 | return nil, err |
| 1540 | } |
| 1541 | } |
| 1542 | } |
| 1543 | for _, key := range s.OptionalKeys { |
| 1544 | if len(parts) > 0 { |
| 1545 | var value string |
| 1546 | value, parts, err = popFront(parts) |
| 1547 | if err != nil { |
| 1548 | return nil, err |
| 1549 | } |
| 1550 | result[key] = value |
| 1551 | } |
| 1552 | } |
| 1553 | if len(parts) > 0 { |
| 1554 | return nil, fmt.Errorf("Invalid job name: %s (too many parts)", n) |
| 1555 | } |
| 1556 | return parts, nil |
| 1557 | } |
| 1558 | |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1559 | split := strings.Split(n, s.Sep) |
| 1560 | if len(split) < 2 { |
Eric Boren | 8ff86a6 | 2018-04-17 14:11:23 -0400 | [diff] [blame] | 1561 | return nil, fmt.Errorf("Invalid job name: %s (not enough parts)", n) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1562 | } |
| 1563 | role := split[0] |
| 1564 | split = split[1:] |
Eric Boren | 8ff86a6 | 2018-04-17 14:11:23 -0400 | [diff] [blame] | 1565 | _, err := parse(0, role, split) |
| 1566 | return result, err |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1567 | } |
| 1568 | |
| 1569 | // MakeJobName assembles the given parts of a Job name, according to the schema. |
| 1570 | func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) { |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1571 | rvParts := make([]string, 0, len(parts)) |
Eric Boren | 8ff86a6 | 2018-04-17 14:11:23 -0400 | [diff] [blame] | 1572 | |
| 1573 | var process func(int, map[string]string) (map[string]string, error) |
| 1574 | process = func(depth int, parts map[string]string) (map[string]string, error) { |
| 1575 | roleKey := "role" |
| 1576 | if depth != 0 { |
| 1577 | roleKey = fmt.Sprintf("sub-role-%d", depth) |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1578 | } |
Eric Boren | 8ff86a6 | 2018-04-17 14:11:23 -0400 | [diff] [blame] | 1579 | role, ok := parts[roleKey] |
| 1580 | if !ok { |
| 1581 | return nil, fmt.Errorf("Invalid job parts; missing key %q", roleKey) |
| 1582 | } |
| 1583 | |
| 1584 | s, ok := s.Schema[role] |
| 1585 | if !ok { |
| 1586 | return nil, fmt.Errorf("Invalid job parts; unknown role %q", role) |
| 1587 | } |
| 1588 | rvParts = append(rvParts, role) |
| 1589 | delete(parts, roleKey) |
| 1590 | |
| 1591 | for _, key := range s.Keys { |
| 1592 | value, ok := parts[key] |
| 1593 | if !ok { |
| 1594 | return nil, fmt.Errorf("Invalid job parts; missing %q", key) |
| 1595 | } |
| 1596 | rvParts = append(rvParts, value) |
| 1597 | delete(parts, key) |
| 1598 | } |
| 1599 | |
| 1600 | if len(s.RecurseRoles) > 0 { |
| 1601 | subRoleKey := fmt.Sprintf("sub-role-%d", depth+1) |
| 1602 | subRole, ok := parts[subRoleKey] |
| 1603 | if !ok { |
| 1604 | return nil, fmt.Errorf("Invalid job parts; missing %q", subRoleKey) |
| 1605 | } |
| 1606 | rvParts = append(rvParts, subRole) |
| 1607 | delete(parts, subRoleKey) |
| 1608 | found := false |
| 1609 | for _, recurseRole := range s.RecurseRoles { |
| 1610 | if recurseRole == subRole { |
| 1611 | found = true |
| 1612 | var err error |
| 1613 | parts, err = process(depth+1, parts) |
| 1614 | if err != nil { |
| 1615 | return nil, err |
| 1616 | } |
| 1617 | break |
| 1618 | } |
| 1619 | } |
| 1620 | if !found { |
| 1621 | return nil, fmt.Errorf("Invalid job parts; unknown sub-role %q", subRole) |
| 1622 | } |
| 1623 | } |
| 1624 | for _, key := range s.OptionalKeys { |
| 1625 | if value, ok := parts[key]; ok { |
| 1626 | rvParts = append(rvParts, value) |
| 1627 | delete(parts, key) |
| 1628 | } |
| 1629 | } |
| 1630 | if len(parts) > 0 { |
| 1631 | return nil, fmt.Errorf("Invalid job parts: too many parts: %v", parts) |
| 1632 | } |
| 1633 | return parts, nil |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1634 | } |
Eric Boren | 8ff86a6 | 2018-04-17 14:11:23 -0400 | [diff] [blame] | 1635 | |
| 1636 | // Copy the parts map, so that we can modify at will. |
| 1637 | partsCpy := make(map[string]string, len(parts)) |
| 1638 | for k, v := range parts { |
| 1639 | partsCpy[k] = v |
| 1640 | } |
| 1641 | if _, err := process(0, partsCpy); err != nil { |
| 1642 | return "", err |
borenet | db182c7 | 2016-09-30 12:53:12 -0700 | [diff] [blame] | 1643 | } |
| 1644 | return strings.Join(rvParts, s.Sep), nil |
| 1645 | } |