blob: 1c7749eef82ddedecdcc5a2f1db24d2f112035b3 [file] [log] [blame]
borenetdb182c72016-09-30 12:53:12 -07001// 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
5package main
6
7/*
8 Generate the tasks.json file.
9*/
10
11import (
borenetdb182c72016-09-30 12:53:12 -070012 "encoding/json"
Eric Boren27225492017-02-01 15:56:55 -050013 "flag"
borenetdb182c72016-09-30 12:53:12 -070014 "fmt"
Eric Boren27225492017-02-01 15:56:55 -050015 "io/ioutil"
borenetdb182c72016-09-30 12:53:12 -070016 "os"
17 "path"
Eric Boren7e3a3642017-06-14 15:25:31 -040018 "path/filepath"
Eric Boren27225492017-02-01 15:56:55 -050019 "regexp"
Eric Boren7e3a3642017-06-14 15:25:31 -040020 "runtime"
borenetdb182c72016-09-30 12:53:12 -070021 "sort"
Kevin Lubick32f318b2017-10-17 13:40:52 -040022 "strconv"
borenetdb182c72016-09-30 12:53:12 -070023 "strings"
Eric Boren4b254b92016-11-08 12:55:32 -050024 "time"
borenetdb182c72016-09-30 12:53:12 -070025
26 "github.com/skia-dev/glog"
Eric Boren7e3a3642017-06-14 15:25:31 -040027 "go.skia.org/infra/go/sklog"
borenetdb182c72016-09-30 12:53:12 -070028 "go.skia.org/infra/go/util"
29 "go.skia.org/infra/task_scheduler/go/specs"
30)
31
32const (
Kevin Lubick814b1492017-11-29 14:45:14 -050033 BUNDLE_RECIPES_NAME = "Housekeeper-PerCommit-BundleRecipes"
34 ISOLATE_SKIMAGE_NAME = "Housekeeper-PerCommit-IsolateSkImage"
35 ISOLATE_SKP_NAME = "Housekeeper-PerCommit-IsolateSKP"
36 ISOLATE_SVG_NAME = "Housekeeper-PerCommit-IsolateSVG"
37 ISOLATE_NDK_LINUX_NAME = "Housekeeper-PerCommit-IsolateAndroidNDKLinux"
38 ISOLATE_WIN_TOOLCHAIN_NAME = "Housekeeper-PerCommit-IsolateWinToolchain"
39 ISOLATE_WIN_VULKAN_SDK_NAME = "Housekeeper-PerCommit-IsolateWinVulkanSDK"
Eric Boren8b3f9e62017-04-04 09:06:16 -040040
Eric Boren170c39c2017-11-15 11:22:57 -050041 DEFAULT_OS_DEBIAN = "Debian-9.1"
42 DEFAULT_OS_LINUX_GCE = "Debian-9.2"
Ben Wagner5a9df182018-02-09 11:21:15 -050043 DEFAULT_OS_MAC = "Mac-10.13.3"
Eric Boren170c39c2017-11-15 11:22:57 -050044 DEFAULT_OS_UBUNTU = "Ubuntu-14.04"
45 DEFAULT_OS_WIN = "Windows-2016Server-14393"
borenetdb182c72016-09-30 12:53:12 -070046
borenetdb182c72016-09-30 12:53:12 -070047 // Name prefix for upload jobs.
48 PREFIX_UPLOAD = "Upload"
49)
50
51var (
52 // "Constants"
53
Eric Boren27225492017-02-01 15:56:55 -050054 // Top-level list of all jobs to run at each commit; loaded from
55 // jobs.json.
56 JOBS []string
57
Eric Boren27225492017-02-01 15:56:55 -050058 // General configuration information.
59 CONFIG struct {
Kevin Lubickc795a4c2017-10-09 15:26:19 -040060 GsBucketCoverage string `json:"gs_bucket_coverage"`
61 GsBucketGm string `json:"gs_bucket_gm"`
62 GsBucketNano string `json:"gs_bucket_nano"`
Yuqian Li2ebf3d12017-10-24 09:43:21 -040063 GsBucketCalm string `json:"gs_bucket_calm"`
Kevin Lubickc795a4c2017-10-09 15:26:19 -040064 NoUpload []string `json:"no_upload"`
65 Pool string `json:"pool"`
borenetdb182c72016-09-30 12:53:12 -070066 }
67
Ben Wagner3d2a2f72017-06-13 17:01:16 -040068 // alternateSwarmDimensions can be set in an init function to override the default swarming bot
69 // dimensions for the given task.
70 alternateSwarmDimensions func(parts map[string]string) []string
71
Eric Borenfd4d60e2017-09-15 10:35:44 -040072 // internalHardwareLabelFn can be set in an init function to provide an
73 // internal_hardware_label variable to the recipe.
Eric Boren4dc4aaf2017-09-15 14:09:07 -040074 internalHardwareLabelFn func(parts map[string]string) *int
Eric Boren053d7a42017-09-15 08:35:31 -040075
borenetdb182c72016-09-30 12:53:12 -070076 // Defines the structure of job names.
77 jobNameSchema *JobNameSchema
Eric Boren27225492017-02-01 15:56:55 -050078
Eric Borenf4a5fc72017-06-06 08:27:09 -040079 // Git 2.13.
Eric Boren9d78afd2017-12-07 14:54:05 +000080 cipdGit1 = &specs.CipdPackage{
81 Name: fmt.Sprintf("infra/git/${platform}"),
82 Path: "git",
83 Version: fmt.Sprintf("version:2.13.0.chromium9"),
Eric Borenf4a5fc72017-06-06 08:27:09 -040084 }
Eric Boren9d78afd2017-12-07 14:54:05 +000085 cipdGit2 = &specs.CipdPackage{
86 Name: fmt.Sprintf("infra/tools/git/${platform}"),
87 Path: "git",
88 Version: fmt.Sprintf("git_revision:a78b5f3658c0578a017db48df97d20ac09822bcd"),
89 }
Eric Borenf4a5fc72017-06-06 08:27:09 -040090
Eric Boren27225492017-02-01 15:56:55 -050091 // Flags.
Eric Boren1f8be682017-02-07 09:16:30 -050092 builderNameSchemaFile = flag.String("builder_name_schema", "", "Path to the builder_name_schema.json file. If not specified, uses infra/bots/recipe_modules/builder_name_schema/builder_name_schema.json from this repo.")
93 assetsDir = flag.String("assets_dir", "", "Directory containing assets.")
94 cfgFile = flag.String("cfg_file", "", "JSON file containing general configuration information.")
Eric Boren1f8be682017-02-07 09:16:30 -050095 jobsFile = flag.String("jobs", "", "JSON file containing jobs to run.")
borenetdb182c72016-09-30 12:53:12 -070096)
97
Eric Borenfd4d60e2017-09-15 10:35:44 -040098// internalHardwareLabel returns the internal ID for the bot, if any.
Eric Boren4dc4aaf2017-09-15 14:09:07 -040099func internalHardwareLabel(parts map[string]string) *int {
Eric Borenfd4d60e2017-09-15 10:35:44 -0400100 if internalHardwareLabelFn != nil {
101 return internalHardwareLabelFn(parts)
Eric Boren053d7a42017-09-15 08:35:31 -0400102 }
103 return nil
104}
105
Eric Boren27225492017-02-01 15:56:55 -0500106// linuxGceDimensions are the Swarming dimensions for Linux GCE
107// instances.
108func linuxGceDimensions() []string {
109 return []string{
Ben Wagner4c9842e2017-09-25 12:56:53 -0400110 // Specify CPU to avoid running builds on bots with a more unique CPU.
111 "cpu:x86-64-Haswell_GCE",
Eric Boren27225492017-02-01 15:56:55 -0500112 "gpu:none",
Eric Boren170c39c2017-11-15 11:22:57 -0500113 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE),
Eric Boren27225492017-02-01 15:56:55 -0500114 fmt.Sprintf("pool:%s", CONFIG.Pool),
115 }
116}
117
borenetdb182c72016-09-30 12:53:12 -0700118// deriveCompileTaskName returns the name of a compile task based on the given
119// job name.
120func deriveCompileTaskName(jobName string, parts map[string]string) string {
Ravi Mistryd4731e92018-01-02 14:54:43 -0500121 if strings.Contains(jobName, "Bookmaker") {
Ravi Mistryedc4f3e2017-12-08 12:58:20 -0500122 return "Build-Debian9-GCC-x86_64-Release"
123 } else if parts["role"] == "Housekeeper" {
Eric Borenbb198fb2017-06-28 11:45:54 -0400124 return "Build-Debian9-GCC-x86_64-Release-Shared"
Yuqian Li4a577af2018-01-05 11:13:43 -0500125 } else if parts["role"] == "Test" || parts["role"] == "Perf" || parts["role"] == "Calmbench" {
borenetdb182c72016-09-30 12:53:12 -0700126 task_os := parts["os"]
Ben Wagner988d15e2017-04-27 13:08:50 -0400127 ec := []string{}
128 if val := parts["extra_config"]; val != "" {
129 ec = strings.Split(val, "_")
Ben Wagnerdba0bc82017-12-11 13:27:27 -0500130 ignore := []string{"Skpbench", "AbandonGpuContext", "PreAbandonGpuContext", "Valgrind", "ReleaseAndAbandonGpuContext", "CCPR", "FSAA", "FAAA", "FDAA", "NativeFonts", "GDI", "NoGPUThreads"}
Ben Wagner988d15e2017-04-27 13:08:50 -0400131 keep := make([]string, 0, len(ec))
132 for _, part := range ec {
133 if !util.In(part, ignore) {
134 keep = append(keep, part)
135 }
136 }
137 ec = keep
Eric Boren6ec17e32017-04-26 14:25:29 -0400138 }
borenetdb182c72016-09-30 12:53:12 -0700139 if task_os == "Android" {
Ben Wagner988d15e2017-04-27 13:08:50 -0400140 if !util.In("Android", ec) {
141 ec = append([]string{"Android"}, ec...)
borenetdb182c72016-09-30 12:53:12 -0700142 }
Eric Borenbb198fb2017-06-28 11:45:54 -0400143 task_os = "Debian9"
Kevin Lubickdcd2a902017-03-08 14:01:01 -0500144 } else if task_os == "Chromecast" {
Eric Borenbb198fb2017-06-28 11:45:54 -0400145 task_os = "Debian9"
Ben Wagner988d15e2017-04-27 13:08:50 -0400146 ec = append([]string{"Chromecast"}, ec...)
Kevin Lubickcb6f3982017-04-07 10:04:08 -0400147 } else if strings.Contains(task_os, "ChromeOS") {
Kevin Lubickb718fbb2017-11-02 09:34:08 -0400148 ec = append([]string{"Chromebook", "GLES"}, ec...)
Eric Borenbb198fb2017-06-28 11:45:54 -0400149 task_os = "Debian9"
borenetdb182c72016-09-30 12:53:12 -0700150 } else if task_os == "iOS" {
Ben Wagner988d15e2017-04-27 13:08:50 -0400151 ec = append([]string{task_os}, ec...)
borenetdb182c72016-09-30 12:53:12 -0700152 task_os = "Mac"
153 } else if strings.Contains(task_os, "Win") {
154 task_os = "Win"
Eric Borenbb198fb2017-06-28 11:45:54 -0400155 } else if strings.Contains(task_os, "Ubuntu") || strings.Contains(task_os, "Debian") {
156 task_os = "Debian9"
borenetdb182c72016-09-30 12:53:12 -0700157 }
Eric Boren50831302016-11-18 13:10:51 -0500158 jobNameMap := map[string]string{
borenetdb182c72016-09-30 12:53:12 -0700159 "role": "Build",
160 "os": task_os,
161 "compiler": parts["compiler"],
162 "target_arch": parts["arch"],
163 "configuration": parts["configuration"],
Eric Boren50831302016-11-18 13:10:51 -0500164 }
Ben Wagner988d15e2017-04-27 13:08:50 -0400165 if len(ec) > 0 {
166 jobNameMap["extra_config"] = strings.Join(ec, "_")
Eric Boren50831302016-11-18 13:10:51 -0500167 }
168 name, err := jobNameSchema.MakeJobName(jobNameMap)
borenetdb182c72016-09-30 12:53:12 -0700169 if err != nil {
170 glog.Fatal(err)
171 }
172 return name
173 } else {
174 return jobName
175 }
176}
177
178// swarmDimensions generates swarming bot dimensions for the given task.
179func swarmDimensions(parts map[string]string) []string {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400180 if alternateSwarmDimensions != nil {
181 return alternateSwarmDimensions(parts)
182 }
183 return defaultSwarmDimensions(parts)
184}
185
186// defaultSwarmDimensions generates default swarming bot dimensions for the given task.
187func defaultSwarmDimensions(parts map[string]string) []string {
borenetdb182c72016-09-30 12:53:12 -0700188 d := map[string]string{
Eric Boren27225492017-02-01 15:56:55 -0500189 "pool": CONFIG.Pool,
borenetdb182c72016-09-30 12:53:12 -0700190 }
191 if os, ok := parts["os"]; ok {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400192 d["os"], ok = map[string]string{
Kevin Lubick291547d2017-03-21 09:25:34 -0400193 "Android": "Android",
194 "Chromecast": "Android",
Kevin Lubickcb6f3982017-04-07 10:04:08 -0400195 "ChromeOS": "ChromeOS",
Eric Borenbb198fb2017-06-28 11:45:54 -0400196 "Debian9": DEFAULT_OS_DEBIAN,
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500197 "Mac": DEFAULT_OS_MAC,
Eric Borenbb198fb2017-06-28 11:45:54 -0400198 "Ubuntu14": DEFAULT_OS_UBUNTU,
Kevin Lubick291547d2017-03-21 09:25:34 -0400199 "Ubuntu16": "Ubuntu-16.10",
Eric Boren810c2b62017-07-11 08:11:15 -0400200 "Ubuntu17": "Ubuntu-17.04",
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500201 "Win": DEFAULT_OS_WIN,
Ben Wagner40226b42017-05-02 13:13:13 -0400202 "Win10": "Windows-10-15063",
Kevin Lubick291547d2017-03-21 09:25:34 -0400203 "Win2k8": "Windows-2008ServerR2-SP1",
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500204 "Win2016": DEFAULT_OS_WIN,
Ben Wagner56738d82017-04-18 15:38:15 -0400205 "Win7": "Windows-7-SP1",
Kevin Lubick291547d2017-03-21 09:25:34 -0400206 "Win8": "Windows-8.1-SP0",
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400207 "iOS": "iOS-10.3.1",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500208 }[os]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400209 if !ok {
210 glog.Fatalf("Entry %q not found in OS mapping.", os)
211 }
borenetdb182c72016-09-30 12:53:12 -0700212 } else {
Eric Borenbb198fb2017-06-28 11:45:54 -0400213 d["os"] = DEFAULT_OS_DEBIAN
borenetdb182c72016-09-30 12:53:12 -0700214 }
Yuqian Liab246cb2017-11-02 13:48:23 -0400215 if parts["role"] == "Test" || parts["role"] == "Perf" || parts["role"] == "Calmbench" {
Kevin Lubick291547d2017-03-21 09:25:34 -0400216 if strings.Contains(parts["os"], "Android") || strings.Contains(parts["os"], "Chromecast") {
borenetdb182c72016-09-30 12:53:12 -0700217 // For Android, the device type is a better dimension
218 // than CPU or GPU.
Ben Wagner36682782017-06-14 10:01:45 -0400219 deviceInfo, ok := map[string][]string{
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400220 "AndroidOne": {"sprout", "MOB30Q"},
Kevin Lubickc2f3e8d2018-01-24 15:48:26 -0500221 "Chorizo": {"chorizo", "1.30_109591"},
Ben Wagner0762bdf2017-11-28 09:41:48 -0500222 "GalaxyS6": {"zerofltetmo", "NRD90M_G920TUVU5FQK1"},
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400223 "GalaxyS7_G930A": {"heroqlteatt", "NRD90M_G930AUCS4BQC2"},
224 "GalaxyS7_G930FD": {"herolte", "NRD90M_G930FXXU1DQAS"},
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400225 "MotoG4": {"athene", "NPJ25.93-14"},
Ben Wagneree3123c2017-12-06 16:29:04 -0500226 "NVIDIA_Shield": {"foster", "NRD90M_1915764_848"},
Ben Wagneree3123c2017-12-06 16:29:04 -0500227 "Nexus5": {"hammerhead", "M4B30Z_3437181"},
Ben Wagnereb549c82017-11-17 08:59:44 -0500228 "Nexus5x": {"bullhead", "OPR6.170623.023"},
Ben Wagneree3123c2017-12-06 16:29:04 -0500229 "Nexus7": {"grouper", "LMY47V_1836172"}, // 2012 Nexus 7
Ben Wagner9539a8c2017-11-02 14:09:32 -0400230 "NexusPlayer": {"fugu", "OPR6.170623.021"},
Kevin Lubick832b2222017-09-26 14:07:38 -0400231 "Pixel": {"sailfish", "OPR3.170623.008"},
Kevin Lubickb018f7b2017-10-31 14:44:08 -0400232 "Pixel2XL": {"taimen", "OPD1.170816.023"},
Kevin Lubick674027a2017-10-31 09:47:38 -0400233 "PixelC": {"dragon", "OPR1.170623.034"},
Kevin Lubick832b2222017-09-26 14:07:38 -0400234 "PixelXL": {"marlin", "OPR3.170623.008"},
Ben Wagner36682782017-06-14 10:01:45 -0400235 }[parts["model"]]
Eric Boren27225492017-02-01 15:56:55 -0500236 if !ok {
Ben Wagner36682782017-06-14 10:01:45 -0400237 glog.Fatalf("Entry %q not found in Android mapping.", parts["model"])
Eric Boren27225492017-02-01 15:56:55 -0500238 }
Eric Boren4b254b92016-11-08 12:55:32 -0500239 d["device_type"] = deviceInfo[0]
240 d["device_os"] = deviceInfo[1]
Kevin Lubick4fd283e2017-12-07 11:19:31 -0500241 // TODO(kjlubick): Remove the python dimension after we have removed the
242 // Nexus5x devices from the local lab (on Monday, Dec 11, 2017 should be fine).
Kevin Lubick0f727ff2017-12-06 15:05:29 -0500243 d["python"] = "2.7.9" // This indicates a RPI, e.g. in Skolo. Golo is 2.7.12
Kevin Lubick4fd283e2017-12-07 11:19:31 -0500244 if parts["model"] == "Nexus5x" {
245 d["python"] = "2.7.12"
246 }
borenetdb182c72016-09-30 12:53:12 -0700247 } else if strings.Contains(parts["os"], "iOS") {
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400248 device, ok := map[string]string{
Eric Boren792079c2016-11-09 14:03:20 -0500249 "iPadMini4": "iPad5,1",
Stephan Altmueller63e843d2017-04-25 11:38:38 -0400250 "iPhone6": "iPhone7,2",
251 "iPhone7": "iPhone9,1",
252 "iPadPro": "iPad6,3",
borenetdb182c72016-09-30 12:53:12 -0700253 }[parts["model"]]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400254 if !ok {
255 glog.Fatalf("Entry %q not found in iOS mapping.", parts["model"])
256 }
257 d["device"] = device
borenetdb182c72016-09-30 12:53:12 -0700258 } else if parts["cpu_or_gpu"] == "CPU" {
Ben Wagner4c9842e2017-09-25 12:56:53 -0400259 modelMapping, ok := map[string]map[string]string{
260 "AVX": {
261 "MacMini7.1": "x86-64-E5-2697_v2",
262 "Golo": "x86-64-E5-2670",
263 },
264 "AVX2": {
Ben Wagner85fb42a2017-11-07 16:57:37 -0500265 "GCE": "x86-64-Haswell_GCE",
Mike Klein9a01a212017-11-03 12:19:54 -0400266 "NUC5i7RYH": "x86-64-i7-5557U",
Ben Wagner4c9842e2017-09-25 12:56:53 -0400267 },
Ben Wagnerb268d232017-09-28 16:38:34 -0400268 "AVX512": {
269 "GCE": "x86-64-Skylake_GCE",
270 },
borenetdb182c72016-09-30 12:53:12 -0700271 }[parts["cpu_or_gpu_value"]]
Ben Wagner3d2a2f72017-06-13 17:01:16 -0400272 if !ok {
273 glog.Fatalf("Entry %q not found in CPU mapping.", parts["cpu_or_gpu_value"])
274 }
Ben Wagner4c9842e2017-09-25 12:56:53 -0400275 cpu, ok := modelMapping[parts["model"]]
276 if !ok {
277 glog.Fatalf("Entry %q not found in %q model mapping.", parts["model"], parts["cpu_or_gpu_value"])
borenetdb182c72016-09-30 12:53:12 -0700278 }
Ben Wagner4c9842e2017-09-25 12:56:53 -0400279 d["cpu"] = cpu
Eric Boren170c39c2017-11-15 11:22:57 -0500280 if parts["model"] == "GCE" && d["os"] == DEFAULT_OS_DEBIAN {
281 d["os"] = DEFAULT_OS_LINUX_GCE
282 }
Ben Wagnerf53e6c92017-12-14 13:15:01 -0500283 if parts["model"] == "GCE" && d["os"] == DEFAULT_OS_WIN {
Ben Wagner832415e2017-12-15 11:23:40 -0500284 // Use normal-size machines for Test and Perf tasks on Win GCE.
Ben Wagnerf53e6c92017-12-14 13:15:01 -0500285 d["machine_type"] = "n1-standard-16"
286 }
borenetdb182c72016-09-30 12:53:12 -0700287 } else {
Ben Wagner1d060782017-06-14 10:34:18 -0400288 if strings.Contains(parts["os"], "Win") {
289 gpu, ok := map[string]string{
Ben Wagner0d2b0912017-08-15 12:43:55 -0400290 "GT610": "10de:104a-22.21.13.8205",
Ben Wagner85fb42a2017-11-07 16:57:37 -0500291 "GTX1070": "10de:1ba1-23.21.13.8813",
292 "GTX660": "10de:11c0-23.21.13.8813",
293 "GTX960": "10de:1401-23.21.13.8813",
Ben Wagner1d060782017-06-14 10:34:18 -0400294 "IntelHD530": "8086:1912-21.20.16.4590",
Ben Wagner5698b002017-08-04 11:25:33 -0400295 "IntelHD4400": "8086:0a16-20.19.15.4703",
Ben Wagner3c286532017-08-11 10:35:57 -0400296 "IntelHD4600": "8086:0412-20.19.15.4703",
Ben Wagner1d060782017-06-14 10:34:18 -0400297 "IntelIris540": "8086:1926-21.20.16.4590",
Ben Wagner3c286532017-08-11 10:35:57 -0400298 "IntelIris6100": "8086:162b-20.19.15.4703",
Ben Wagner2040ed22017-11-22 11:22:22 -0500299 "RadeonHD7770": "1002:683d-22.19.165.512",
Ben Wagner1d060782017-06-14 10:34:18 -0400300 "RadeonR9M470X": "1002:6646-22.19.165.512",
Ben Wagnerae532f62017-08-02 23:24:16 -0400301 "QuadroP400": "10de:1cb3-22.21.13.8205",
Ben Wagner1d060782017-06-14 10:34:18 -0400302 }[parts["cpu_or_gpu_value"]]
303 if !ok {
304 glog.Fatalf("Entry %q not found in Win GPU mapping.", parts["cpu_or_gpu_value"])
305 }
306 d["gpu"] = gpu
Ben Wagner08435892017-02-18 23:28:26 -0500307
Ben Wagner4b1df022017-06-15 12:28:04 -0400308 // Specify cpu dimension for NUCs and ShuttleCs. We temporarily have two
309 // types of machines with a GTX960.
310 cpu, ok := map[string]string{
311 "NUC6i7KYK": "x86-64-i7-6770HQ",
312 "ShuttleC": "x86-64-i7-6700K",
Ben Wagner1d060782017-06-14 10:34:18 -0400313 }[parts["model"]]
314 if ok {
Ben Wagner4b1df022017-06-15 12:28:04 -0400315 d["cpu"] = cpu
Ben Wagner1d060782017-06-14 10:34:18 -0400316 }
Eric Borenbb198fb2017-06-28 11:45:54 -0400317 } else if strings.Contains(parts["os"], "Ubuntu") || strings.Contains(parts["os"], "Debian") {
Ben Wagner1d060782017-06-14 10:34:18 -0400318 gpu, ok := map[string]string{
Ben Wagner1d060782017-06-14 10:34:18 -0400319 // Intel drivers come from CIPD, so no need to specify the version here.
320 "IntelBayTrail": "8086:0f31",
321 "IntelHD2000": "8086:0102",
322 "IntelHD405": "8086:22b1",
Ben Wagnerab10c822017-12-19 15:14:12 -0500323 "IntelIris640": "8086:5926",
Ben Wagnerc274ec42017-08-03 22:29:22 -0400324 "QuadroP400": "10de:1cb3-384.59",
Ben Wagner1d060782017-06-14 10:34:18 -0400325 }[parts["cpu_or_gpu_value"]]
326 if !ok {
327 glog.Fatalf("Entry %q not found in Ubuntu GPU mapping.", parts["cpu_or_gpu_value"])
328 }
329 d["gpu"] = gpu
330 } else if strings.Contains(parts["os"], "Mac") {
331 gpu, ok := map[string]string{
Ben Wagner1d8726f2018-02-02 14:47:31 -0500332 "IntelHD6000": "8086:1626",
Ben Wagnerdf430052018-02-08 16:57:04 -0500333 "IntelHD615": "8086:591e",
Ben Wagnercc4221b2017-08-17 17:29:04 -0400334 "IntelIris5100": "8086:0a2e",
Ben Wagner1d060782017-06-14 10:34:18 -0400335 }[parts["cpu_or_gpu_value"]]
336 if !ok {
337 glog.Fatalf("Entry %q not found in Mac GPU mapping.", parts["cpu_or_gpu_value"])
338 }
339 d["gpu"] = gpu
Ben Wagnere7b8fea2018-02-09 10:29:09 -0500340 // Yuck. We have two different types of MacMini7,1 with the same GPU but different CPUs.
341 if parts["cpu_or_gpu_value"] == "IntelIris5100" {
342 // Run all tasks on Golo machines for now.
343 d["cpu"] = "x86-64-i7-4578U"
344 }
Ben Wagner1d060782017-06-14 10:34:18 -0400345 } else if strings.Contains(parts["os"], "ChromeOS") {
Kevin Lubick64ca6be2017-12-04 15:43:31 -0500346 version, ok := map[string]string{
347 "MaliT604": "9901.12.0",
348 "MaliT764": "10172.0.0",
349 "MaliT860": "10172.0.0",
Kevin Lubick0b1b9c22017-12-08 14:14:38 -0500350 "PowerVRGX6250": "10176.5.0",
Kevin Lubick64ca6be2017-12-04 15:43:31 -0500351 "TegraK1": "10172.0.0",
352 "IntelHDGraphics615": "10032.17.0",
Ben Wagner1d060782017-06-14 10:34:18 -0400353 }[parts["cpu_or_gpu_value"]]
354 if !ok {
355 glog.Fatalf("Entry %q not found in ChromeOS GPU mapping.", parts["cpu_or_gpu_value"])
356 }
Kevin Lubick64ca6be2017-12-04 15:43:31 -0500357 d["gpu"] = parts["cpu_or_gpu_value"]
358 d["release_version"] = version
Ben Wagner1d060782017-06-14 10:34:18 -0400359 } else {
360 glog.Fatalf("Unknown GPU mapping for OS %q.", parts["os"])
Ben Wagner08435892017-02-18 23:28:26 -0500361 }
borenetdb182c72016-09-30 12:53:12 -0700362 }
363 } else {
364 d["gpu"] = "none"
Eric Borenbb198fb2017-06-28 11:45:54 -0400365 if d["os"] == DEFAULT_OS_DEBIAN {
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400366 return linuxGceDimensions()
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500367 } else if d["os"] == DEFAULT_OS_WIN {
368 // Windows CPU bots.
Ben Wagnera78f1bc2017-09-26 18:19:56 -0400369 d["cpu"] = "x86-64-Haswell_GCE"
Ben Wagner832415e2017-12-15 11:23:40 -0500370 // Use many-core machines for Build tasks on Win GCE, except for Goma.
371 if strings.Contains(parts["extra_config"], "Goma") {
372 d["machine_type"] = "n1-standard-16"
373 } else {
374 d["machine_type"] = "n1-highcpu-64"
375 }
Ben Wagnerd3fdcc92017-11-14 13:30:04 -0500376 } else if d["os"] == DEFAULT_OS_MAC {
377 // Mac CPU bots.
Ben Wagnera78f1bc2017-09-26 18:19:56 -0400378 d["cpu"] = "x86-64-E5-2697_v2"
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400379 }
borenetdb182c72016-09-30 12:53:12 -0700380 }
Kevin Lubick4610a9b2017-03-22 15:54:54 -0400381
borenetdb182c72016-09-30 12:53:12 -0700382 rv := make([]string, 0, len(d))
383 for k, v := range d {
384 rv = append(rv, fmt.Sprintf("%s:%s", k, v))
385 }
386 sort.Strings(rv)
387 return rv
388}
389
Eric Boren7e3a3642017-06-14 15:25:31 -0400390// relpath returns the relative path to the given file from the config file.
391func relpath(f string) string {
392 _, filename, _, _ := runtime.Caller(0)
393 dir := path.Dir(filename)
394 rel := dir
395 if *cfgFile != "" {
396 rel = path.Dir(*cfgFile)
397 }
398 rv, err := filepath.Rel(rel, path.Join(dir, f))
399 if err != nil {
400 sklog.Fatal(err)
401 }
402 return rv
403}
404
Eric Boren8b3f9e62017-04-04 09:06:16 -0400405// bundleRecipes generates the task to bundle and isolate the recipes.
406func bundleRecipes(b *specs.TasksCfgBuilder) string {
407 b.MustAddTask(BUNDLE_RECIPES_NAME, &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +0000408 CipdPackages: []*specs.CipdPackage{cipdGit1, cipdGit2},
409 Dimensions: linuxGceDimensions(),
410 ExtraArgs: []string{
411 "--workdir", "../../..", "bundle_recipes",
412 fmt.Sprintf("buildername=%s", BUNDLE_RECIPES_NAME),
413 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
Eric Boren8b3f9e62017-04-04 09:06:16 -0400414 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000415 Isolate: relpath("bundle_recipes.isolate"),
Kevin Lubick07072942017-05-11 13:35:23 -0400416 Priority: 0.7,
Eric Boren8b3f9e62017-04-04 09:06:16 -0400417 })
418 return BUNDLE_RECIPES_NAME
419}
420
Eric Boren23a6ec62017-04-07 08:31:22 -0400421// useBundledRecipes returns true iff the given bot should use bundled recipes
422// instead of syncing recipe DEPS itself.
423func useBundledRecipes(parts map[string]string) bool {
424 // Use bundled recipes for all test/perf tasks.
425 return true
426}
427
Kevin Lubick07072942017-05-11 13:35:23 -0400428type isolateAssetCfg struct {
Eric Boren9d78afd2017-12-07 14:54:05 +0000429 isolateFile string
430 cipdPkg string
Kevin Lubick07072942017-05-11 13:35:23 -0400431}
432
433var ISOLATE_ASSET_MAPPING = map[string]isolateAssetCfg{
434 ISOLATE_SKIMAGE_NAME: {
Eric Boren9d78afd2017-12-07 14:54:05 +0000435 isolateFile: "isolate_skimage.isolate",
436 cipdPkg: "skimage",
Kevin Lubick07072942017-05-11 13:35:23 -0400437 },
438 ISOLATE_SKP_NAME: {
Eric Boren9d78afd2017-12-07 14:54:05 +0000439 isolateFile: "isolate_skp.isolate",
440 cipdPkg: "skp",
Kevin Lubick07072942017-05-11 13:35:23 -0400441 },
442 ISOLATE_SVG_NAME: {
Eric Boren9d78afd2017-12-07 14:54:05 +0000443 isolateFile: "isolate_svg.isolate",
444 cipdPkg: "svg",
Kevin Lubick07072942017-05-11 13:35:23 -0400445 },
Kevin Lubick814b1492017-11-29 14:45:14 -0500446 ISOLATE_NDK_LINUX_NAME: {
Eric Boren9d78afd2017-12-07 14:54:05 +0000447 isolateFile: "isolate_ndk_linux.isolate",
448 cipdPkg: "android_ndk_linux",
Kevin Lubick814b1492017-11-29 14:45:14 -0500449 },
450 ISOLATE_WIN_TOOLCHAIN_NAME: {
Eric Boren9d78afd2017-12-07 14:54:05 +0000451 isolateFile: "isolate_win_toolchain.isolate",
452 cipdPkg: "win_toolchain",
Kevin Lubick814b1492017-11-29 14:45:14 -0500453 },
454 ISOLATE_WIN_VULKAN_SDK_NAME: {
Eric Boren9d78afd2017-12-07 14:54:05 +0000455 isolateFile: "isolate_win_vulkan_sdk.isolate",
456 cipdPkg: "win_vulkan_sdk",
Kevin Lubick814b1492017-11-29 14:45:14 -0500457 },
Kevin Lubick07072942017-05-11 13:35:23 -0400458}
459
Eric Boren9d78afd2017-12-07 14:54:05 +0000460// bundleRecipes generates the task to bundle and isolate the recipes.
Kevin Lubick07072942017-05-11 13:35:23 -0400461func isolateCIPDAsset(b *specs.TasksCfgBuilder, name string) string {
462 b.MustAddTask(name, &specs.TaskSpec{
463 CipdPackages: []*specs.CipdPackage{
Eric Boren9d78afd2017-12-07 14:54:05 +0000464 b.MustGetCipdPackageFromAsset(ISOLATE_ASSET_MAPPING[name].cipdPkg),
Kevin Lubick07072942017-05-11 13:35:23 -0400465 },
466 Dimensions: linuxGceDimensions(),
Eric Boren9d78afd2017-12-07 14:54:05 +0000467 Isolate: relpath(ISOLATE_ASSET_MAPPING[name].isolateFile),
Kevin Lubick07072942017-05-11 13:35:23 -0400468 Priority: 0.7,
469 })
470 return name
471}
472
Kevin Lubick90189522017-05-15 08:30:27 -0400473// getIsolatedCIPDDeps returns the slice of Isolate_* tasks a given task needs.
474// This allows us to save time on I/O bound bots, like the RPIs.
475func getIsolatedCIPDDeps(parts map[string]string) []string {
476 deps := []string{}
Kevin Lubick07072942017-05-11 13:35:23 -0400477 // Only do this on the RPIs for now. Other, faster machines shouldn't see much
478 // benefit and we don't need the extra complexity, for now
Kevin Lubick90189522017-05-15 08:30:27 -0400479 rpiOS := []string{"Android", "ChromeOS", "iOS"}
480
481 if o := parts["os"]; strings.Contains(o, "Chromecast") {
482 // Chromecasts don't have enough disk space to fit all of the content,
483 // so we do a subset of the skps.
484 deps = append(deps, ISOLATE_SKP_NAME)
485 } else if e := parts["extra_config"]; strings.Contains(e, "Skpbench") {
486 // Skpbench only needs skps
487 deps = append(deps, ISOLATE_SKP_NAME)
488 } else if util.In(o, rpiOS) {
489 deps = append(deps, ISOLATE_SKP_NAME)
490 deps = append(deps, ISOLATE_SVG_NAME)
491 deps = append(deps, ISOLATE_SKIMAGE_NAME)
492 }
493
494 return deps
Kevin Lubick07072942017-05-11 13:35:23 -0400495}
496
borenetdb182c72016-09-30 12:53:12 -0700497// compile generates a compile task. Returns the name of the last task in the
498// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700499func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string {
borenetdb182c72016-09-30 12:53:12 -0700500 // Collect the necessary CIPD packages.
501 pkgs := []*specs.CipdPackage{}
Eric Boren9d78afd2017-12-07 14:54:05 +0000502 deps := []string{}
borenetdb182c72016-09-30 12:53:12 -0700503
504 // Android bots require a toolchain.
505 if strings.Contains(name, "Android") {
Ravi Mistry5e967422018-02-01 13:38:13 -0500506 if parts["extra_config"] == "Android_Framework" {
507 // Do not need a toolchain when building the
508 // Android Framework.
509 } else if strings.Contains(name, "Mac") {
boreneted20a702016-10-20 11:04:31 -0700510 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_darwin"))
Mike Klein86c2c0f2016-11-02 13:13:16 -0400511 } else if strings.Contains(name, "Win") {
Mike Kleine9215f02016-11-02 15:44:26 -0400512 pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows")
513 pkg.Path = "n"
514 pkgs = append(pkgs, pkg)
borenetdb182c72016-09-30 12:53:12 -0700515 } else {
Kevin Lubick814b1492017-11-29 14:45:14 -0500516 deps = append(deps, isolateCIPDAsset(b, ISOLATE_NDK_LINUX_NAME))
borenetdb182c72016-09-30 12:53:12 -0700517 }
Kevin Lubickdcd2a902017-03-08 14:01:01 -0500518 } else if strings.Contains(name, "Chromecast") {
519 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("cast_toolchain"))
Kevin Lubickffce0792017-05-24 15:30:35 -0400520 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles"))
Kevin Lubick261ea192017-04-05 07:32:45 -0400521 } else if strings.Contains(name, "Chromebook") {
522 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
Kevin Lubickb718fbb2017-11-02 09:34:08 -0400523 if parts["target_arch"] == "x86_64" {
524 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_x86_64_gles"))
525 } else if parts["target_arch"] == "arm" {
526 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("armhf_sysroot"))
527 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("chromebook_arm_gles"))
528 }
Eric Borenbb198fb2017-06-28 11:45:54 -0400529 } else if strings.Contains(name, "Debian") {
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500530 if strings.Contains(name, "Clang") {
531 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
532 }
533 if strings.Contains(name, "Vulkan") {
534 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
535 }
Kevin Lubickebf648e2017-09-21 13:45:16 -0400536 if strings.Contains(name, "EMCC") {
537 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("emscripten_sdk"))
538 }
Mike Klein27dcee12016-11-09 16:31:42 -0500539 } else if strings.Contains(name, "Win") {
Kevin Lubick814b1492017-11-29 14:45:14 -0500540 deps = append(deps, isolateCIPDAsset(b, ISOLATE_WIN_TOOLCHAIN_NAME))
Mike Klein8e3c42b2017-07-31 14:57:20 -0400541 if strings.Contains(name, "Clang") {
542 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_win"))
543 }
borenetdb182c72016-09-30 12:53:12 -0700544 if strings.Contains(name, "Vulkan") {
Kevin Lubick814b1492017-11-29 14:45:14 -0500545 deps = append(deps, isolateCIPDAsset(b, ISOLATE_WIN_VULKAN_SDK_NAME))
borenetdb182c72016-09-30 12:53:12 -0700546 }
547 }
548
Stephan Altmueller5f3b9402017-03-20 13:38:45 -0400549 dimensions := swarmDimensions(parts)
Stephan Altmueller5f3b9402017-03-20 13:38:45 -0400550
borenetdb182c72016-09-30 12:53:12 -0700551 // Add the task.
boreneted20a702016-10-20 11:04:31 -0700552 b.MustAddTask(name, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700553 CipdPackages: pkgs,
Eric Boren9d78afd2017-12-07 14:54:05 +0000554 Dimensions: dimensions,
555 Dependencies: deps,
556 ExtraArgs: []string{
557 "--workdir", "../../..", "compile",
skia.buildbots2478c732016-11-04 14:37:26 -0400558 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700559 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700560 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
561 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400562 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700563 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400564 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
565 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700566 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000567 Isolate: relpath("compile_skia.isolate"),
568 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700569 })
Eric Boren8615fe52016-12-12 14:30:12 -0500570 // All compile tasks are runnable as their own Job. Assert that the Job
571 // is listed in JOBS.
572 if !util.In(name, JOBS) {
573 glog.Fatalf("Job %q is missing from the JOBS list!", name)
574 }
Ravi Mistry6f136222017-12-12 17:08:24 -0500575
576 // Upload the skiaserve binary only for Linux Android compile bots.
577 // See skbug.com/7399 for context.
578 if parts["configuration"] == "Release" &&
579 parts["extra_config"] == "Android" &&
580 !strings.Contains(parts["os"], "Win") &&
581 !strings.Contains(parts["os"], "Mac") {
582 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
583 b.MustAddTask(uploadName, &specs.TaskSpec{
584 Dependencies: []string{name},
585 Dimensions: linuxGceDimensions(),
586 ExtraArgs: []string{
587 "--workdir", "../../..", "upload_skiaserve",
588 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
589 fmt.Sprintf("buildername=%s", name),
590 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
591 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
592 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
593 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
594 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
595 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
596 },
597 // We're using the same isolate as upload_dm_results
598 Isolate: relpath("upload_dm_results.isolate"),
599 Priority: 0.8,
600 })
601 return uploadName
602 }
603
borenetdb182c72016-09-30 12:53:12 -0700604 return name
605}
606
607// recreateSKPs generates a RecreateSKPs task. Returns the name of the last
608// task in the generated chain of tasks, which the Job should add as a
609// dependency.
Eric Boren9d78afd2017-12-07 14:54:05 +0000610func recreateSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500611 b.MustAddTask(name, &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +0000612 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
613 Dimensions: linuxGceDimensions(),
614 ExecutionTimeout: 4 * time.Hour,
615 ExtraArgs: []string{
616 "--workdir", "../../..", "recreate_skps",
Eric Boren4b254b92016-11-08 12:55:32 -0500617 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
618 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500619 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
620 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400621 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500622 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
623 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
624 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
625 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000626 IoTimeout: 40 * time.Minute,
627 Isolate: relpath("compile_skia.isolate"),
628 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500629 })
borenetdb182c72016-09-30 12:53:12 -0700630 return name
631}
632
Ravi Mistry01b48e72017-05-17 14:28:06 -0400633// updateMetaConfig generates a UpdateMetaConfig task. Returns the name of the
634// last task in the generated chain of tasks, which the Job should add as a
635// dependency.
Eric Boren9d78afd2017-12-07 14:54:05 +0000636func updateMetaConfig(b *specs.TasksCfgBuilder, name string) string {
Ravi Mistry01b48e72017-05-17 14:28:06 -0400637 b.MustAddTask(name, &specs.TaskSpec{
Stephan Altmuellerddad85b2017-05-19 13:08:19 -0400638 CipdPackages: []*specs.CipdPackage{},
Eric Boren9d78afd2017-12-07 14:54:05 +0000639 Dimensions: linuxGceDimensions(),
640 ExtraArgs: []string{
641 "--workdir", "../../..", "update_meta_config",
Ravi Mistry01b48e72017-05-17 14:28:06 -0400642 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
643 fmt.Sprintf("buildername=%s", name),
644 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
645 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
646 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
647 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
648 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
649 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
650 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000651 Isolate: relpath("meta_config.isolate"),
652 Priority: 0.8,
Ravi Mistry01b48e72017-05-17 14:28:06 -0400653 })
654 return name
655}
656
borenetdb182c72016-09-30 12:53:12 -0700657// ctSKPs generates a CT SKPs task. Returns the name of the last task in the
658// generated chain of tasks, which the Job should add as a dependency.
Eric Boren9d78afd2017-12-07 14:54:05 +0000659func ctSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500660 b.MustAddTask(name, &specs.TaskSpec{
Ben Wagner21c3fb92017-08-04 14:13:27 -0400661 CipdPackages: []*specs.CipdPackage{},
Eric Boren9d78afd2017-12-07 14:54:05 +0000662 Dimensions: []string{
663 "pool:SkiaCT",
664 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX_GCE),
665 },
666 ExecutionTimeout: 24 * time.Hour,
667 ExtraArgs: []string{
668 "--workdir", "../../..", "ct_skps",
Eric Boren4b254b92016-11-08 12:55:32 -0500669 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
670 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500671 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
672 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400673 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500674 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
675 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
676 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
677 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000678 IoTimeout: time.Hour,
679 Isolate: relpath("ct_skps_skia.isolate"),
680 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500681 })
borenetdb182c72016-09-30 12:53:12 -0700682 return name
683}
684
Eric Borenf7928b42017-07-28 07:35:28 -0400685// checkGeneratedFiles verifies that no generated SKSL files have been edited
686// by hand.
Eric Boren9d78afd2017-12-07 14:54:05 +0000687func checkGeneratedFiles(b *specs.TasksCfgBuilder, name string) string {
Eric Borenf7928b42017-07-28 07:35:28 -0400688 b.MustAddTask(name, &specs.TaskSpec{
689 CipdPackages: []*specs.CipdPackage{},
Eric Boren9d78afd2017-12-07 14:54:05 +0000690 Dimensions: linuxGceDimensions(),
691 ExtraArgs: []string{
692 "--workdir", "../../..", "check_generated_files",
Eric Borenf7928b42017-07-28 07:35:28 -0400693 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
694 fmt.Sprintf("buildername=%s", name),
695 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
696 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
697 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
698 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
699 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
700 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
701 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000702 Isolate: relpath("compile_skia.isolate"),
703 Priority: 0.8,
Eric Borenf7928b42017-07-28 07:35:28 -0400704 })
705 return name
706}
707
borenetdb182c72016-09-30 12:53:12 -0700708// housekeeper generates a Housekeeper task. Returns the name of the last task
709// in the generated chain of tasks, which the Job should add as a dependency.
Eric Boren9d78afd2017-12-07 14:54:05 +0000710func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500711 b.MustAddTask(name, &specs.TaskSpec{
Eric Boren22f5ef72016-12-02 11:01:33 -0500712 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren9d78afd2017-12-07 14:54:05 +0000713 Dependencies: []string{compileTaskName},
714 Dimensions: linuxGceDimensions(),
715 ExtraArgs: []string{
716 "--workdir", "../../..", "housekeeper",
Eric Boren4b254b92016-11-08 12:55:32 -0500717 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
718 fmt.Sprintf("buildername=%s", name),
Eric Boren4b254b92016-11-08 12:55:32 -0500719 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
720 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400721 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
Eric Boren4b254b92016-11-08 12:55:32 -0500722 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
723 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
724 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
725 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000726 Isolate: relpath("housekeeper_skia.isolate"),
727 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500728 })
borenetdb182c72016-09-30 12:53:12 -0700729 return name
730}
731
Ravi Mistryedc4f3e2017-12-08 12:58:20 -0500732// bookmaker generates a Bookmaker task. Returns the name of the last task
733// in the generated chain of tasks, which the Job should add as a dependency.
734func bookmaker(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
735 b.MustAddTask(name, &specs.TaskSpec{
736 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
737 Dependencies: []string{compileTaskName},
738 Dimensions: linuxGceDimensions(),
739 ExtraArgs: []string{
740 "--workdir", "../../..", "bookmaker",
741 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
742 fmt.Sprintf("buildername=%s", name),
743 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
744 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
745 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
746 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
747 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
748 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
749 },
750 Isolate: relpath("compile_skia.isolate"),
751 Priority: 0.8,
752 ExecutionTimeout: 2 * time.Hour,
753 IoTimeout: 2 * time.Hour,
754 })
755 return name
756}
757
Ravi Mistry5e967422018-02-01 13:38:13 -0500758// androidFrameworkCompile generates an Android Framework Compile task. Returns
759// the name of the last task in the generated chain of tasks, which the Job
760// should add as a dependency.
761func androidFrameworkCompile(b *specs.TasksCfgBuilder, name string) string {
762 b.MustAddTask(name, &specs.TaskSpec{
763 Dimensions: linuxGceDimensions(),
764 ExtraArgs: []string{
765 "--workdir", "../../..", "android_compile",
766 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
767 fmt.Sprintf("buildername=%s", name),
768 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
769 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
770 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
771 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
772 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
773 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
774 },
775 Isolate: relpath("compile_skia.isolate"),
776 Priority: 0.8,
777 })
778 return name
779}
780
borenet2dbbfa52016-10-14 06:32:09 -0700781// infra generates an infra_tests task. Returns the name of the last task in the
782// generated chain of tasks, which the Job should add as a dependency.
Eric Boren9d78afd2017-12-07 14:54:05 +0000783func infra(b *specs.TasksCfgBuilder, name string) string {
boreneted20a702016-10-20 11:04:31 -0700784 b.MustAddTask(name, &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +0000785 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
786 Dimensions: linuxGceDimensions(),
787 ExtraArgs: []string{
788 "--workdir", "../../..", "infra",
skia.buildbots2478c732016-11-04 14:37:26 -0400789 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenet2dbbfa52016-10-14 06:32:09 -0700790 fmt.Sprintf("buildername=%s", name),
borenet2dbbfa52016-10-14 06:32:09 -0700791 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
792 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400793 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet2dbbfa52016-10-14 06:32:09 -0700794 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400795 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
796 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenet2dbbfa52016-10-14 06:32:09 -0700797 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000798 Isolate: relpath("infra_skia.isolate"),
799 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700800 })
borenet2dbbfa52016-10-14 06:32:09 -0700801 return name
802}
803
Yuqian Li4a577af2018-01-05 11:13:43 -0500804func getParentRevisionName(compileTaskName string, parts map[string]string) string {
805 if parts["extra_config"] == "" {
806 return compileTaskName + "-ParentRevision"
807 } else {
808 return compileTaskName + "_ParentRevision"
809 }
810}
811
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400812// calmbench generates a calmbench task. Returns the name of the last task in the
813// generated chain of tasks, which the Job should add as a dependency.
Yuqian Li4a577af2018-01-05 11:13:43 -0500814func calmbench(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, compileParentName string) string {
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400815 s := &specs.TaskSpec{
Yuqian Li4a577af2018-01-05 11:13:43 -0500816 Dependencies: []string{compileTaskName, compileParentName},
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400817 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("clang_linux")},
Eric Boren9d78afd2017-12-07 14:54:05 +0000818 Dimensions: swarmDimensions(parts),
819 ExtraArgs: []string{
820 "--workdir", "../../..", "calmbench",
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400821 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
822 fmt.Sprintf("buildername=%s", name),
823 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
824 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
825 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
826 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
827 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
828 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
829 },
Yuqian Li4a577af2018-01-05 11:13:43 -0500830 Isolate: relpath("calmbench.isolate"),
Eric Boren9d78afd2017-12-07 14:54:05 +0000831 Priority: 0.8,
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400832 }
833
834 s.Dependencies = append(s.Dependencies, ISOLATE_SKP_NAME, ISOLATE_SVG_NAME)
835
836 b.MustAddTask(name, s)
837
Yuqian Li2ebf3d12017-10-24 09:43:21 -0400838 // Upload results if necessary.
839 if strings.Contains(name, "Release") && doUpload(name) {
840 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
841 b.MustAddTask(uploadName, &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +0000842 Dependencies: []string{name},
843 Dimensions: linuxGceDimensions(),
844 ExtraArgs: []string{
845 "--workdir", "../../..", "upload_calmbench_results",
Yuqian Li2ebf3d12017-10-24 09:43:21 -0400846 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
847 fmt.Sprintf("buildername=%s", name),
848 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
849 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
850 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
851 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
852 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
853 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
854 fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketCalm),
855 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000856 // We're using the same isolate as upload_nano_results
857 Isolate: relpath("upload_nano_results.isolate"),
858 Priority: 0.8,
Yuqian Li2ebf3d12017-10-24 09:43:21 -0400859 })
860 return uploadName
861 }
862
Yuqian Lic81aaaa2017-10-16 12:24:43 -0400863 return name
864}
865
borenetdb182c72016-09-30 12:53:12 -0700866// doUpload indicates whether the given Job should upload its results.
867func doUpload(name string) bool {
Eric Boren27225492017-02-01 15:56:55 -0500868 for _, s := range CONFIG.NoUpload {
869 m, err := regexp.MatchString(s, name)
870 if err != nil {
871 glog.Fatal(err)
872 }
873 if m {
borenetdb182c72016-09-30 12:53:12 -0700874 return false
875 }
876 }
877 return true
878}
879
880// test generates a Test task. Returns the name of the last task in the
881// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700882func test(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Kevin Lubick4f0f9332018-01-12 14:31:48 -0500883 deps := []string{compileTaskName}
884 if strings.Contains(name, "Android_ASAN") {
885 deps = append(deps, isolateCIPDAsset(b, ISOLATE_NDK_LINUX_NAME))
886 }
887
Eric Boren4b254b92016-11-08 12:55:32 -0500888 s := &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +0000889 CipdPackages: pkgs,
Kevin Lubick4f0f9332018-01-12 14:31:48 -0500890 Dependencies: deps,
Eric Boren9d78afd2017-12-07 14:54:05 +0000891 Dimensions: swarmDimensions(parts),
892 ExecutionTimeout: 4 * time.Hour,
893 Expiration: 20 * time.Hour,
894 ExtraArgs: []string{
895 "--workdir", "../../..", "test",
skia.buildbots2478c732016-11-04 14:37:26 -0400896 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
Eric Boren9a9e3872017-11-29 12:33:22 -0500897 fmt.Sprintf("buildbucket_build_id=%s", specs.PLACEHOLDER_BUILDBUCKET_BUILD_ID),
borenetdb182c72016-09-30 12:53:12 -0700898 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700899 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
900 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400901 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700902 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400903 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
904 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700905 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000906 IoTimeout: 40 * time.Minute,
907 Isolate: relpath("test_skia.isolate"),
908 MaxAttempts: 1,
909 Priority: 0.8,
910 }
911 if useBundledRecipes(parts) {
912 s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME)
913 if strings.Contains(parts["os"], "Win") {
914 s.Isolate = relpath("test_skia_bundled_win.isolate")
915 } else {
916 s.Isolate = relpath("test_skia_bundled_unix.isolate")
917 }
Eric Boren8b3f9e62017-04-04 09:06:16 -0400918 }
Kevin Lubick90189522017-05-15 08:30:27 -0400919 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
920 s.Dependencies = append(s.Dependencies, deps...)
Kevin Lubick07072942017-05-11 13:35:23 -0400921 }
Eric Boren4b254b92016-11-08 12:55:32 -0500922 if strings.Contains(parts["extra_config"], "Valgrind") {
923 s.ExecutionTimeout = 9 * time.Hour
924 s.Expiration = 48 * time.Hour
925 s.IoTimeout = time.Hour
Eric Borend696df72017-05-31 15:09:10 -0400926 s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind"))
Kevin Lubickea613822017-12-04 10:20:23 -0500927 s.Dimensions = append(s.Dimensions, "valgrind:1")
Eric Boren4b254b92016-11-08 12:55:32 -0500928 } else if strings.Contains(parts["extra_config"], "MSAN") {
929 s.ExecutionTimeout = 9 * time.Hour
Ben Wagnera6b2ba22017-06-08 10:34:17 -0400930 } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" {
931 // skia:6737
932 s.ExecutionTimeout = 6 * time.Hour
Eric Boren4b254b92016-11-08 12:55:32 -0500933 }
Eric Borenfd4d60e2017-09-15 10:35:44 -0400934 iid := internalHardwareLabel(parts)
Eric Boren053d7a42017-09-15 08:35:31 -0400935 if iid != nil {
Eric Boren4dc4aaf2017-09-15 14:09:07 -0400936 s.ExtraArgs = append(s.ExtraArgs, fmt.Sprintf("internal_hardware_label=%d", *iid))
Eric Boren053d7a42017-09-15 08:35:31 -0400937 }
Eric Boren4b254b92016-11-08 12:55:32 -0500938 b.MustAddTask(name, s)
939
Kevin Lubickc795a4c2017-10-09 15:26:19 -0400940 // Upload results if necessary. TODO(kjlubick): If we do coverage analysis at the same
941 // time as normal tests (which would be nice), cfg.json needs to have Coverage removed.
borenetdb182c72016-09-30 12:53:12 -0700942 if doUpload(name) {
943 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700944 b.MustAddTask(uploadName, &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +0000945 Dependencies: []string{name},
946 Dimensions: linuxGceDimensions(),
947 ExtraArgs: []string{
948 "--workdir", "../../..", "upload_dm_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400949 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700950 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -0700951 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
952 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -0400953 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -0700954 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400955 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
956 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
Eric Boren965861b2017-02-06 15:38:41 -0500957 fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketGm),
borenetdb182c72016-09-30 12:53:12 -0700958 },
Eric Boren9d78afd2017-12-07 14:54:05 +0000959 Isolate: relpath("upload_dm_results.isolate"),
960 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700961 })
borenetdb182c72016-09-30 12:53:12 -0700962 return uploadName
Kevin Lubick32f318b2017-10-17 13:40:52 -0400963 }
964
965 return name
966}
967
968func coverage(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
969 shards := 1
970 deps := []string{}
971
972 tf := parts["test_filter"]
973 if strings.Contains(tf, "Shard") {
974 // Expected Shard_NN
975 shardstr := strings.Split(tf, "_")[1]
976 var err error
977 shards, err = strconv.Atoi(shardstr)
978 if err != nil {
979 glog.Fatalf("Expected int for number of shards %q in %s: %s", shardstr, name, err)
980 }
981 }
982 for i := 0; i < shards; i++ {
983 n := strings.Replace(name, tf, fmt.Sprintf("shard_%02d_%02d", i, shards), 1)
984 s := &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +0000985 CipdPackages: pkgs,
986 Dependencies: []string{compileTaskName},
987 Dimensions: swarmDimensions(parts),
988 ExecutionTimeout: 4 * time.Hour,
989 Expiration: 20 * time.Hour,
990 ExtraArgs: []string{
991 "--workdir", "../../..", "test",
Kevin Lubickc795a4c2017-10-09 15:26:19 -0400992 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
Kevin Lubick32f318b2017-10-17 13:40:52 -0400993 fmt.Sprintf("buildername=%s", n),
Kevin Lubickc795a4c2017-10-09 15:26:19 -0400994 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
995 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
996 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
997 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
998 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
999 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
Kevin Lubickc795a4c2017-10-09 15:26:19 -04001000 },
Eric Boren9d78afd2017-12-07 14:54:05 +00001001 IoTimeout: 40 * time.Minute,
1002 Isolate: relpath("test_skia.isolate"),
1003 MaxAttempts: 1,
1004 Priority: 0.8,
1005 }
1006 if useBundledRecipes(parts) {
1007 s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME)
1008 if strings.Contains(parts["os"], "Win") {
1009 s.Isolate = relpath("test_skia_bundled_win.isolate")
1010 } else {
1011 s.Isolate = relpath("test_skia_bundled_unix.isolate")
1012 }
Kevin Lubick32f318b2017-10-17 13:40:52 -04001013 }
1014 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
1015 s.Dependencies = append(s.Dependencies, deps...)
1016 }
1017 b.MustAddTask(n, s)
1018 deps = append(deps, n)
borenetdb182c72016-09-30 12:53:12 -07001019 }
Kevin Lubickc795a4c2017-10-09 15:26:19 -04001020
Kevin Lubick32f318b2017-10-17 13:40:52 -04001021 uploadName := fmt.Sprintf("%s%s%s", "Upload", jobNameSchema.Sep, name)
1022 // We need clang_linux to get access to the llvm-profdata and llvm-cov binaries
1023 // which are used to deal with the raw coverage data output by the Test step.
1024 pkgs = append([]*specs.CipdPackage{}, b.MustGetCipdPackageFromAsset("clang_linux"))
1025 deps = append(deps, compileTaskName)
1026
1027 b.MustAddTask(uploadName, &specs.TaskSpec{
1028 // A dependency on compileTaskName makes the TaskScheduler link the
1029 // isolated output of the compile step to the input of the upload step,
1030 // which gives us access to the instrumented binary. The binary is
1031 // needed to figure out symbol names and line numbers.
1032 Dependencies: deps,
1033 Dimensions: linuxGceDimensions(),
1034 CipdPackages: pkgs,
Eric Boren9d78afd2017-12-07 14:54:05 +00001035 ExtraArgs: []string{
1036 "--workdir", "../../..", "upload_coverage_results",
Kevin Lubick32f318b2017-10-17 13:40:52 -04001037 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
1038 fmt.Sprintf("buildername=%s", name),
1039 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
1040 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
1041 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
1042 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
1043 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
1044 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
1045 fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketCoverage),
1046 },
Eric Boren9d78afd2017-12-07 14:54:05 +00001047 Isolate: relpath("upload_coverage_results.isolate"),
Kevin Lubick32f318b2017-10-17 13:40:52 -04001048 Priority: 0.8,
1049 })
1050 return uploadName
borenetdb182c72016-09-30 12:53:12 -07001051}
1052
1053// perf generates a Perf task. Returns the name of the last task in the
1054// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -07001055func perf(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Eric Boren768f52f2017-04-10 08:14:33 -04001056 recipe := "perf"
Eric Boren9d78afd2017-12-07 14:54:05 +00001057 isolate := relpath("perf_skia.isolate")
Kevin Lubickb03b5ac2016-11-14 13:42:27 -05001058 if strings.Contains(parts["extra_config"], "Skpbench") {
Eric Boren768f52f2017-04-10 08:14:33 -04001059 recipe = "skpbench"
Eric Boren9d78afd2017-12-07 14:54:05 +00001060 isolate = relpath("skpbench_skia.isolate")
1061 if useBundledRecipes(parts) {
1062 if strings.Contains(parts["os"], "Win") {
1063 isolate = relpath("skpbench_skia_bundled_win.isolate")
1064 } else {
1065 isolate = relpath("skpbench_skia_bundled_unix.isolate")
1066 }
1067 }
1068 } else if useBundledRecipes(parts) {
1069 if strings.Contains(parts["os"], "Win") {
1070 isolate = relpath("perf_skia_bundled_win.isolate")
1071 } else {
1072 isolate = relpath("perf_skia_bundled_unix.isolate")
1073 }
Kevin Lubickb03b5ac2016-11-14 13:42:27 -05001074 }
Eric Boren4b254b92016-11-08 12:55:32 -05001075 s := &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +00001076 CipdPackages: pkgs,
1077 Dependencies: []string{compileTaskName},
1078 Dimensions: swarmDimensions(parts),
1079 ExecutionTimeout: 4 * time.Hour,
1080 Expiration: 20 * time.Hour,
1081 ExtraArgs: []string{
1082 "--workdir", "../../..", recipe,
skia.buildbots2478c732016-11-04 14:37:26 -04001083 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -07001084 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -07001085 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
1086 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -04001087 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -07001088 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -04001089 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
1090 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -07001091 },
Eric Boren9d78afd2017-12-07 14:54:05 +00001092 IoTimeout: 40 * time.Minute,
1093 Isolate: isolate,
1094 MaxAttempts: 1,
1095 Priority: 0.8,
1096 }
1097 if useBundledRecipes(parts) {
1098 s.Dependencies = append(s.Dependencies, BUNDLE_RECIPES_NAME)
Eric Boren8b3f9e62017-04-04 09:06:16 -04001099 }
Kevin Lubick90189522017-05-15 08:30:27 -04001100 if deps := getIsolatedCIPDDeps(parts); len(deps) > 0 {
1101 s.Dependencies = append(s.Dependencies, deps...)
1102 }
1103
Eric Boren4b254b92016-11-08 12:55:32 -05001104 if strings.Contains(parts["extra_config"], "Valgrind") {
1105 s.ExecutionTimeout = 9 * time.Hour
1106 s.Expiration = 48 * time.Hour
1107 s.IoTimeout = time.Hour
Eric Borenc5a073d2017-06-01 07:13:33 -04001108 s.CipdPackages = append(s.CipdPackages, b.MustGetCipdPackageFromAsset("valgrind"))
Kevin Lubickea613822017-12-04 10:20:23 -05001109 s.Dimensions = append(s.Dimensions, "valgrind:1")
Eric Boren4b254b92016-11-08 12:55:32 -05001110 } else if strings.Contains(parts["extra_config"], "MSAN") {
1111 s.ExecutionTimeout = 9 * time.Hour
Ben Wagnera6b2ba22017-06-08 10:34:17 -04001112 } else if parts["arch"] == "x86" && parts["configuration"] == "Debug" {
1113 // skia:6737
1114 s.ExecutionTimeout = 6 * time.Hour
Eric Boren4b254b92016-11-08 12:55:32 -05001115 }
Eric Borenfd4d60e2017-09-15 10:35:44 -04001116 iid := internalHardwareLabel(parts)
Eric Boren053d7a42017-09-15 08:35:31 -04001117 if iid != nil {
Eric Boren4dc4aaf2017-09-15 14:09:07 -04001118 s.ExtraArgs = append(s.ExtraArgs, fmt.Sprintf("internal_hardware_label=%d", *iid))
Eric Boren053d7a42017-09-15 08:35:31 -04001119 }
Eric Boren4b254b92016-11-08 12:55:32 -05001120 b.MustAddTask(name, s)
1121
borenetdb182c72016-09-30 12:53:12 -07001122 // Upload results if necessary.
1123 if strings.Contains(name, "Release") && doUpload(name) {
1124 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -07001125 b.MustAddTask(uploadName, &specs.TaskSpec{
Eric Boren9d78afd2017-12-07 14:54:05 +00001126 Dependencies: []string{name},
1127 Dimensions: linuxGceDimensions(),
1128 ExtraArgs: []string{
1129 "--workdir", "../../..", "upload_nano_results",
skia.buildbots2478c732016-11-04 14:37:26 -04001130 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -07001131 fmt.Sprintf("buildername=%s", name),
borenetdb182c72016-09-30 12:53:12 -07001132 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
1133 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
Eric Boren09419502017-04-21 09:37:37 -04001134 fmt.Sprintf("patch_repo=%s", specs.PLACEHOLDER_PATCH_REPO),
borenet98b2e7a2016-10-13 06:23:45 -07001135 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -04001136 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
1137 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
Eric Boren965861b2017-02-06 15:38:41 -05001138 fmt.Sprintf("gs_bucket=%s", CONFIG.GsBucketNano),
borenetdb182c72016-09-30 12:53:12 -07001139 },
Eric Boren9d78afd2017-12-07 14:54:05 +00001140 Isolate: relpath("upload_nano_results.isolate"),
1141 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -07001142 })
borenetdb182c72016-09-30 12:53:12 -07001143 return uploadName
1144 }
1145 return name
1146}
1147
1148// process generates tasks and jobs for the given job name.
boreneted20a702016-10-20 11:04:31 -07001149func process(b *specs.TasksCfgBuilder, name string) {
borenetdb182c72016-09-30 12:53:12 -07001150 deps := []string{}
1151
Eric Boren8b3f9e62017-04-04 09:06:16 -04001152 // Bundle Recipes.
1153 if name == BUNDLE_RECIPES_NAME {
1154 deps = append(deps, bundleRecipes(b))
1155 }
1156
Kevin Lubick07072942017-05-11 13:35:23 -04001157 // Isolate CIPD assets.
Kevin Lubick07072942017-05-11 13:35:23 -04001158 if _, ok := ISOLATE_ASSET_MAPPING[name]; ok {
1159 deps = append(deps, isolateCIPDAsset(b, name))
1160 }
1161
borenetdb182c72016-09-30 12:53:12 -07001162 parts, err := jobNameSchema.ParseJobName(name)
1163 if err != nil {
1164 glog.Fatal(err)
1165 }
1166
1167 // RecreateSKPs.
1168 if strings.Contains(name, "RecreateSKPs") {
Eric Boren9d78afd2017-12-07 14:54:05 +00001169 deps = append(deps, recreateSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -07001170 }
1171
Ravi Mistry01b48e72017-05-17 14:28:06 -04001172 // UpdateMetaConfig bot.
1173 if strings.Contains(name, "UpdateMetaConfig") {
Eric Boren9d78afd2017-12-07 14:54:05 +00001174 deps = append(deps, updateMetaConfig(b, name))
Ravi Mistry01b48e72017-05-17 14:28:06 -04001175 }
1176
borenetdb182c72016-09-30 12:53:12 -07001177 // CT bots.
1178 if strings.Contains(name, "-CT_") {
Eric Boren9d78afd2017-12-07 14:54:05 +00001179 deps = append(deps, ctSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -07001180 }
1181
borenet2dbbfa52016-10-14 06:32:09 -07001182 // Infra tests.
1183 if name == "Housekeeper-PerCommit-InfraTests" {
Eric Boren9d78afd2017-12-07 14:54:05 +00001184 deps = append(deps, infra(b, name))
borenet2dbbfa52016-10-14 06:32:09 -07001185 }
1186
borenetdb182c72016-09-30 12:53:12 -07001187 // Compile bots.
1188 if parts["role"] == "Build" {
Ravi Mistry5e967422018-02-01 13:38:13 -05001189 if parts["extra_config"] == "Android_Framework" {
1190 // Android Framework compile tasks use a different recipe.
1191 deps = append(deps, androidFrameworkCompile(b, name))
1192 } else {
1193 deps = append(deps, compile(b, name, parts))
1194 }
borenetdb182c72016-09-30 12:53:12 -07001195 }
1196
Eric Borenf5a90e82016-11-15 15:18:20 -05001197 // Most remaining bots need a compile task.
borenetdb182c72016-09-30 12:53:12 -07001198 compileTaskName := deriveCompileTaskName(name, parts)
borenet52383432016-10-17 10:17:53 -07001199 compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName)
1200 if err != nil {
1201 glog.Fatal(err)
1202 }
Yuqian Li4a577af2018-01-05 11:13:43 -05001203 compileParentName := getParentRevisionName(compileTaskName, compileTaskParts)
1204 compileParentParts, err := jobNameSchema.ParseJobName(compileParentName)
1205 if err != nil {
1206 glog.Fatal(err)
1207 }
1208
Eric Boren628e78b2016-11-17 11:33:27 -05001209 // These bots do not need a compile task.
Yuqian Li4a577af2018-01-05 11:13:43 -05001210 if parts["role"] != "Build" &&
Eric Borenb8ab7f72017-04-10 11:00:09 -04001211 name != "Housekeeper-PerCommit-BundleRecipes" &&
Eric Borenf5a90e82016-11-15 15:18:20 -05001212 name != "Housekeeper-PerCommit-InfraTests" &&
Eric Borenf7928b42017-07-28 07:35:28 -04001213 name != "Housekeeper-PerCommit-CheckGeneratedFiles" &&
Ravi Mistry5e967422018-02-01 13:38:13 -05001214 !strings.Contains(name, "Android_Framework") &&
Eric Boren71b762f2016-11-30 14:05:16 -05001215 !strings.Contains(name, "RecreateSKPs") &&
Ravi Mistry01b48e72017-05-17 14:28:06 -04001216 !strings.Contains(name, "UpdateMetaConfig") &&
Ben Wagner50b84682017-06-12 13:03:29 -04001217 !strings.Contains(name, "-CT_") &&
1218 !strings.Contains(name, "Housekeeper-PerCommit-Isolate") {
boreneted20a702016-10-20 11:04:31 -07001219 compile(b, compileTaskName, compileTaskParts)
Ben Wagner4c39c0d2018-01-10 11:14:52 -05001220 if parts["role"] == "Calmbench" {
Yuqian Li4a577af2018-01-05 11:13:43 -05001221 compile(b, compileParentName, compileParentParts)
1222 }
borenet52383432016-10-17 10:17:53 -07001223 }
borenetdb182c72016-09-30 12:53:12 -07001224
Eric Borenf7928b42017-07-28 07:35:28 -04001225 // Housekeepers.
Eric Boren22f5ef72016-12-02 11:01:33 -05001226 if name == "Housekeeper-PerCommit" {
Eric Boren9d78afd2017-12-07 14:54:05 +00001227 deps = append(deps, housekeeper(b, name, compileTaskName))
borenetdb182c72016-09-30 12:53:12 -07001228 }
Eric Borenf7928b42017-07-28 07:35:28 -04001229 if name == "Housekeeper-PerCommit-CheckGeneratedFiles" {
Eric Boren9d78afd2017-12-07 14:54:05 +00001230 deps = append(deps, checkGeneratedFiles(b, name))
Eric Borenf7928b42017-07-28 07:35:28 -04001231 }
Ravi Mistryd4731e92018-01-02 14:54:43 -05001232 if strings.Contains(name, "Bookmaker") {
Ravi Mistryedc4f3e2017-12-08 12:58:20 -05001233 deps = append(deps, bookmaker(b, name, compileTaskName))
1234 }
borenetdb182c72016-09-30 12:53:12 -07001235
1236 // Common assets needed by the remaining bots.
Kevin Lubick07072942017-05-11 13:35:23 -04001237
1238 pkgs := []*specs.CipdPackage{}
1239
Kevin Lubick90189522017-05-15 08:30:27 -04001240 if deps := getIsolatedCIPDDeps(parts); len(deps) == 0 {
Kevin Lubick07072942017-05-11 13:35:23 -04001241 pkgs = []*specs.CipdPackage{
1242 b.MustGetCipdPackageFromAsset("skimage"),
1243 b.MustGetCipdPackageFromAsset("skp"),
1244 b.MustGetCipdPackageFromAsset("svg"),
1245 }
borenetdb182c72016-09-30 12:53:12 -07001246 }
Kevin Lubick90189522017-05-15 08:30:27 -04001247
Ben Wagner5655ba42017-10-02 10:48:32 -04001248 if strings.Contains(name, "Ubuntu") || strings.Contains(name, "Debian") {
1249 if strings.Contains(name, "SAN") {
1250 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
1251 }
Kevin Lubick35115eb2017-02-17 10:25:34 -05001252 if strings.Contains(name, "Vulkan") {
1253 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
1254 }
Ben Wagner5655ba42017-10-02 10:48:32 -04001255 if strings.Contains(name, "Intel") && strings.Contains(name, "GPU") {
1256 if strings.Contains(name, "Release") {
1257 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_release"))
1258 } else {
1259 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_intel_driver_debug"))
1260 }
Kevin Lubick0a51b482017-02-06 12:45:29 -05001261 }
1262 }
borenetdb182c72016-09-30 12:53:12 -07001263
1264 // Test bots.
Kevin Lubick32f318b2017-10-17 13:40:52 -04001265
1266 if parts["role"] == "Test" {
1267 if strings.Contains(parts["extra_config"], "Coverage") {
1268 deps = append(deps, coverage(b, name, parts, compileTaskName, pkgs))
1269 } else if !strings.Contains(name, "-CT_") {
1270 deps = append(deps, test(b, name, parts, compileTaskName, pkgs))
1271 }
1272
borenetdb182c72016-09-30 12:53:12 -07001273 }
1274
1275 // Perf bots.
Eric Boren71b762f2016-11-30 14:05:16 -05001276 if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -07001277 deps = append(deps, perf(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -07001278 }
1279
Yuqian Li4a577af2018-01-05 11:13:43 -05001280 // Calmbench bots.
1281 if parts["role"] == "Calmbench" {
1282 deps = append(deps, calmbench(b, name, parts, compileTaskName, compileParentName))
1283 }
1284
borenetdb182c72016-09-30 12:53:12 -07001285 // Add the Job spec.
Eric Borenf5a90e82016-11-15 15:18:20 -05001286 j := &specs.JobSpec{
borenetdb182c72016-09-30 12:53:12 -07001287 Priority: 0.8,
1288 TaskSpecs: deps,
Eric Borenba937a42017-07-31 10:41:15 -04001289 Trigger: specs.TRIGGER_ANY_BRANCH,
Eric Borenf5a90e82016-11-15 15:18:20 -05001290 }
Eric Borenba937a42017-07-31 10:41:15 -04001291 if strings.Contains(name, "-Nightly-") {
1292 j.Trigger = specs.TRIGGER_NIGHTLY
Ravi Mistryf06dae82017-10-16 10:31:41 -04001293 } else if strings.Contains(name, "-Weekly-") || strings.Contains(name, "CT_DM_1m_SKPs") {
Eric Borenba937a42017-07-31 10:41:15 -04001294 j.Trigger = specs.TRIGGER_WEEKLY
1295 } else if strings.Contains(name, "Flutter") || strings.Contains(name, "PDFium") || strings.Contains(name, "CommandBuffer") {
1296 j.Trigger = specs.TRIGGER_MASTER_ONLY
Eric Boren71b762f2016-11-30 14:05:16 -05001297 }
Eric Boren8615fe52016-12-12 14:30:12 -05001298 b.MustAddJob(name, j)
borenetdb182c72016-09-30 12:53:12 -07001299}
1300
Eric Boren27225492017-02-01 15:56:55 -05001301func loadJson(flag *string, defaultFlag string, val interface{}) {
1302 if *flag == "" {
1303 *flag = defaultFlag
1304 }
1305 b, err := ioutil.ReadFile(*flag)
1306 if err != nil {
1307 glog.Fatal(err)
1308 }
1309 if err := json.Unmarshal(b, val); err != nil {
1310 glog.Fatal(err)
1311 }
1312}
1313
borenetdb182c72016-09-30 12:53:12 -07001314// Regenerate the tasks.json file.
1315func main() {
boreneted20a702016-10-20 11:04:31 -07001316 b := specs.MustNewTasksCfgBuilder()
Eric Boren27225492017-02-01 15:56:55 -05001317 b.SetAssetsDir(*assetsDir)
1318 infraBots := path.Join(b.CheckoutRoot(), "infra", "bots")
1319
1320 // Load the jobs from a JSON file.
1321 loadJson(jobsFile, path.Join(infraBots, "jobs.json"), &JOBS)
1322
Eric Boren27225492017-02-01 15:56:55 -05001323 // Load general config information from a JSON file.
1324 loadJson(cfgFile, path.Join(infraBots, "cfg.json"), &CONFIG)
1325
borenetdb182c72016-09-30 12:53:12 -07001326 // Create the JobNameSchema.
Eric Boren1f8be682017-02-07 09:16:30 -05001327 if *builderNameSchemaFile == "" {
1328 *builderNameSchemaFile = path.Join(b.CheckoutRoot(), "infra", "bots", "recipe_modules", "builder_name_schema", "builder_name_schema.json")
1329 }
1330 schema, err := NewJobNameSchema(*builderNameSchemaFile)
borenetdb182c72016-09-30 12:53:12 -07001331 if err != nil {
1332 glog.Fatal(err)
1333 }
1334 jobNameSchema = schema
1335
borenetdb182c72016-09-30 12:53:12 -07001336 // Create Tasks and Jobs.
boreneted20a702016-10-20 11:04:31 -07001337 for _, name := range JOBS {
1338 process(b, name)
borenetdb182c72016-09-30 12:53:12 -07001339 }
1340
boreneted20a702016-10-20 11:04:31 -07001341 b.MustFinish()
borenetdb182c72016-09-30 12:53:12 -07001342}
1343
1344// TODO(borenet): The below really belongs in its own file, probably next to the
1345// builder_name_schema.json file.
1346
1347// JobNameSchema is a struct used for (de)constructing Job names in a
1348// predictable format.
1349type JobNameSchema struct {
1350 Schema map[string][]string `json:"builder_name_schema"`
1351 Sep string `json:"builder_name_sep"`
1352}
1353
1354// NewJobNameSchema returns a JobNameSchema instance based on the given JSON
1355// file.
1356func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) {
1357 var rv JobNameSchema
1358 f, err := os.Open(jsonFile)
1359 if err != nil {
1360 return nil, err
1361 }
1362 defer util.Close(f)
1363 if err := json.NewDecoder(f).Decode(&rv); err != nil {
1364 return nil, err
1365 }
1366 return &rv, nil
1367}
1368
1369// ParseJobName splits the given Job name into its component parts, according
1370// to the schema.
1371func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) {
1372 split := strings.Split(n, s.Sep)
1373 if len(split) < 2 {
1374 return nil, fmt.Errorf("Invalid job name: %q", n)
1375 }
1376 role := split[0]
1377 split = split[1:]
1378 keys, ok := s.Schema[role]
1379 if !ok {
1380 return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role)
1381 }
1382 extraConfig := ""
1383 if len(split) == len(keys)+1 {
1384 extraConfig = split[len(split)-1]
1385 split = split[:len(split)-1]
1386 }
1387 if len(split) != len(keys) {
1388 return nil, fmt.Errorf("Invalid job name; %q has incorrect number of parts.", n)
1389 }
1390 rv := make(map[string]string, len(keys)+2)
1391 rv["role"] = role
1392 if extraConfig != "" {
1393 rv["extra_config"] = extraConfig
1394 }
1395 for i, k := range keys {
1396 rv[k] = split[i]
1397 }
1398 return rv, nil
1399}
1400
1401// MakeJobName assembles the given parts of a Job name, according to the schema.
1402func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) {
1403 role, ok := parts["role"]
1404 if !ok {
1405 return "", fmt.Errorf("Invalid job parts; jobs must have a role.")
1406 }
1407 keys, ok := s.Schema[role]
1408 if !ok {
1409 return "", fmt.Errorf("Invalid job parts; unknown role %q", role)
1410 }
1411 rvParts := make([]string, 0, len(parts))
1412 rvParts = append(rvParts, role)
1413 for _, k := range keys {
1414 v, ok := parts[k]
1415 if !ok {
1416 return "", fmt.Errorf("Invalid job parts; missing %q", k)
1417 }
1418 rvParts = append(rvParts, v)
1419 }
1420 if _, ok := parts["extra_config"]; ok {
1421 rvParts = append(rvParts, parts["extra_config"])
1422 }
1423 return strings.Join(rvParts, s.Sep), nil
1424}