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