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