blob: 89a6fe28604c32327090729fae34a4e82bf53fd8 [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"
13 "fmt"
borenetdb182c72016-09-30 12:53:12 -070014 "os"
15 "path"
borenetdb182c72016-09-30 12:53:12 -070016 "sort"
17 "strings"
Eric Boren4b254b92016-11-08 12:55:32 -050018 "time"
borenetdb182c72016-09-30 12:53:12 -070019
20 "github.com/skia-dev/glog"
borenetdb182c72016-09-30 12:53:12 -070021 "go.skia.org/infra/go/util"
22 "go.skia.org/infra/task_scheduler/go/specs"
23)
24
25const (
Kevin Lubick797ef162016-12-15 10:45:08 -050026 DEFAULT_OS = DEFAULT_OS_LINUX
27 DEFAULT_OS_LINUX = "Ubuntu-14.04"
borenetdb182c72016-09-30 12:53:12 -070028
29 // Pool for Skia bots.
30 POOL_SKIA = "Skia"
31
32 // Name prefix for upload jobs.
33 PREFIX_UPLOAD = "Upload"
34)
35
36var (
37 // "Constants"
38
39 // Top-level list of all jobs to run at each commit.
40 JOBS = []string{
Eric Boreneaef6152016-11-18 08:24:21 -050041 "Build-Mac-Clang-Arm7-Debug-iOS",
42 "Build-Mac-Clang-Arm7-Release-iOS",
Mike Klein2afffbd2016-12-05 10:42:36 -050043 "Build-Mac-Clang-arm64-Debug-Android",
Mike Klein6749af42016-11-07 15:38:48 -050044 "Build-Mac-Clang-arm64-Debug-GN_iOS",
Mike Klein2afffbd2016-12-05 10:42:36 -050045 "Build-Mac-Clang-x86_64-Debug",
Eric Boren8615fe52016-12-12 14:30:12 -050046 "Build-Mac-Clang-x86_64-Debug-CommandBuffer",
Mike Klein2afffbd2016-12-05 10:42:36 -050047 "Build-Mac-Clang-x86_64-Release",
Eric Boren8615fe52016-12-12 14:30:12 -050048 "Build-Mac-Clang-x86_64-Release-CommandBuffer",
Mike Klein2afffbd2016-12-05 10:42:36 -050049 "Build-Ubuntu-Clang-arm-Debug-Android",
50 "Build-Ubuntu-Clang-arm-Release-Android",
51 "Build-Ubuntu-Clang-arm64-Debug-Android",
52 "Build-Ubuntu-Clang-arm64-Debug-Android_FrameworkDefs",
53 "Build-Ubuntu-Clang-arm64-Debug-Android_Vulkan",
54 "Build-Ubuntu-Clang-arm64-Release-Android",
55 "Build-Ubuntu-Clang-arm64-Release-Android_Vulkan",
56 "Build-Ubuntu-Clang-mips64el-Debug-Android",
57 "Build-Ubuntu-Clang-mips64el-Release-Android",
58 "Build-Ubuntu-Clang-mipsel-Debug-Android",
59 "Build-Ubuntu-Clang-mipsel-Release-Android",
60 "Build-Ubuntu-Clang-x64-Debug-Android",
61 "Build-Ubuntu-Clang-x64-Release-Android",
62 "Build-Ubuntu-Clang-x86-Debug-Android",
63 "Build-Ubuntu-Clang-x86-Debug-Android_Vulkan",
64 "Build-Ubuntu-Clang-x86-Release-Android",
65 "Build-Ubuntu-Clang-x86-Release-Android_Vulkan",
66 "Build-Ubuntu-Clang-x86_64-Debug",
Eric Boren8615fe52016-12-12 14:30:12 -050067 "Build-Ubuntu-Clang-x86_64-Debug-ASAN",
68 "Build-Ubuntu-Clang-x86_64-Debug-MSAN",
Kevin Lubick9c7dcac2017-01-18 09:24:56 -050069 "Build-Ubuntu-Clang-x86_64-Debug-Vulkan",
Mike Klein2afffbd2016-12-05 10:42:36 -050070 "Build-Ubuntu-Clang-x86_64-Release",
Mike Kleind8ee67c2017-01-19 12:14:50 -050071 "Build-Ubuntu-Clang-x86_64-Release-ASAN",
Mike Klein56770752017-01-05 08:09:57 -050072 "Build-Ubuntu-Clang-x86_64-Release-Fast",
Eric Boren8615fe52016-12-12 14:30:12 -050073 "Build-Ubuntu-Clang-x86_64-Release-TSAN",
Kevin Lubick9c7dcac2017-01-18 09:24:56 -050074 "Build-Ubuntu-Clang-x86_64-Release-Vulkan",
Eric Boren50831302016-11-18 13:10:51 -050075 "Build-Ubuntu-GCC-x86-Debug",
76 "Build-Ubuntu-GCC-x86-Release",
Mike Klein2afffbd2016-12-05 10:42:36 -050077 "Build-Ubuntu-GCC-x86_64-Debug",
Eric Boren50831302016-11-18 13:10:51 -050078 "Build-Ubuntu-GCC-x86_64-Debug-NoGPU",
Eric Boren8615fe52016-12-12 14:30:12 -050079 "Build-Ubuntu-GCC-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
Mike Klein2afffbd2016-12-05 10:42:36 -050080 "Build-Ubuntu-GCC-x86_64-Release",
Eric Boren50831302016-11-18 13:10:51 -050081 "Build-Ubuntu-GCC-x86_64-Release-ANGLE",
Eric Boren50831302016-11-18 13:10:51 -050082 "Build-Ubuntu-GCC-x86_64-Release-Mesa",
83 "Build-Ubuntu-GCC-x86_64-Release-NoGPU",
84 "Build-Ubuntu-GCC-x86_64-Release-PDFium",
Eric Boren3dc73f32016-12-13 08:48:46 -050085 "Build-Ubuntu-GCC-x86_64-Release-PDFium_SkiaPaths",
Eric Boren8615fe52016-12-12 14:30:12 -050086 "Build-Ubuntu-GCC-x86_64-Release-SKNX_NO_SIMD",
87 "Build-Ubuntu-GCC-x86_64-Release-Shared",
Eric Borenbd488f82016-11-23 11:03:28 -050088 "Build-Ubuntu-GCC-x86_64-Release-Valgrind",
Mike Klein2afffbd2016-12-05 10:42:36 -050089 "Build-Win-Clang-arm64-Release-Android",
Eric Borencb4feeb2016-11-28 10:12:09 -050090 "Build-Win-MSVC-x86-Debug",
91 "Build-Win-MSVC-x86-Debug-ANGLE",
92 "Build-Win-MSVC-x86-Debug-Exceptions",
93 "Build-Win-MSVC-x86-Debug-GDI",
94 "Build-Win-MSVC-x86-Release",
95 "Build-Win-MSVC-x86-Release-ANGLE",
96 "Build-Win-MSVC-x86-Release-GDI",
97 "Build-Win-MSVC-x86_64-Debug",
Eric Boren8615fe52016-12-12 14:30:12 -050098 "Build-Win-MSVC-x86_64-Debug-ANGLE",
99 "Build-Win-MSVC-x86_64-Debug-GDI",
100 "Build-Win-MSVC-x86_64-Debug-Vulkan",
Eric Borencb4feeb2016-11-28 10:12:09 -0500101 "Build-Win-MSVC-x86_64-Release",
Eric Boren8615fe52016-12-12 14:30:12 -0500102 "Build-Win-MSVC-x86_64-Release-ANGLE",
103 "Build-Win-MSVC-x86_64-Release-GDI",
Eric Borencb4feeb2016-11-28 10:12:09 -0500104 "Build-Win-MSVC-x86_64-Release-Vulkan",
Eric Borenf5a90e82016-11-15 15:18:20 -0500105 "Housekeeper-Nightly-RecreateSKPs_Canary",
Eric Boren22f5ef72016-12-02 11:01:33 -0500106 "Housekeeper-PerCommit",
Eric Boren792079c2016-11-09 14:03:20 -0500107 "Housekeeper-PerCommit-InfraTests",
Eric Borenf5a90e82016-11-15 15:18:20 -0500108 "Housekeeper-Weekly-RecreateSKPs",
Mike Klein2afffbd2016-12-05 10:42:36 -0500109 "Perf-Android-Clang-AndroidOne-CPU-MT6582-arm-Debug-Android",
110 "Perf-Android-Clang-AndroidOne-CPU-MT6582-arm-Release-Android",
111 "Perf-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Debug-Android",
112 "Perf-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Release-Android",
113 "Perf-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Debug-Android",
114 "Perf-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Debug-Android_Vulkan",
115 "Perf-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Release-Android",
116 "Perf-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Release-Android_Vulkan",
117 "Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android",
118 "Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android_Vulkan",
119 "Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Release-Android",
120 "Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Release-Android_Vulkan",
121 "Perf-Android-Clang-Nexus10-GPU-MaliT604-arm-Debug-Android",
122 "Perf-Android-Clang-Nexus10-GPU-MaliT604-arm-Release-Android",
123 "Perf-Android-Clang-Nexus5-GPU-Adreno330-arm-Debug-Android",
124 "Perf-Android-Clang-Nexus5-GPU-Adreno330-arm-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500125 "Perf-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Debug-Android",
126 "Perf-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Debug-Android_Vulkan",
127 "Perf-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Release-Android",
128 "Perf-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Release-Android_Vulkan",
129 "Perf-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-Android",
130 "Perf-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500131 "Perf-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Debug-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500132 "Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Debug-Android",
Greg Daniel879bdc92016-12-19 09:28:50 -0500133 // "Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Debug-Android_Vulkan",
Mike Klein2afffbd2016-12-05 10:42:36 -0500134 "Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android",
Greg Daniel879bdc92016-12-19 09:28:50 -0500135 // "Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android_Vulkan",
Mike Klein2afffbd2016-12-05 10:42:36 -0500136 "Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Debug-Android",
137 "Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Debug-Android_Vulkan",
138 "Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Release-Android",
139 "Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Release-Android_Vulkan",
Kevin Lubicke29ce642016-12-09 11:11:33 -0500140 "Perf-Android-Clang-PixelC-CPU-TegraX1-arm64-Debug-Android",
141 "Perf-Android-Clang-PixelC-CPU-TegraX1-arm64-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500142 "Perf-Android-Clang-PixelC-GPU-TegraX1-arm64-Release-Android_Skpbench",
143 "Perf-Android-Clang-PixelC-GPU-TegraX1-arm64-Release-Android_Vulkan_Skpbench",
144 "Perf-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Debug",
145 "Perf-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release",
146 "Perf-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Debug",
147 "Perf-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Release",
148 "Perf-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug",
149 "Perf-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Release",
Eric Borenb409c6a2016-11-28 07:22:18 -0500150 "Perf-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Release-CommandBuffer",
Mike Klein2afffbd2016-12-05 10:42:36 -0500151 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug",
Eric Boren50831302016-11-18 13:10:51 -0500152 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN",
Eric Boren50831302016-11-18 13:10:51 -0500153 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN",
Mike Klein2afffbd2016-12-05 10:42:36 -0500154 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release",
Mike Kleind8ee67c2017-01-19 12:14:50 -0500155 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-ASAN",
Mike Klein56770752017-01-05 08:09:57 -0500156 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-Fast",
Eric Borenbd488f82016-11-23 11:03:28 -0500157 "Perf-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Debug-ASAN",
Mike Kleind8ee67c2017-01-19 12:14:50 -0500158 "Perf-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Release-ASAN",
Eric Boren50831302016-11-18 13:10:51 -0500159 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug",
Mike Klein2afffbd2016-12-05 10:42:36 -0500160 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug",
Eric Boren50831302016-11-18 13:10:51 -0500161 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
Mike Klein2afffbd2016-12-05 10:42:36 -0500162 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release",
Eric Boren71b762f2016-11-30 14:05:16 -0500163 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-CT_BENCH_1k_SKPs",
Eric Boren71b762f2016-11-30 14:05:16 -0500164 "Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_1k_SKPs",
Eric Borenbd488f82016-11-23 11:03:28 -0500165 "Perf-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind",
Mike Klein2afffbd2016-12-05 10:42:36 -0500166 "Perf-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Debug",
167 "Perf-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Release",
Kevin Lubick893c49e2017-01-17 15:15:40 -0500168 "Perf-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Debug",
169 "Perf-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Release",
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500170 "Perf-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Debug-Vulkan",
171 "Perf-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500172 "Perf-Win10-MSVC-Golo-GPU-GT610-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500173 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug",
174 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug-ANGLE",
175 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug-Vulkan",
176 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release",
177 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release-ANGLE",
178 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500179 "Perf-Win10-MSVC-NUC-GPU-IntelIris6100-x86_64-Debug-ANGLE",
180 "Perf-Win10-MSVC-NUC-GPU-IntelIris6100-x86_64-Release-ANGLE",
Ben Wagner17f811b2016-12-22 08:40:14 -0500181 "Perf-Win10-MSVC-ShuttleA-GPU-AMDHD7770-x86_64-Debug",
182 "Perf-Win10-MSVC-ShuttleA-GPU-AMDHD7770-x86_64-Release",
Eric Boren78f5af72016-11-30 12:49:00 -0500183 "Perf-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug",
184 "Perf-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug-Vulkan",
185 "Perf-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Release",
186 "Perf-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Release-Vulkan",
Ben Wagner17f811b2016-12-22 08:40:14 -0500187 "Perf-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Debug",
188 "Perf-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Release",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500189 "Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Debug",
190 "Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Debug-ANGLE",
191 "Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release",
192 "Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release-ANGLE",
193 "Perf-Win10-MSVC-ShuttleC-GPU-iHD530-x86_64-Debug",
194 "Perf-Win10-MSVC-ShuttleC-GPU-iHD530-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500195 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug",
196 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug-ANGLE",
197 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug-Vulkan",
198 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release",
199 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release-ANGLE",
200 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500201 "Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86-Debug",
202 "Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug",
203 "Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug-GDI",
204 "Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Release",
Eric Boren792079c2016-11-09 14:03:20 -0500205 "Perf-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Debug",
206 "Perf-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Release",
Mike Klein2afffbd2016-12-05 10:42:36 -0500207 "Test-Android-Clang-AndroidOne-CPU-MT6582-arm-Debug-Android",
208 "Test-Android-Clang-AndroidOne-CPU-MT6582-arm-Release-Android",
209 "Test-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Debug-Android",
210 "Test-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Release-Android",
211 "Test-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Debug-Android",
212 "Test-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Debug-Android_Vulkan",
213 "Test-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Release-Android",
214 "Test-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Release-Android_Vulkan",
Kevin Lubick56ff9a12016-12-14 08:48:00 -0500215 "Test-Android-Clang-GalaxyTab3-GPU-Vivante-arm-Debug-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500216 "Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android",
217 "Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android_Vulkan",
218 "Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Release-Android",
219 "Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Release-Android_Vulkan",
220 "Test-Android-Clang-Nexus10-GPU-MaliT604-arm-Debug-Android",
221 "Test-Android-Clang-Nexus10-GPU-MaliT604-arm-Release-Android",
222 "Test-Android-Clang-Nexus5-GPU-Adreno330-arm-Debug-Android",
223 "Test-Android-Clang-Nexus5-GPU-Adreno330-arm-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500224 "Test-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Debug-Android",
225 "Test-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Debug-Android_Vulkan",
226 "Test-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Release-Android",
227 "Test-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Release-Android_Vulkan",
228 "Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-Android",
229 "Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500230 "Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Debug-Android",
231 "Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-Android",
232 "Test-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Debug-Android",
Greg Daniel80a08dd2017-01-20 10:45:49 -0500233 "Test-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Debug-Android_Vulkan",
Mike Klein2afffbd2016-12-05 10:42:36 -0500234 "Test-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android",
Greg Daniel80a08dd2017-01-20 10:45:49 -0500235 "Test-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android_Vulkan",
Kevin Lubicke29ce642016-12-09 11:11:33 -0500236 "Test-Android-Clang-PixelC-CPU-TegraX1-arm64-Debug-Android",
237 "Test-Android-Clang-PixelC-CPU-TegraX1-arm64-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500238 "Test-Android-Clang-PixelXL-GPU-Adreno530-arm64-Debug-Android",
239 "Test-Android-Clang-PixelXL-GPU-Adreno530-arm64-Debug-Android_Vulkan",
240 "Test-Android-Clang-PixelXL-GPU-Adreno530-arm64-Release-Android",
241 "Test-Android-Clang-PixelXL-GPU-Adreno530-arm64-Release-Android_Vulkan",
242 "Test-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Debug",
243 "Test-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release",
244 "Test-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Debug",
245 "Test-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Release",
246 "Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug",
Eric Borenb409c6a2016-11-28 07:22:18 -0500247 "Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug-CommandBuffer",
Mike Klein2afffbd2016-12-05 10:42:36 -0500248 "Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Release",
249 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug",
Eric Boren50831302016-11-18 13:10:51 -0500250 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN",
Eric Boren50831302016-11-18 13:10:51 -0500251 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN",
Mike Klein2afffbd2016-12-05 10:42:36 -0500252 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release",
Mike Kleind8ee67c2017-01-19 12:14:50 -0500253 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-ASAN",
Mike Klein56770752017-01-05 08:09:57 -0500254 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-Fast",
Eric Boren50831302016-11-18 13:10:51 -0500255 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-TSAN",
Eric Borenbd488f82016-11-23 11:03:28 -0500256 "Test-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Debug-ASAN",
Mike Kleind8ee67c2017-01-19 12:14:50 -0500257 "Test-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Release-ASAN",
Eric Borenbd488f82016-11-23 11:03:28 -0500258 "Test-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Release-TSAN",
Eric Boren50831302016-11-18 13:10:51 -0500259 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug",
Mike Klein2afffbd2016-12-05 10:42:36 -0500260 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug",
Eric Boren71b762f2016-11-30 14:05:16 -0500261 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_100k_SKPs",
262 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs",
263 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_100k_SKPs",
Eric Boren50831302016-11-18 13:10:51 -0500264 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
Mike Klein2afffbd2016-12-05 10:42:36 -0500265 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release",
Eric Boren50831302016-11-18 13:10:51 -0500266 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD",
Eric Borenbd488f82016-11-23 11:03:28 -0500267 "Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind",
Mike Klein2afffbd2016-12-05 10:42:36 -0500268 "Test-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Debug",
269 "Test-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Release",
Kevin Lubick893c49e2017-01-17 15:15:40 -0500270 "Test-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Debug",
271 "Test-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Release",
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500272 "Test-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Debug-Vulkan",
273 "Test-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500274 "Test-Win10-MSVC-Golo-GPU-GT610-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500275 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug",
276 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug-ANGLE",
277 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug-Vulkan",
278 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release",
279 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release-ANGLE",
280 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500281 "Test-Win10-MSVC-NUC-GPU-IntelIris6100-x86_64-Debug-ANGLE",
282 "Test-Win10-MSVC-NUC-GPU-IntelIris6100-x86_64-Release-ANGLE",
Ben Wagner17f811b2016-12-22 08:40:14 -0500283 "Test-Win10-MSVC-ShuttleA-GPU-AMDHD7770-x86_64-Debug",
284 "Test-Win10-MSVC-ShuttleA-GPU-AMDHD7770-x86_64-Release",
Eric Boren78f5af72016-11-30 12:49:00 -0500285 "Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug",
286 "Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug-Vulkan",
287 "Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500288 "Test-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Debug",
289 "Test-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Release",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500290 "Test-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Debug",
291 "Test-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Debug-ANGLE",
292 "Test-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release",
293 "Test-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release-ANGLE",
294 "Test-Win10-MSVC-ShuttleC-GPU-iHD530-x86_64-Debug",
295 "Test-Win10-MSVC-ShuttleC-GPU-iHD530-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500296 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug",
297 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug-ANGLE",
298 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug-Vulkan",
299 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release",
300 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release-ANGLE",
301 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500302 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86-Debug",
303 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86-Release",
304 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug",
305 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug-GDI",
306 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Release",
307 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Release-GDI",
Eric Boren792079c2016-11-09 14:03:20 -0500308 "Test-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Debug",
309 "Test-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Release",
borenetdb182c72016-09-30 12:53:12 -0700310 }
311
Eric Boren4b254b92016-11-08 12:55:32 -0500312 // LINUX_GCE_DIMENSIONS are the Swarming dimensions for Linux GCE
313 // instances.
314 LINUX_GCE_DIMENSIONS = []string{
borenetdb182c72016-09-30 12:53:12 -0700315 "cpu:x86-64-avx2",
316 "gpu:none",
Kevin Lubick797ef162016-12-15 10:45:08 -0500317 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX),
borenetdb182c72016-09-30 12:53:12 -0700318 fmt.Sprintf("pool:%s", POOL_SKIA),
319 }
320
321 // Defines the structure of job names.
322 jobNameSchema *JobNameSchema
borenetdb182c72016-09-30 12:53:12 -0700323)
324
325// deriveCompileTaskName returns the name of a compile task based on the given
326// job name.
327func deriveCompileTaskName(jobName string, parts map[string]string) string {
328 if parts["role"] == "Housekeeper" {
329 return "Build-Ubuntu-GCC-x86_64-Release-Shared"
330 } else if parts["role"] == "Test" || parts["role"] == "Perf" {
331 task_os := parts["os"]
332 ec := parts["extra_config"]
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500333 ec = strings.TrimSuffix(ec, "_Skpbench")
borenetdb182c72016-09-30 12:53:12 -0700334 if task_os == "Android" {
335 if ec == "Vulkan" {
336 ec = "Android_Vulkan"
borenetdb182c72016-09-30 12:53:12 -0700337 }
borenet52383432016-10-17 10:17:53 -0700338 task_os = "Ubuntu"
borenetdb182c72016-09-30 12:53:12 -0700339 } else if task_os == "iOS" {
340 ec = task_os
341 task_os = "Mac"
342 } else if strings.Contains(task_os, "Win") {
343 task_os = "Win"
Kevin Lubick893c49e2017-01-17 15:15:40 -0500344 } else if strings.Contains(task_os, "Ubuntu") {
345 task_os = "Ubuntu"
borenetdb182c72016-09-30 12:53:12 -0700346 }
Eric Boren50831302016-11-18 13:10:51 -0500347 jobNameMap := map[string]string{
borenetdb182c72016-09-30 12:53:12 -0700348 "role": "Build",
349 "os": task_os,
350 "compiler": parts["compiler"],
351 "target_arch": parts["arch"],
352 "configuration": parts["configuration"],
Eric Boren50831302016-11-18 13:10:51 -0500353 }
354 if ec != "" {
355 jobNameMap["extra_config"] = ec
356 }
357 name, err := jobNameSchema.MakeJobName(jobNameMap)
borenetdb182c72016-09-30 12:53:12 -0700358 if err != nil {
359 glog.Fatal(err)
360 }
361 return name
362 } else {
363 return jobName
364 }
365}
366
367// swarmDimensions generates swarming bot dimensions for the given task.
368func swarmDimensions(parts map[string]string) []string {
borenetdb182c72016-09-30 12:53:12 -0700369 d := map[string]string{
370 "pool": POOL_SKIA,
371 }
372 if os, ok := parts["os"]; ok {
Eric Boren54ff2fc2016-12-02 12:09:10 -0500373 d["os"] = map[string]string{
Kevin Lubick893c49e2017-01-17 15:15:40 -0500374 "Android": "Android",
375 "Mac": "Mac-10.11",
376 "Ubuntu": DEFAULT_OS_LINUX,
377 "Ubuntu16": "Ubuntu-16.04",
378 "Win": "Windows-2008ServerR2-SP1",
379 "Win10": "Windows-10-14393",
380 "Win2k8": "Windows-2008ServerR2-SP1",
381 "Win8": "Windows-8.1-SP0",
382 "iOS": "iOS-9.3.1",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500383 }[os]
Ben Wagner73557372016-12-29 16:27:03 -0500384 // Chrome Golo has a different Windows image.
385 if parts["model"] == "Golo" && os == "Win10" {
386 d["os"] = "Windows-10-10586"
Ben Wagner17f811b2016-12-22 08:40:14 -0500387 }
borenetdb182c72016-09-30 12:53:12 -0700388 } else {
389 d["os"] = DEFAULT_OS
390 }
borenetdb182c72016-09-30 12:53:12 -0700391 if parts["role"] == "Test" || parts["role"] == "Perf" {
392 if strings.Contains(parts["os"], "Android") {
393 // For Android, the device type is a better dimension
394 // than CPU or GPU.
Eric Boren4b254b92016-11-08 12:55:32 -0500395 deviceInfo := map[string][]string{
396 "AndroidOne": {"sprout", "MOB30Q"},
397 "GalaxyS7": {"heroqlteatt", "MMB29M"},
Kevin Lubick56ff9a12016-12-14 08:48:00 -0500398 "GalaxyTab3": {"goyawifi", "JDQ39"},
Eric Boren4b254b92016-11-08 12:55:32 -0500399 "NVIDIA_Shield": {"foster", "MRA58K"},
400 "Nexus10": {"manta", "LMY49J"},
Kevin Lubicke2d41412016-12-28 10:10:09 -0500401 "Nexus5": {"hammerhead", "M4B30Z"},
Eric Boren4b254b92016-11-08 12:55:32 -0500402 "Nexus6": {"shamu", "M"},
403 "Nexus6p": {"angler", "NMF26C"},
404 "Nexus7": {"grouper", "LMY47V"},
405 "Nexus7v2": {"flo", "M"},
Kevin Lubick5ac82602017-01-13 09:37:03 -0500406 "NexusPlayer": {"fugu", "N2G10B"},
Kevin Lubick7cf77452016-12-28 13:35:13 -0500407 "Pixel": {"sailfish", "NMF26Q"},
Kevin Lubickeaef5492016-12-15 12:36:12 -0500408 "PixelC": {"dragon", "NMF26H"},
Kevin Lubick7cf77452016-12-28 13:35:13 -0500409 "PixelXL": {"marlin", "NMF26Q"},
borenetdb182c72016-09-30 12:53:12 -0700410 }[parts["model"]]
Eric Boren4b254b92016-11-08 12:55:32 -0500411 d["device_type"] = deviceInfo[0]
412 d["device_os"] = deviceInfo[1]
borenetdb182c72016-09-30 12:53:12 -0700413 } else if strings.Contains(parts["os"], "iOS") {
414 d["device"] = map[string]string{
Eric Boren792079c2016-11-09 14:03:20 -0500415 "iPadMini4": "iPad5,1",
borenetdb182c72016-09-30 12:53:12 -0700416 }[parts["model"]]
borenetdb182c72016-09-30 12:53:12 -0700417 } else if parts["cpu_or_gpu"] == "CPU" {
418 d["gpu"] = "none"
419 d["cpu"] = map[string]string{
420 "AVX": "x86-64",
421 "AVX2": "x86-64-avx2",
422 "SSE4": "x86-64",
423 }[parts["cpu_or_gpu_value"]]
424 if strings.Contains(parts["os"], "Win") && parts["cpu_or_gpu_value"] == "AVX2" {
425 // AVX2 is not correctly detected on Windows. Fall back on other
426 // dimensions to ensure that we correctly target machines which we know
427 // have AVX2 support.
428 d["cpu"] = "x86-64"
429 d["os"] = "Windows-2008ServerR2-SP1"
430 }
431 } else {
432 d["gpu"] = map[string]string{
Ben Wagner17f811b2016-12-22 08:40:14 -0500433 "AMDHD7770": "1002:683d",
434 "GeForce320M": "10de:08a4",
435 "GT610": "10de:104a",
436 "GTX1070": "10de:1ba1",
437 "GTX550Ti": "10de:1244",
438 "GTX660": "10de:11c0",
439 "GTX960": "10de:1401",
440 // TODO(benjaminwagner): This device ID doesn't
441 // match HD4000.
442 "HD4000": "8086:0a2e",
443 // This bot will eventually go away, so I'm not
444 // going to bother renaming it.
Eric Boren4b254b92016-11-08 12:55:32 -0500445 "iHD530": "8086:1912",
Ben Wagner17f811b2016-12-22 08:40:14 -0500446 "IntelHD4600": "8086:0412",
447 "IntelIris540": "8086:1926",
Eric Boren4b254b92016-11-08 12:55:32 -0500448 "IntelIris6100": "8086:162b",
borenetdb182c72016-09-30 12:53:12 -0700449 }[parts["cpu_or_gpu_value"]]
450 }
451 } else {
452 d["gpu"] = "none"
453 }
454 rv := make([]string, 0, len(d))
455 for k, v := range d {
456 rv = append(rv, fmt.Sprintf("%s:%s", k, v))
457 }
458 sort.Strings(rv)
459 return rv
460}
461
borenetdb182c72016-09-30 12:53:12 -0700462// compile generates a compile task. Returns the name of the last task in the
463// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700464func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string {
borenetdb182c72016-09-30 12:53:12 -0700465 // Collect the necessary CIPD packages.
466 pkgs := []*specs.CipdPackage{}
467
468 // Android bots require a toolchain.
469 if strings.Contains(name, "Android") {
borenetdb182c72016-09-30 12:53:12 -0700470 if strings.Contains(name, "Mac") {
boreneted20a702016-10-20 11:04:31 -0700471 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_darwin"))
Mike Klein86c2c0f2016-11-02 13:13:16 -0400472 } else if strings.Contains(name, "Win") {
Mike Kleine9215f02016-11-02 15:44:26 -0400473 pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows")
474 pkg.Path = "n"
475 pkgs = append(pkgs, pkg)
borenetdb182c72016-09-30 12:53:12 -0700476 } else {
boreneted20a702016-10-20 11:04:31 -0700477 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_linux"))
borenetdb182c72016-09-30 12:53:12 -0700478 }
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500479 } else if strings.Contains(name, "Ubuntu") {
480 if strings.Contains(name, "Clang") {
481 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
482 }
483 if strings.Contains(name, "Vulkan") {
484 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
485 }
Mike Klein27dcee12016-11-09 16:31:42 -0500486 } else if strings.Contains(name, "Win") {
boreneted20a702016-10-20 11:04:31 -0700487 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_toolchain"))
borenetdb182c72016-09-30 12:53:12 -0700488 if strings.Contains(name, "Vulkan") {
boreneted20a702016-10-20 11:04:31 -0700489 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_vulkan_sdk"))
borenetdb182c72016-09-30 12:53:12 -0700490 }
491 }
492
493 // Add the task.
boreneted20a702016-10-20 11:04:31 -0700494 b.MustAddTask(name, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700495 CipdPackages: pkgs,
496 Dimensions: swarmDimensions(parts),
497 ExtraArgs: []string{
498 "--workdir", "../../..", "swarm_compile",
skia.buildbots2478c732016-11-04 14:37:26 -0400499 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700500 fmt.Sprintf("buildername=%s", name),
501 "mastername=fake-master",
502 "buildnumber=2",
503 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700504 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700505 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
506 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700507 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400508 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
509 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700510 },
511 Isolate: "compile_skia.isolate",
512 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700513 })
Eric Boren8615fe52016-12-12 14:30:12 -0500514 // All compile tasks are runnable as their own Job. Assert that the Job
515 // is listed in JOBS.
516 if !util.In(name, JOBS) {
517 glog.Fatalf("Job %q is missing from the JOBS list!", name)
518 }
borenetdb182c72016-09-30 12:53:12 -0700519 return name
520}
521
522// recreateSKPs generates a RecreateSKPs task. Returns the name of the last
523// task in the generated chain of tasks, which the Job should add as a
524// dependency.
boreneted20a702016-10-20 11:04:31 -0700525func recreateSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500526 b.MustAddTask(name, &specs.TaskSpec{
Eric Borenf5a90e82016-11-15 15:18:20 -0500527 CipdPackages: []*specs.CipdPackage{},
528 Dimensions: LINUX_GCE_DIMENSIONS,
529 ExecutionTimeout: 4 * time.Hour,
Eric Boren4b254b92016-11-08 12:55:32 -0500530 ExtraArgs: []string{
531 "--workdir", "../../..", "swarm_RecreateSKPs",
532 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
533 fmt.Sprintf("buildername=%s", name),
534 "mastername=fake-master",
535 "buildnumber=2",
536 "slavename=fake-buildslave",
537 "nobuildbot=True",
538 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
539 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
540 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
541 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
542 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
543 },
Eric Borenf5a90e82016-11-15 15:18:20 -0500544 IoTimeout: 40 * time.Minute,
545 Isolate: "compile_skia.isolate",
546 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500547 })
borenetdb182c72016-09-30 12:53:12 -0700548 return name
549}
550
551// ctSKPs generates a CT SKPs task. Returns the name of the last task in the
552// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700553func ctSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500554 b.MustAddTask(name, &specs.TaskSpec{
555 CipdPackages: []*specs.CipdPackage{},
556 Dimensions: []string{"pool:SkiaCT"},
557 ExecutionTimeout: 24 * time.Hour,
558 ExtraArgs: []string{
559 "--workdir", "../../..", "swarm_ct_skps",
560 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
561 fmt.Sprintf("buildername=%s", name),
562 "mastername=fake-master",
563 "buildnumber=2",
564 "slavename=fake-buildslave",
565 "nobuildbot=True",
566 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
567 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
568 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
569 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
570 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
571 },
572 IoTimeout: time.Hour,
573 Isolate: "ct_skps_skia.isolate",
574 Priority: 0.8,
575 })
borenetdb182c72016-09-30 12:53:12 -0700576 return name
577}
578
579// housekeeper generates a Housekeeper task. Returns the name of the last task
580// in the generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700581func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500582 b.MustAddTask(name, &specs.TaskSpec{
Eric Boren22f5ef72016-12-02 11:01:33 -0500583 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren4b254b92016-11-08 12:55:32 -0500584 Dependencies: []string{compileTaskName},
585 Dimensions: LINUX_GCE_DIMENSIONS,
586 ExtraArgs: []string{
587 "--workdir", "../../..", "swarm_housekeeper",
588 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
589 fmt.Sprintf("buildername=%s", name),
590 "mastername=fake-master",
591 "buildnumber=2",
592 "slavename=fake-buildslave",
593 "nobuildbot=True",
594 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
595 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
596 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
597 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
598 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
599 },
600 Isolate: "housekeeper_skia.isolate",
601 Priority: 0.8,
602 })
borenetdb182c72016-09-30 12:53:12 -0700603 return name
604}
605
borenet2dbbfa52016-10-14 06:32:09 -0700606// infra generates an infra_tests task. Returns the name of the last task in the
607// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700608func infra(b *specs.TasksCfgBuilder, name string) string {
609 b.MustAddTask(name, &specs.TaskSpec{
borenet2dbbfa52016-10-14 06:32:09 -0700610 CipdPackages: []*specs.CipdPackage{},
Eric Boren4b254b92016-11-08 12:55:32 -0500611 Dimensions: LINUX_GCE_DIMENSIONS,
borenet2dbbfa52016-10-14 06:32:09 -0700612 ExtraArgs: []string{
613 "--workdir", "../../..", "swarm_infra",
skia.buildbots2478c732016-11-04 14:37:26 -0400614 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenet2dbbfa52016-10-14 06:32:09 -0700615 fmt.Sprintf("buildername=%s", name),
616 "mastername=fake-master",
617 "buildnumber=2",
618 "slavename=fake-buildslave",
619 "nobuildbot=True",
620 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
621 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
622 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400623 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
624 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenet2dbbfa52016-10-14 06:32:09 -0700625 },
626 Isolate: "infra_skia.isolate",
627 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700628 })
borenet2dbbfa52016-10-14 06:32:09 -0700629 return name
630}
631
borenetdb182c72016-09-30 12:53:12 -0700632// doUpload indicates whether the given Job should upload its results.
633func doUpload(name string) bool {
634 skipUploadBots := []string{
635 "ASAN",
636 "Coverage",
637 "MSAN",
638 "TSAN",
639 "UBSAN",
640 "Valgrind",
641 }
642 for _, s := range skipUploadBots {
643 if strings.Contains(name, s) {
644 return false
645 }
646 }
647 return true
648}
649
650// test generates a Test task. Returns the name of the last task in the
651// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700652func test(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500653 s := &specs.TaskSpec{
Eric Boren1f2f64b2016-11-09 18:35:15 -0500654 CipdPackages: pkgs,
655 Dependencies: []string{compileTaskName},
656 Dimensions: swarmDimensions(parts),
657 ExecutionTimeout: 4 * time.Hour,
658 Expiration: 20 * time.Hour,
borenetdb182c72016-09-30 12:53:12 -0700659 ExtraArgs: []string{
660 "--workdir", "../../..", "swarm_test",
skia.buildbots2478c732016-11-04 14:37:26 -0400661 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700662 fmt.Sprintf("buildername=%s", name),
663 "mastername=fake-master",
664 "buildnumber=2",
665 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700666 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700667 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
668 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700669 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400670 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
671 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700672 },
Eric Boren1f2f64b2016-11-09 18:35:15 -0500673 IoTimeout: 40 * time.Minute,
674 Isolate: "test_skia.isolate",
675 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500676 }
677 if strings.Contains(parts["extra_config"], "Valgrind") {
678 s.ExecutionTimeout = 9 * time.Hour
679 s.Expiration = 48 * time.Hour
680 s.IoTimeout = time.Hour
681 } else if strings.Contains(parts["extra_config"], "MSAN") {
682 s.ExecutionTimeout = 9 * time.Hour
683 }
684 b.MustAddTask(name, s)
685
borenetdb182c72016-09-30 12:53:12 -0700686 // Upload results if necessary.
687 if doUpload(name) {
688 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700689 b.MustAddTask(uploadName, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700690 Dependencies: []string{name},
Eric Boren4b254b92016-11-08 12:55:32 -0500691 Dimensions: LINUX_GCE_DIMENSIONS,
borenetdb182c72016-09-30 12:53:12 -0700692 ExtraArgs: []string{
693 "--workdir", "../../..", "upload_dm_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400694 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700695 fmt.Sprintf("buildername=%s", name),
696 "mastername=fake-master",
697 "buildnumber=2",
698 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700699 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700700 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
701 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700702 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400703 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
704 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700705 },
706 Isolate: "upload_dm_results.isolate",
707 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700708 })
borenetdb182c72016-09-30 12:53:12 -0700709 return uploadName
710 }
711 return name
712}
713
714// perf generates a Perf task. Returns the name of the last task in the
715// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700716func perf(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500717 recipe := "swarm_perf"
718 isolate := "perf_skia.isolate"
719 if strings.Contains(parts["extra_config"], "Skpbench") {
720 recipe = "swarm_skpbench"
721 isolate = "skpbench_skia.isolate"
722 }
Eric Boren4b254b92016-11-08 12:55:32 -0500723 s := &specs.TaskSpec{
Eric Boren1f2f64b2016-11-09 18:35:15 -0500724 CipdPackages: pkgs,
725 Dependencies: []string{compileTaskName},
726 Dimensions: swarmDimensions(parts),
727 ExecutionTimeout: 4 * time.Hour,
728 Expiration: 20 * time.Hour,
borenetdb182c72016-09-30 12:53:12 -0700729 ExtraArgs: []string{
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500730 "--workdir", "../../..", recipe,
skia.buildbots2478c732016-11-04 14:37:26 -0400731 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700732 fmt.Sprintf("buildername=%s", name),
733 "mastername=fake-master",
734 "buildnumber=2",
735 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700736 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700737 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
738 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700739 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400740 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
741 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700742 },
Eric Boren1f2f64b2016-11-09 18:35:15 -0500743 IoTimeout: 40 * time.Minute,
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500744 Isolate: isolate,
Eric Boren1f2f64b2016-11-09 18:35:15 -0500745 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500746 }
747 if strings.Contains(parts["extra_config"], "Valgrind") {
748 s.ExecutionTimeout = 9 * time.Hour
749 s.Expiration = 48 * time.Hour
750 s.IoTimeout = time.Hour
751 } else if strings.Contains(parts["extra_config"], "MSAN") {
752 s.ExecutionTimeout = 9 * time.Hour
753 }
754 b.MustAddTask(name, s)
755
borenetdb182c72016-09-30 12:53:12 -0700756 // Upload results if necessary.
757 if strings.Contains(name, "Release") && doUpload(name) {
758 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700759 b.MustAddTask(uploadName, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700760 Dependencies: []string{name},
Eric Boren4b254b92016-11-08 12:55:32 -0500761 Dimensions: LINUX_GCE_DIMENSIONS,
borenetdb182c72016-09-30 12:53:12 -0700762 ExtraArgs: []string{
763 "--workdir", "../../..", "upload_nano_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400764 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700765 fmt.Sprintf("buildername=%s", name),
766 "mastername=fake-master",
767 "buildnumber=2",
768 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700769 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700770 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
771 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700772 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400773 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
774 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700775 },
776 Isolate: "upload_nano_results.isolate",
777 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700778 })
borenetdb182c72016-09-30 12:53:12 -0700779 return uploadName
780 }
781 return name
782}
783
784// process generates tasks and jobs for the given job name.
boreneted20a702016-10-20 11:04:31 -0700785func process(b *specs.TasksCfgBuilder, name string) {
borenetdb182c72016-09-30 12:53:12 -0700786 deps := []string{}
787
788 parts, err := jobNameSchema.ParseJobName(name)
789 if err != nil {
790 glog.Fatal(err)
791 }
792
793 // RecreateSKPs.
794 if strings.Contains(name, "RecreateSKPs") {
boreneted20a702016-10-20 11:04:31 -0700795 deps = append(deps, recreateSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -0700796 }
797
798 // CT bots.
799 if strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700800 deps = append(deps, ctSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -0700801 }
802
borenet2dbbfa52016-10-14 06:32:09 -0700803 // Infra tests.
804 if name == "Housekeeper-PerCommit-InfraTests" {
boreneted20a702016-10-20 11:04:31 -0700805 deps = append(deps, infra(b, name))
borenet2dbbfa52016-10-14 06:32:09 -0700806 }
807
borenetdb182c72016-09-30 12:53:12 -0700808 // Compile bots.
809 if parts["role"] == "Build" {
boreneted20a702016-10-20 11:04:31 -0700810 deps = append(deps, compile(b, name, parts))
borenetdb182c72016-09-30 12:53:12 -0700811 }
812
Eric Borenf5a90e82016-11-15 15:18:20 -0500813 // Most remaining bots need a compile task.
borenetdb182c72016-09-30 12:53:12 -0700814 compileTaskName := deriveCompileTaskName(name, parts)
borenet52383432016-10-17 10:17:53 -0700815 compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName)
816 if err != nil {
817 glog.Fatal(err)
818 }
Eric Boren628e78b2016-11-17 11:33:27 -0500819 // These bots do not need a compile task.
Eric Borenf5a90e82016-11-15 15:18:20 -0500820 if parts["role"] != "Build" &&
821 name != "Housekeeper-PerCommit-InfraTests" &&
Eric Boren71b762f2016-11-30 14:05:16 -0500822 !strings.Contains(name, "RecreateSKPs") &&
823 !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700824 compile(b, compileTaskName, compileTaskParts)
borenet52383432016-10-17 10:17:53 -0700825 }
borenetdb182c72016-09-30 12:53:12 -0700826
827 // Housekeeper.
Eric Boren22f5ef72016-12-02 11:01:33 -0500828 if name == "Housekeeper-PerCommit" {
boreneted20a702016-10-20 11:04:31 -0700829 deps = append(deps, housekeeper(b, name, compileTaskName))
borenetdb182c72016-09-30 12:53:12 -0700830 }
831
832 // Common assets needed by the remaining bots.
833 pkgs := []*specs.CipdPackage{
boreneted20a702016-10-20 11:04:31 -0700834 b.MustGetCipdPackageFromAsset("skimage"),
835 b.MustGetCipdPackageFromAsset("skp"),
836 b.MustGetCipdPackageFromAsset("svg"),
borenetdb182c72016-09-30 12:53:12 -0700837 }
Eric Boren4b254b92016-11-08 12:55:32 -0500838 if strings.Contains(name, "Ubuntu") && strings.Contains(name, "SAN") {
839 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
840 }
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500841 // Skpbench only needs skps
842 if strings.Contains(name, "Skpbench") {
843 pkgs = []*specs.CipdPackage{
844 b.MustGetCipdPackageFromAsset("skp"),
845 }
846 }
borenetdb182c72016-09-30 12:53:12 -0700847
848 // Test bots.
Eric Boren71b762f2016-11-30 14:05:16 -0500849 if parts["role"] == "Test" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700850 deps = append(deps, test(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -0700851 }
852
853 // Perf bots.
Eric Boren71b762f2016-11-30 14:05:16 -0500854 if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700855 deps = append(deps, perf(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -0700856 }
857
858 // Add the Job spec.
Eric Borenf5a90e82016-11-15 15:18:20 -0500859 j := &specs.JobSpec{
borenetdb182c72016-09-30 12:53:12 -0700860 Priority: 0.8,
861 TaskSpecs: deps,
Eric Borenf5a90e82016-11-15 15:18:20 -0500862 }
863 if name == "Housekeeper-Nightly-RecreateSKPs_Canary" {
864 j.Trigger = "nightly"
865 }
866 if name == "Housekeeper-Weekly-RecreateSKPs" {
867 j.Trigger = "weekly"
868 }
Eric Boren71b762f2016-11-30 14:05:16 -0500869 if name == "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs" {
870 j.Trigger = "weekly"
871 }
Eric Boren8615fe52016-12-12 14:30:12 -0500872 b.MustAddJob(name, j)
borenetdb182c72016-09-30 12:53:12 -0700873}
874
borenetdb182c72016-09-30 12:53:12 -0700875// Regenerate the tasks.json file.
876func main() {
boreneted20a702016-10-20 11:04:31 -0700877 b := specs.MustNewTasksCfgBuilder()
borenetdb182c72016-09-30 12:53:12 -0700878 // Create the JobNameSchema.
Eric Boren6441a462017-01-13 13:37:53 -0500879 schema, err := NewJobNameSchema(path.Join(b.CheckoutRoot(), "infra", "bots", ".recipe_deps", "skia-recipes", "recipe_modules", "builder_name_schema", "builder_name_schema.json"))
borenetdb182c72016-09-30 12:53:12 -0700880 if err != nil {
881 glog.Fatal(err)
882 }
883 jobNameSchema = schema
884
borenetdb182c72016-09-30 12:53:12 -0700885 // Create Tasks and Jobs.
boreneted20a702016-10-20 11:04:31 -0700886 for _, name := range JOBS {
887 process(b, name)
borenetdb182c72016-09-30 12:53:12 -0700888 }
889
boreneted20a702016-10-20 11:04:31 -0700890 b.MustFinish()
borenetdb182c72016-09-30 12:53:12 -0700891}
892
893// TODO(borenet): The below really belongs in its own file, probably next to the
894// builder_name_schema.json file.
895
896// JobNameSchema is a struct used for (de)constructing Job names in a
897// predictable format.
898type JobNameSchema struct {
899 Schema map[string][]string `json:"builder_name_schema"`
900 Sep string `json:"builder_name_sep"`
901}
902
903// NewJobNameSchema returns a JobNameSchema instance based on the given JSON
904// file.
905func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) {
906 var rv JobNameSchema
907 f, err := os.Open(jsonFile)
908 if err != nil {
909 return nil, err
910 }
911 defer util.Close(f)
912 if err := json.NewDecoder(f).Decode(&rv); err != nil {
913 return nil, err
914 }
915 return &rv, nil
916}
917
918// ParseJobName splits the given Job name into its component parts, according
919// to the schema.
920func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) {
921 split := strings.Split(n, s.Sep)
922 if len(split) < 2 {
923 return nil, fmt.Errorf("Invalid job name: %q", n)
924 }
925 role := split[0]
926 split = split[1:]
927 keys, ok := s.Schema[role]
928 if !ok {
929 return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role)
930 }
931 extraConfig := ""
932 if len(split) == len(keys)+1 {
933 extraConfig = split[len(split)-1]
934 split = split[:len(split)-1]
935 }
936 if len(split) != len(keys) {
937 return nil, fmt.Errorf("Invalid job name; %q has incorrect number of parts.", n)
938 }
939 rv := make(map[string]string, len(keys)+2)
940 rv["role"] = role
941 if extraConfig != "" {
942 rv["extra_config"] = extraConfig
943 }
944 for i, k := range keys {
945 rv[k] = split[i]
946 }
947 return rv, nil
948}
949
950// MakeJobName assembles the given parts of a Job name, according to the schema.
951func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) {
952 role, ok := parts["role"]
953 if !ok {
954 return "", fmt.Errorf("Invalid job parts; jobs must have a role.")
955 }
956 keys, ok := s.Schema[role]
957 if !ok {
958 return "", fmt.Errorf("Invalid job parts; unknown role %q", role)
959 }
960 rvParts := make([]string, 0, len(parts))
961 rvParts = append(rvParts, role)
962 for _, k := range keys {
963 v, ok := parts[k]
964 if !ok {
965 return "", fmt.Errorf("Invalid job parts; missing %q", k)
966 }
967 rvParts = append(rvParts, v)
968 }
969 if _, ok := parts["extra_config"]; ok {
970 rvParts = append(rvParts, parts["extra_config"])
971 }
972 return strings.Join(rvParts, s.Sep), nil
973}