blob: 04212b7abb6d61e12fe2ab4e5b1d34827babdebc [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 Kleinb48fd3c2017-01-23 11:58:53 -050043 "Build-Mac-Clang-arm-Debug-GN_iOS",
44 "Build-Mac-Clang-arm-Release-GN_iOS",
Mike Klein2afffbd2016-12-05 10:42:36 -050045 "Build-Mac-Clang-arm64-Debug-Android",
Mike Klein6749af42016-11-07 15:38:48 -050046 "Build-Mac-Clang-arm64-Debug-GN_iOS",
Mike Kleinb48fd3c2017-01-23 11:58:53 -050047 "Build-Mac-Clang-arm64-Release-GN_iOS",
Mike Klein2afffbd2016-12-05 10:42:36 -050048 "Build-Mac-Clang-x86_64-Debug",
Eric Boren8615fe52016-12-12 14:30:12 -050049 "Build-Mac-Clang-x86_64-Debug-CommandBuffer",
Mike Klein2afffbd2016-12-05 10:42:36 -050050 "Build-Mac-Clang-x86_64-Release",
Eric Boren8615fe52016-12-12 14:30:12 -050051 "Build-Mac-Clang-x86_64-Release-CommandBuffer",
Mike Klein2afffbd2016-12-05 10:42:36 -050052 "Build-Ubuntu-Clang-arm-Debug-Android",
53 "Build-Ubuntu-Clang-arm-Release-Android",
54 "Build-Ubuntu-Clang-arm64-Debug-Android",
55 "Build-Ubuntu-Clang-arm64-Debug-Android_FrameworkDefs",
56 "Build-Ubuntu-Clang-arm64-Debug-Android_Vulkan",
57 "Build-Ubuntu-Clang-arm64-Release-Android",
58 "Build-Ubuntu-Clang-arm64-Release-Android_Vulkan",
59 "Build-Ubuntu-Clang-mips64el-Debug-Android",
60 "Build-Ubuntu-Clang-mips64el-Release-Android",
61 "Build-Ubuntu-Clang-mipsel-Debug-Android",
62 "Build-Ubuntu-Clang-mipsel-Release-Android",
63 "Build-Ubuntu-Clang-x64-Debug-Android",
64 "Build-Ubuntu-Clang-x64-Release-Android",
65 "Build-Ubuntu-Clang-x86-Debug-Android",
66 "Build-Ubuntu-Clang-x86-Debug-Android_Vulkan",
67 "Build-Ubuntu-Clang-x86-Release-Android",
68 "Build-Ubuntu-Clang-x86-Release-Android_Vulkan",
69 "Build-Ubuntu-Clang-x86_64-Debug",
Eric Boren8615fe52016-12-12 14:30:12 -050070 "Build-Ubuntu-Clang-x86_64-Debug-ASAN",
71 "Build-Ubuntu-Clang-x86_64-Debug-MSAN",
Kevin Lubick9c7dcac2017-01-18 09:24:56 -050072 "Build-Ubuntu-Clang-x86_64-Debug-Vulkan",
Mike Klein2afffbd2016-12-05 10:42:36 -050073 "Build-Ubuntu-Clang-x86_64-Release",
Mike Kleind8ee67c2017-01-19 12:14:50 -050074 "Build-Ubuntu-Clang-x86_64-Release-ASAN",
Mike Klein56770752017-01-05 08:09:57 -050075 "Build-Ubuntu-Clang-x86_64-Release-Fast",
Eric Boren8615fe52016-12-12 14:30:12 -050076 "Build-Ubuntu-Clang-x86_64-Release-TSAN",
Kevin Lubick9c7dcac2017-01-18 09:24:56 -050077 "Build-Ubuntu-Clang-x86_64-Release-Vulkan",
Eric Boren50831302016-11-18 13:10:51 -050078 "Build-Ubuntu-GCC-x86-Debug",
79 "Build-Ubuntu-GCC-x86-Release",
Mike Klein2afffbd2016-12-05 10:42:36 -050080 "Build-Ubuntu-GCC-x86_64-Debug",
Eric Boren50831302016-11-18 13:10:51 -050081 "Build-Ubuntu-GCC-x86_64-Debug-NoGPU",
Eric Boren8615fe52016-12-12 14:30:12 -050082 "Build-Ubuntu-GCC-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
Mike Klein2afffbd2016-12-05 10:42:36 -050083 "Build-Ubuntu-GCC-x86_64-Release",
Eric Boren50831302016-11-18 13:10:51 -050084 "Build-Ubuntu-GCC-x86_64-Release-ANGLE",
Eric Boren50831302016-11-18 13:10:51 -050085 "Build-Ubuntu-GCC-x86_64-Release-Mesa",
86 "Build-Ubuntu-GCC-x86_64-Release-NoGPU",
87 "Build-Ubuntu-GCC-x86_64-Release-PDFium",
Eric Boren3dc73f32016-12-13 08:48:46 -050088 "Build-Ubuntu-GCC-x86_64-Release-PDFium_SkiaPaths",
Eric Boren8615fe52016-12-12 14:30:12 -050089 "Build-Ubuntu-GCC-x86_64-Release-SKNX_NO_SIMD",
90 "Build-Ubuntu-GCC-x86_64-Release-Shared",
Eric Borenbd488f82016-11-23 11:03:28 -050091 "Build-Ubuntu-GCC-x86_64-Release-Valgrind",
Mike Klein2afffbd2016-12-05 10:42:36 -050092 "Build-Win-Clang-arm64-Release-Android",
Eric Borencb4feeb2016-11-28 10:12:09 -050093 "Build-Win-MSVC-x86-Debug",
94 "Build-Win-MSVC-x86-Debug-ANGLE",
95 "Build-Win-MSVC-x86-Debug-Exceptions",
96 "Build-Win-MSVC-x86-Debug-GDI",
97 "Build-Win-MSVC-x86-Release",
98 "Build-Win-MSVC-x86-Release-ANGLE",
99 "Build-Win-MSVC-x86-Release-GDI",
100 "Build-Win-MSVC-x86_64-Debug",
Eric Boren8615fe52016-12-12 14:30:12 -0500101 "Build-Win-MSVC-x86_64-Debug-ANGLE",
102 "Build-Win-MSVC-x86_64-Debug-GDI",
103 "Build-Win-MSVC-x86_64-Debug-Vulkan",
Eric Borencb4feeb2016-11-28 10:12:09 -0500104 "Build-Win-MSVC-x86_64-Release",
Eric Boren8615fe52016-12-12 14:30:12 -0500105 "Build-Win-MSVC-x86_64-Release-ANGLE",
106 "Build-Win-MSVC-x86_64-Release-GDI",
Eric Borencb4feeb2016-11-28 10:12:09 -0500107 "Build-Win-MSVC-x86_64-Release-Vulkan",
Eric Borenf5a90e82016-11-15 15:18:20 -0500108 "Housekeeper-Nightly-RecreateSKPs_Canary",
Eric Boren22f5ef72016-12-02 11:01:33 -0500109 "Housekeeper-PerCommit",
Eric Boren792079cf2016-11-09 14:03:20 -0500110 "Housekeeper-PerCommit-InfraTests",
Eric Borenf5a90e82016-11-15 15:18:20 -0500111 "Housekeeper-Weekly-RecreateSKPs",
Mike Klein2afffbd2016-12-05 10:42:36 -0500112 "Perf-Android-Clang-AndroidOne-CPU-MT6582-arm-Debug-Android",
113 "Perf-Android-Clang-AndroidOne-CPU-MT6582-arm-Release-Android",
114 "Perf-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Debug-Android",
115 "Perf-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Release-Android",
116 "Perf-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Debug-Android",
117 "Perf-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Debug-Android_Vulkan",
118 "Perf-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Release-Android",
119 "Perf-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Release-Android_Vulkan",
120 "Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android",
121 "Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android_Vulkan",
122 "Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Release-Android",
123 "Perf-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Release-Android_Vulkan",
124 "Perf-Android-Clang-Nexus10-GPU-MaliT604-arm-Debug-Android",
125 "Perf-Android-Clang-Nexus10-GPU-MaliT604-arm-Release-Android",
126 "Perf-Android-Clang-Nexus5-GPU-Adreno330-arm-Debug-Android",
127 "Perf-Android-Clang-Nexus5-GPU-Adreno330-arm-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500128 "Perf-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Debug-Android",
129 "Perf-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Debug-Android_Vulkan",
130 "Perf-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Release-Android",
131 "Perf-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Release-Android_Vulkan",
132 "Perf-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-Android",
133 "Perf-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500134 "Perf-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Debug-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500135 "Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Debug-Android",
Greg Daniel879bdc92016-12-19 09:28:50 -0500136 // "Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Debug-Android_Vulkan",
Mike Klein2afffbd2016-12-05 10:42:36 -0500137 "Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android",
Greg Daniel879bdc92016-12-19 09:28:50 -0500138 // "Perf-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android_Vulkan",
Mike Klein2afffbd2016-12-05 10:42:36 -0500139 "Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Debug-Android",
140 "Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Debug-Android_Vulkan",
141 "Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Release-Android",
142 "Perf-Android-Clang-Pixel-GPU-Adreno530-arm64-Release-Android_Vulkan",
Kevin Lubicke29ce642016-12-09 11:11:33 -0500143 "Perf-Android-Clang-PixelC-CPU-TegraX1-arm64-Debug-Android",
144 "Perf-Android-Clang-PixelC-CPU-TegraX1-arm64-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500145 "Perf-Android-Clang-PixelC-GPU-TegraX1-arm64-Release-Android_Skpbench",
146 "Perf-Android-Clang-PixelC-GPU-TegraX1-arm64-Release-Android_Vulkan_Skpbench",
147 "Perf-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Debug",
148 "Perf-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release",
149 "Perf-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Debug",
150 "Perf-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Release",
151 "Perf-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug",
152 "Perf-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Release",
Eric Borenb409c6a2016-11-28 07:22:18 -0500153 "Perf-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Release-CommandBuffer",
Mike Klein2afffbd2016-12-05 10:42:36 -0500154 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug",
Eric Boren50831302016-11-18 13:10:51 -0500155 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN",
Eric Boren50831302016-11-18 13:10:51 -0500156 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN",
Mike Klein2afffbd2016-12-05 10:42:36 -0500157 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release",
Mike Kleind8ee67c2017-01-19 12:14:50 -0500158 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-ASAN",
Mike Klein56770752017-01-05 08:09:57 -0500159 "Perf-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-Fast",
Eric Borenbd488f82016-11-23 11:03:28 -0500160 "Perf-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Debug-ASAN",
Mike Kleind8ee67c2017-01-19 12:14:50 -0500161 "Perf-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Release-ASAN",
Eric Boren50831302016-11-18 13:10:51 -0500162 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug",
Mike Klein2afffbd2016-12-05 10:42:36 -0500163 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug",
Eric Boren50831302016-11-18 13:10:51 -0500164 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
Mike Klein2afffbd2016-12-05 10:42:36 -0500165 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release",
Eric Boren71b762f2016-11-30 14:05:16 -0500166 "Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-CT_BENCH_1k_SKPs",
Eric Boren71b762f2016-11-30 14:05:16 -0500167 "Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_1k_SKPs",
Eric Borenbd488f82016-11-23 11:03:28 -0500168 "Perf-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind",
Mike Klein2afffbd2016-12-05 10:42:36 -0500169 "Perf-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Debug",
170 "Perf-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Release",
Kevin Lubick893c49e2017-01-17 15:15:40 -0500171 "Perf-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Debug",
172 "Perf-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Release",
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500173 "Perf-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Debug-Vulkan",
174 "Perf-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500175 "Perf-Win10-MSVC-Golo-GPU-GT610-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500176 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug",
177 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug-ANGLE",
178 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug-Vulkan",
179 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release",
180 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release-ANGLE",
181 "Perf-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500182 "Perf-Win10-MSVC-NUC-GPU-IntelIris6100-x86_64-Debug-ANGLE",
183 "Perf-Win10-MSVC-NUC-GPU-IntelIris6100-x86_64-Release-ANGLE",
Ben Wagner17f811b2016-12-22 08:40:14 -0500184 "Perf-Win10-MSVC-ShuttleA-GPU-AMDHD7770-x86_64-Debug",
185 "Perf-Win10-MSVC-ShuttleA-GPU-AMDHD7770-x86_64-Release",
Eric Boren78f5af72016-11-30 12:49:00 -0500186 "Perf-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug",
187 "Perf-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug-Vulkan",
188 "Perf-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Release",
189 "Perf-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Release-Vulkan",
Ben Wagner17f811b2016-12-22 08:40:14 -0500190 "Perf-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Debug",
191 "Perf-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Release",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500192 "Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Debug",
193 "Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Debug-ANGLE",
194 "Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release",
195 "Perf-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release-ANGLE",
196 "Perf-Win10-MSVC-ShuttleC-GPU-iHD530-x86_64-Debug",
197 "Perf-Win10-MSVC-ShuttleC-GPU-iHD530-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500198 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug",
199 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug-ANGLE",
200 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug-Vulkan",
201 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release",
202 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release-ANGLE",
203 "Perf-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500204 "Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86-Debug",
205 "Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug",
206 "Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug-GDI",
207 "Perf-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Release",
Eric Boren792079cf2016-11-09 14:03:20 -0500208 "Perf-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Debug",
209 "Perf-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Release",
Mike Klein2afffbd2016-12-05 10:42:36 -0500210 "Test-Android-Clang-AndroidOne-CPU-MT6582-arm-Debug-Android",
211 "Test-Android-Clang-AndroidOne-CPU-MT6582-arm-Release-Android",
212 "Test-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Debug-Android",
213 "Test-Android-Clang-AndroidOne-GPU-Mali400MP2-arm-Release-Android",
214 "Test-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Debug-Android",
215 "Test-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Debug-Android_Vulkan",
216 "Test-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Release-Android",
217 "Test-Android-Clang-GalaxyS7-GPU-Adreno530-arm64-Release-Android_Vulkan",
Kevin Lubick56ff9a12016-12-14 08:48:00 -0500218 "Test-Android-Clang-GalaxyTab3-GPU-Vivante-arm-Debug-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500219 "Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android",
220 "Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Debug-Android_Vulkan",
221 "Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Release-Android",
222 "Test-Android-Clang-NVIDIA_Shield-GPU-TegraX1-arm64-Release-Android_Vulkan",
223 "Test-Android-Clang-Nexus10-GPU-MaliT604-arm-Debug-Android",
224 "Test-Android-Clang-Nexus10-GPU-MaliT604-arm-Release-Android",
225 "Test-Android-Clang-Nexus5-GPU-Adreno330-arm-Debug-Android",
226 "Test-Android-Clang-Nexus5-GPU-Adreno330-arm-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500227 "Test-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Debug-Android",
228 "Test-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Debug-Android_Vulkan",
229 "Test-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Release-Android",
230 "Test-Android-Clang-Nexus6p-GPU-Adreno430-arm64-Release-Android_Vulkan",
231 "Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-Android",
232 "Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500233 "Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Debug-Android",
234 "Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-Android",
235 "Test-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Debug-Android",
Greg Daniel80a08dd2017-01-20 10:45:49 -0500236 "Test-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Debug-Android_Vulkan",
Mike Klein2afffbd2016-12-05 10:42:36 -0500237 "Test-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android",
Greg Daniel80a08dd2017-01-20 10:45:49 -0500238 "Test-Android-Clang-NexusPlayer-GPU-PowerVR-x86-Release-Android_Vulkan",
Kevin Lubicke29ce642016-12-09 11:11:33 -0500239 "Test-Android-Clang-PixelC-CPU-TegraX1-arm64-Debug-Android",
240 "Test-Android-Clang-PixelC-CPU-TegraX1-arm64-Release-Android",
Mike Klein2afffbd2016-12-05 10:42:36 -0500241 "Test-Android-Clang-PixelXL-GPU-Adreno530-arm64-Debug-Android",
242 "Test-Android-Clang-PixelXL-GPU-Adreno530-arm64-Debug-Android_Vulkan",
243 "Test-Android-Clang-PixelXL-GPU-Adreno530-arm64-Release-Android",
244 "Test-Android-Clang-PixelXL-GPU-Adreno530-arm64-Release-Android_Vulkan",
245 "Test-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Debug",
246 "Test-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release",
247 "Test-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Debug",
248 "Test-Mac-Clang-MacMini6.2-CPU-AVX-x86_64-Release",
249 "Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug",
Eric Borenb409c6a2016-11-28 07:22:18 -0500250 "Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug-CommandBuffer",
Mike Klein2afffbd2016-12-05 10:42:36 -0500251 "Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Release",
252 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug",
Eric Boren50831302016-11-18 13:10:51 -0500253 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-ASAN",
Eric Boren50831302016-11-18 13:10:51 -0500254 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN",
Mike Klein2afffbd2016-12-05 10:42:36 -0500255 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release",
Mike Kleind8ee67c2017-01-19 12:14:50 -0500256 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-ASAN",
Mike Klein56770752017-01-05 08:09:57 -0500257 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-Fast",
Eric Boren50831302016-11-18 13:10:51 -0500258 "Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Release-TSAN",
Eric Borenbd488f82016-11-23 11:03:28 -0500259 "Test-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Debug-ASAN",
Mike Kleind8ee67c2017-01-19 12:14:50 -0500260 "Test-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Release-ASAN",
Eric Borenbd488f82016-11-23 11:03:28 -0500261 "Test-Ubuntu-Clang-Golo-GPU-GT610-x86_64-Release-TSAN",
Eric Boren50831302016-11-18 13:10:51 -0500262 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug",
Mike Klein2afffbd2016-12-05 10:42:36 -0500263 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug",
Eric Boren71b762f2016-11-30 14:05:16 -0500264 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_100k_SKPs",
265 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs",
266 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_100k_SKPs",
Eric Boren50831302016-11-18 13:10:51 -0500267 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
Mike Klein2afffbd2016-12-05 10:42:36 -0500268 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release",
Eric Boren50831302016-11-18 13:10:51 -0500269 "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD",
Eric Borenbd488f82016-11-23 11:03:28 -0500270 "Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind",
Mike Klein2afffbd2016-12-05 10:42:36 -0500271 "Test-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Debug",
272 "Test-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Release",
Kevin Lubick893c49e2017-01-17 15:15:40 -0500273 "Test-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Debug",
274 "Test-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Release",
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500275 "Test-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Debug-Vulkan",
276 "Test-Ubuntu16-Clang-NUC-GPU-IntelIris540-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500277 "Test-Win10-MSVC-Golo-GPU-GT610-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500278 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug",
279 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug-ANGLE",
280 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Debug-Vulkan",
281 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release",
282 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release-ANGLE",
283 "Test-Win10-MSVC-NUC-GPU-IntelIris540-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500284 "Test-Win10-MSVC-NUC-GPU-IntelIris6100-x86_64-Debug-ANGLE",
285 "Test-Win10-MSVC-NUC-GPU-IntelIris6100-x86_64-Release-ANGLE",
Ben Wagner17f811b2016-12-22 08:40:14 -0500286 "Test-Win10-MSVC-ShuttleA-GPU-AMDHD7770-x86_64-Debug",
287 "Test-Win10-MSVC-ShuttleA-GPU-AMDHD7770-x86_64-Release",
Eric Boren78f5af72016-11-30 12:49:00 -0500288 "Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug",
289 "Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug-Vulkan",
290 "Test-Win10-MSVC-ShuttleA-GPU-GTX660-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500291 "Test-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Debug",
292 "Test-Win10-MSVC-ShuttleB-GPU-IntelHD4600-x86_64-Release",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500293 "Test-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Debug",
294 "Test-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Debug-ANGLE",
295 "Test-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release",
296 "Test-Win10-MSVC-ShuttleC-GPU-GTX960-x86_64-Release-ANGLE",
297 "Test-Win10-MSVC-ShuttleC-GPU-iHD530-x86_64-Debug",
298 "Test-Win10-MSVC-ShuttleC-GPU-iHD530-x86_64-Release",
Ben Wagner17f811b2016-12-22 08:40:14 -0500299 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug",
300 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug-ANGLE",
301 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Debug-Vulkan",
302 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release",
303 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release-ANGLE",
304 "Test-Win10-MSVC-ZBOX-GPU-GTX1070-x86_64-Release-Vulkan",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500305 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86-Debug",
306 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86-Release",
307 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug",
308 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Debug-GDI",
309 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Release",
310 "Test-Win2k8-MSVC-GCE-CPU-AVX2-x86_64-Release-GDI",
Eric Boren792079cf2016-11-09 14:03:20 -0500311 "Test-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Debug",
312 "Test-iOS-Clang-iPadMini4-GPU-GX6450-Arm7-Release",
borenetdb182c72016-09-30 12:53:12 -0700313 }
314
Eric Boren4b254b92016-11-08 12:55:32 -0500315 // LINUX_GCE_DIMENSIONS are the Swarming dimensions for Linux GCE
316 // instances.
317 LINUX_GCE_DIMENSIONS = []string{
borenetdb182c72016-09-30 12:53:12 -0700318 "cpu:x86-64-avx2",
319 "gpu:none",
Kevin Lubick797ef162016-12-15 10:45:08 -0500320 fmt.Sprintf("os:%s", DEFAULT_OS_LINUX),
borenetdb182c72016-09-30 12:53:12 -0700321 fmt.Sprintf("pool:%s", POOL_SKIA),
322 }
323
324 // Defines the structure of job names.
325 jobNameSchema *JobNameSchema
borenetdb182c72016-09-30 12:53:12 -0700326)
327
328// deriveCompileTaskName returns the name of a compile task based on the given
329// job name.
330func deriveCompileTaskName(jobName string, parts map[string]string) string {
331 if parts["role"] == "Housekeeper" {
332 return "Build-Ubuntu-GCC-x86_64-Release-Shared"
333 } else if parts["role"] == "Test" || parts["role"] == "Perf" {
334 task_os := parts["os"]
335 ec := parts["extra_config"]
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500336 ec = strings.TrimSuffix(ec, "_Skpbench")
borenetdb182c72016-09-30 12:53:12 -0700337 if task_os == "Android" {
338 if ec == "Vulkan" {
339 ec = "Android_Vulkan"
borenetdb182c72016-09-30 12:53:12 -0700340 }
borenet52383432016-10-17 10:17:53 -0700341 task_os = "Ubuntu"
borenetdb182c72016-09-30 12:53:12 -0700342 } else if task_os == "iOS" {
343 ec = task_os
344 task_os = "Mac"
345 } else if strings.Contains(task_os, "Win") {
346 task_os = "Win"
Kevin Lubick893c49e2017-01-17 15:15:40 -0500347 } else if strings.Contains(task_os, "Ubuntu") {
348 task_os = "Ubuntu"
borenetdb182c72016-09-30 12:53:12 -0700349 }
Eric Boren50831302016-11-18 13:10:51 -0500350 jobNameMap := map[string]string{
borenetdb182c72016-09-30 12:53:12 -0700351 "role": "Build",
352 "os": task_os,
353 "compiler": parts["compiler"],
354 "target_arch": parts["arch"],
355 "configuration": parts["configuration"],
Eric Boren50831302016-11-18 13:10:51 -0500356 }
357 if ec != "" {
358 jobNameMap["extra_config"] = ec
359 }
360 name, err := jobNameSchema.MakeJobName(jobNameMap)
borenetdb182c72016-09-30 12:53:12 -0700361 if err != nil {
362 glog.Fatal(err)
363 }
364 return name
365 } else {
366 return jobName
367 }
368}
369
370// swarmDimensions generates swarming bot dimensions for the given task.
371func swarmDimensions(parts map[string]string) []string {
borenetdb182c72016-09-30 12:53:12 -0700372 d := map[string]string{
373 "pool": POOL_SKIA,
374 }
375 if os, ok := parts["os"]; ok {
Eric Boren54ff2fc2016-12-02 12:09:10 -0500376 d["os"] = map[string]string{
Kevin Lubick893c49e2017-01-17 15:15:40 -0500377 "Android": "Android",
378 "Mac": "Mac-10.11",
379 "Ubuntu": DEFAULT_OS_LINUX,
Kevin Lubick9063eca2017-02-01 11:10:32 -0500380 "Ubuntu16": "Ubuntu-16.10",
Kevin Lubick893c49e2017-01-17 15:15:40 -0500381 "Win": "Windows-2008ServerR2-SP1",
382 "Win10": "Windows-10-14393",
383 "Win2k8": "Windows-2008ServerR2-SP1",
384 "Win8": "Windows-8.1-SP0",
385 "iOS": "iOS-9.3.1",
Eric Boren54ff2fc2016-12-02 12:09:10 -0500386 }[os]
Ben Wagner73557372016-12-29 16:27:03 -0500387 // Chrome Golo has a different Windows image.
388 if parts["model"] == "Golo" && os == "Win10" {
389 d["os"] = "Windows-10-10586"
Ben Wagner17f811b2016-12-22 08:40:14 -0500390 }
borenetdb182c72016-09-30 12:53:12 -0700391 } else {
392 d["os"] = DEFAULT_OS
393 }
borenetdb182c72016-09-30 12:53:12 -0700394 if parts["role"] == "Test" || parts["role"] == "Perf" {
395 if strings.Contains(parts["os"], "Android") {
396 // For Android, the device type is a better dimension
397 // than CPU or GPU.
Eric Boren4b254b92016-11-08 12:55:32 -0500398 deviceInfo := map[string][]string{
399 "AndroidOne": {"sprout", "MOB30Q"},
400 "GalaxyS7": {"heroqlteatt", "MMB29M"},
Kevin Lubick56ff9a12016-12-14 08:48:00 -0500401 "GalaxyTab3": {"goyawifi", "JDQ39"},
Eric Boren4b254b92016-11-08 12:55:32 -0500402 "NVIDIA_Shield": {"foster", "MRA58K"},
403 "Nexus10": {"manta", "LMY49J"},
Kevin Lubicke2d41412016-12-28 10:10:09 -0500404 "Nexus5": {"hammerhead", "M4B30Z"},
Eric Boren4b254b92016-11-08 12:55:32 -0500405 "Nexus6": {"shamu", "M"},
406 "Nexus6p": {"angler", "NMF26C"},
407 "Nexus7": {"grouper", "LMY47V"},
408 "Nexus7v2": {"flo", "M"},
Kevin Lubick5ac82602017-01-13 09:37:03 -0500409 "NexusPlayer": {"fugu", "N2G10B"},
Kevin Lubick7cf77452016-12-28 13:35:13 -0500410 "Pixel": {"sailfish", "NMF26Q"},
Kevin Lubickeaef5492016-12-15 12:36:12 -0500411 "PixelC": {"dragon", "NMF26H"},
Kevin Lubick7cf77452016-12-28 13:35:13 -0500412 "PixelXL": {"marlin", "NMF26Q"},
borenetdb182c72016-09-30 12:53:12 -0700413 }[parts["model"]]
Eric Boren4b254b92016-11-08 12:55:32 -0500414 d["device_type"] = deviceInfo[0]
415 d["device_os"] = deviceInfo[1]
borenetdb182c72016-09-30 12:53:12 -0700416 } else if strings.Contains(parts["os"], "iOS") {
417 d["device"] = map[string]string{
Eric Boren792079cf2016-11-09 14:03:20 -0500418 "iPadMini4": "iPad5,1",
borenetdb182c72016-09-30 12:53:12 -0700419 }[parts["model"]]
borenetdb182c72016-09-30 12:53:12 -0700420 } else if parts["cpu_or_gpu"] == "CPU" {
421 d["gpu"] = "none"
422 d["cpu"] = map[string]string{
423 "AVX": "x86-64",
424 "AVX2": "x86-64-avx2",
425 "SSE4": "x86-64",
426 }[parts["cpu_or_gpu_value"]]
427 if strings.Contains(parts["os"], "Win") && parts["cpu_or_gpu_value"] == "AVX2" {
428 // AVX2 is not correctly detected on Windows. Fall back on other
429 // dimensions to ensure that we correctly target machines which we know
430 // have AVX2 support.
431 d["cpu"] = "x86-64"
432 d["os"] = "Windows-2008ServerR2-SP1"
433 }
434 } else {
435 d["gpu"] = map[string]string{
Ben Wagner17f811b2016-12-22 08:40:14 -0500436 "AMDHD7770": "1002:683d",
437 "GeForce320M": "10de:08a4",
438 "GT610": "10de:104a",
439 "GTX1070": "10de:1ba1",
440 "GTX550Ti": "10de:1244",
441 "GTX660": "10de:11c0",
442 "GTX960": "10de:1401",
443 // TODO(benjaminwagner): This device ID doesn't
444 // match HD4000.
445 "HD4000": "8086:0a2e",
446 // This bot will eventually go away, so I'm not
447 // going to bother renaming it.
Eric Boren4b254b92016-11-08 12:55:32 -0500448 "iHD530": "8086:1912",
Ben Wagner17f811b2016-12-22 08:40:14 -0500449 "IntelHD4600": "8086:0412",
450 "IntelIris540": "8086:1926",
Eric Boren4b254b92016-11-08 12:55:32 -0500451 "IntelIris6100": "8086:162b",
borenetdb182c72016-09-30 12:53:12 -0700452 }[parts["cpu_or_gpu_value"]]
453 }
454 } else {
455 d["gpu"] = "none"
456 }
457 rv := make([]string, 0, len(d))
458 for k, v := range d {
459 rv = append(rv, fmt.Sprintf("%s:%s", k, v))
460 }
461 sort.Strings(rv)
462 return rv
463}
464
borenetdb182c72016-09-30 12:53:12 -0700465// compile generates a compile task. Returns the name of the last task in the
466// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700467func compile(b *specs.TasksCfgBuilder, name string, parts map[string]string) string {
borenetdb182c72016-09-30 12:53:12 -0700468 // Collect the necessary CIPD packages.
469 pkgs := []*specs.CipdPackage{}
470
471 // Android bots require a toolchain.
472 if strings.Contains(name, "Android") {
borenetdb182c72016-09-30 12:53:12 -0700473 if strings.Contains(name, "Mac") {
boreneted20a702016-10-20 11:04:31 -0700474 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_darwin"))
Mike Klein86c2c0f2016-11-02 13:13:16 -0400475 } else if strings.Contains(name, "Win") {
Mike Kleine9215f02016-11-02 15:44:26 -0400476 pkg := b.MustGetCipdPackageFromAsset("android_ndk_windows")
477 pkg.Path = "n"
478 pkgs = append(pkgs, pkg)
borenetdb182c72016-09-30 12:53:12 -0700479 } else {
boreneted20a702016-10-20 11:04:31 -0700480 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("android_ndk_linux"))
borenetdb182c72016-09-30 12:53:12 -0700481 }
Kevin Lubick9c7dcac2017-01-18 09:24:56 -0500482 } else if strings.Contains(name, "Ubuntu") {
483 if strings.Contains(name, "Clang") {
484 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
485 }
486 if strings.Contains(name, "Vulkan") {
487 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("linux_vulkan_sdk"))
488 }
Mike Klein27dcee12016-11-09 16:31:42 -0500489 } else if strings.Contains(name, "Win") {
boreneted20a702016-10-20 11:04:31 -0700490 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_toolchain"))
borenetdb182c72016-09-30 12:53:12 -0700491 if strings.Contains(name, "Vulkan") {
boreneted20a702016-10-20 11:04:31 -0700492 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("win_vulkan_sdk"))
borenetdb182c72016-09-30 12:53:12 -0700493 }
494 }
495
496 // Add the task.
boreneted20a702016-10-20 11:04:31 -0700497 b.MustAddTask(name, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700498 CipdPackages: pkgs,
499 Dimensions: swarmDimensions(parts),
500 ExtraArgs: []string{
501 "--workdir", "../../..", "swarm_compile",
skia.buildbots2478c732016-11-04 14:37:26 -0400502 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700503 fmt.Sprintf("buildername=%s", name),
504 "mastername=fake-master",
505 "buildnumber=2",
506 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700507 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700508 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
509 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700510 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400511 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
512 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700513 },
514 Isolate: "compile_skia.isolate",
515 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700516 })
Eric Boren8615fe52016-12-12 14:30:12 -0500517 // All compile tasks are runnable as their own Job. Assert that the Job
518 // is listed in JOBS.
519 if !util.In(name, JOBS) {
520 glog.Fatalf("Job %q is missing from the JOBS list!", name)
521 }
borenetdb182c72016-09-30 12:53:12 -0700522 return name
523}
524
525// recreateSKPs generates a RecreateSKPs task. Returns the name of the last
526// task in the generated chain of tasks, which the Job should add as a
527// dependency.
boreneted20a702016-10-20 11:04:31 -0700528func recreateSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500529 b.MustAddTask(name, &specs.TaskSpec{
Eric Borenf5a90e82016-11-15 15:18:20 -0500530 CipdPackages: []*specs.CipdPackage{},
531 Dimensions: LINUX_GCE_DIMENSIONS,
532 ExecutionTimeout: 4 * time.Hour,
Eric Boren4b254b92016-11-08 12:55:32 -0500533 ExtraArgs: []string{
534 "--workdir", "../../..", "swarm_RecreateSKPs",
535 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
536 fmt.Sprintf("buildername=%s", name),
537 "mastername=fake-master",
538 "buildnumber=2",
539 "slavename=fake-buildslave",
540 "nobuildbot=True",
541 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
542 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
543 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
544 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
545 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
546 },
Eric Borenf5a90e82016-11-15 15:18:20 -0500547 IoTimeout: 40 * time.Minute,
548 Isolate: "compile_skia.isolate",
549 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500550 })
borenetdb182c72016-09-30 12:53:12 -0700551 return name
552}
553
554// ctSKPs generates a CT SKPs task. Returns the name of the last task in the
555// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700556func ctSKPs(b *specs.TasksCfgBuilder, name string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500557 b.MustAddTask(name, &specs.TaskSpec{
558 CipdPackages: []*specs.CipdPackage{},
559 Dimensions: []string{"pool:SkiaCT"},
560 ExecutionTimeout: 24 * time.Hour,
561 ExtraArgs: []string{
562 "--workdir", "../../..", "swarm_ct_skps",
563 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
564 fmt.Sprintf("buildername=%s", name),
565 "mastername=fake-master",
566 "buildnumber=2",
567 "slavename=fake-buildslave",
568 "nobuildbot=True",
569 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
570 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
571 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
572 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
573 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
574 },
575 IoTimeout: time.Hour,
576 Isolate: "ct_skps_skia.isolate",
577 Priority: 0.8,
578 })
borenetdb182c72016-09-30 12:53:12 -0700579 return name
580}
581
582// housekeeper generates a Housekeeper task. Returns the name of the last task
583// in the generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700584func housekeeper(b *specs.TasksCfgBuilder, name, compileTaskName string) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500585 b.MustAddTask(name, &specs.TaskSpec{
Eric Boren22f5ef72016-12-02 11:01:33 -0500586 CipdPackages: []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")},
Eric Boren4b254b92016-11-08 12:55:32 -0500587 Dependencies: []string{compileTaskName},
588 Dimensions: LINUX_GCE_DIMENSIONS,
589 ExtraArgs: []string{
590 "--workdir", "../../..", "swarm_housekeeper",
591 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
592 fmt.Sprintf("buildername=%s", name),
593 "mastername=fake-master",
594 "buildnumber=2",
595 "slavename=fake-buildslave",
596 "nobuildbot=True",
597 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
598 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
599 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
600 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
601 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
602 },
603 Isolate: "housekeeper_skia.isolate",
604 Priority: 0.8,
605 })
borenetdb182c72016-09-30 12:53:12 -0700606 return name
607}
608
borenet2dbbfa52016-10-14 06:32:09 -0700609// infra generates an infra_tests task. Returns the name of the last task in the
610// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700611func infra(b *specs.TasksCfgBuilder, name string) string {
612 b.MustAddTask(name, &specs.TaskSpec{
borenet2dbbfa52016-10-14 06:32:09 -0700613 CipdPackages: []*specs.CipdPackage{},
Eric Boren4b254b92016-11-08 12:55:32 -0500614 Dimensions: LINUX_GCE_DIMENSIONS,
borenet2dbbfa52016-10-14 06:32:09 -0700615 ExtraArgs: []string{
616 "--workdir", "../../..", "swarm_infra",
skia.buildbots2478c732016-11-04 14:37:26 -0400617 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenet2dbbfa52016-10-14 06:32:09 -0700618 fmt.Sprintf("buildername=%s", name),
619 "mastername=fake-master",
620 "buildnumber=2",
621 "slavename=fake-buildslave",
622 "nobuildbot=True",
623 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
624 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
625 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400626 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
627 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenet2dbbfa52016-10-14 06:32:09 -0700628 },
629 Isolate: "infra_skia.isolate",
630 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700631 })
borenet2dbbfa52016-10-14 06:32:09 -0700632 return name
633}
634
borenetdb182c72016-09-30 12:53:12 -0700635// doUpload indicates whether the given Job should upload its results.
636func doUpload(name string) bool {
637 skipUploadBots := []string{
638 "ASAN",
639 "Coverage",
640 "MSAN",
641 "TSAN",
642 "UBSAN",
643 "Valgrind",
644 }
645 for _, s := range skipUploadBots {
646 if strings.Contains(name, s) {
647 return false
648 }
649 }
650 return true
651}
652
653// test generates a Test task. Returns the name of the last task in the
654// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700655func test(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Eric Boren4b254b92016-11-08 12:55:32 -0500656 s := &specs.TaskSpec{
Eric Boren1f2f64b2016-11-09 18:35:15 -0500657 CipdPackages: pkgs,
658 Dependencies: []string{compileTaskName},
659 Dimensions: swarmDimensions(parts),
660 ExecutionTimeout: 4 * time.Hour,
661 Expiration: 20 * time.Hour,
borenetdb182c72016-09-30 12:53:12 -0700662 ExtraArgs: []string{
663 "--workdir", "../../..", "swarm_test",
skia.buildbots2478c732016-11-04 14:37:26 -0400664 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700665 fmt.Sprintf("buildername=%s", name),
666 "mastername=fake-master",
667 "buildnumber=2",
668 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700669 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700670 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
671 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700672 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400673 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
674 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700675 },
Eric Boren1f2f64b2016-11-09 18:35:15 -0500676 IoTimeout: 40 * time.Minute,
677 Isolate: "test_skia.isolate",
678 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500679 }
680 if strings.Contains(parts["extra_config"], "Valgrind") {
681 s.ExecutionTimeout = 9 * time.Hour
682 s.Expiration = 48 * time.Hour
683 s.IoTimeout = time.Hour
684 } else if strings.Contains(parts["extra_config"], "MSAN") {
685 s.ExecutionTimeout = 9 * time.Hour
686 }
687 b.MustAddTask(name, s)
688
borenetdb182c72016-09-30 12:53:12 -0700689 // Upload results if necessary.
690 if doUpload(name) {
691 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700692 b.MustAddTask(uploadName, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700693 Dependencies: []string{name},
Eric Boren4b254b92016-11-08 12:55:32 -0500694 Dimensions: LINUX_GCE_DIMENSIONS,
borenetdb182c72016-09-30 12:53:12 -0700695 ExtraArgs: []string{
696 "--workdir", "../../..", "upload_dm_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400697 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700698 fmt.Sprintf("buildername=%s", name),
699 "mastername=fake-master",
700 "buildnumber=2",
701 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700702 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700703 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
704 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700705 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400706 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
707 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700708 },
709 Isolate: "upload_dm_results.isolate",
710 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700711 })
borenetdb182c72016-09-30 12:53:12 -0700712 return uploadName
713 }
714 return name
715}
716
717// perf generates a Perf task. Returns the name of the last task in the
718// generated chain of tasks, which the Job should add as a dependency.
boreneted20a702016-10-20 11:04:31 -0700719func perf(b *specs.TasksCfgBuilder, name string, parts map[string]string, compileTaskName string, pkgs []*specs.CipdPackage) string {
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500720 recipe := "swarm_perf"
721 isolate := "perf_skia.isolate"
722 if strings.Contains(parts["extra_config"], "Skpbench") {
723 recipe = "swarm_skpbench"
724 isolate = "skpbench_skia.isolate"
725 }
Eric Boren4b254b92016-11-08 12:55:32 -0500726 s := &specs.TaskSpec{
Eric Boren1f2f64b2016-11-09 18:35:15 -0500727 CipdPackages: pkgs,
728 Dependencies: []string{compileTaskName},
729 Dimensions: swarmDimensions(parts),
730 ExecutionTimeout: 4 * time.Hour,
731 Expiration: 20 * time.Hour,
borenetdb182c72016-09-30 12:53:12 -0700732 ExtraArgs: []string{
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500733 "--workdir", "../../..", recipe,
skia.buildbots2478c732016-11-04 14:37:26 -0400734 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700735 fmt.Sprintf("buildername=%s", name),
736 "mastername=fake-master",
737 "buildnumber=2",
738 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700739 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700740 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
741 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700742 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400743 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
744 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700745 },
Eric Boren1f2f64b2016-11-09 18:35:15 -0500746 IoTimeout: 40 * time.Minute,
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500747 Isolate: isolate,
Eric Boren1f2f64b2016-11-09 18:35:15 -0500748 Priority: 0.8,
Eric Boren4b254b92016-11-08 12:55:32 -0500749 }
750 if strings.Contains(parts["extra_config"], "Valgrind") {
751 s.ExecutionTimeout = 9 * time.Hour
752 s.Expiration = 48 * time.Hour
753 s.IoTimeout = time.Hour
754 } else if strings.Contains(parts["extra_config"], "MSAN") {
755 s.ExecutionTimeout = 9 * time.Hour
756 }
757 b.MustAddTask(name, s)
758
borenetdb182c72016-09-30 12:53:12 -0700759 // Upload results if necessary.
760 if strings.Contains(name, "Release") && doUpload(name) {
761 uploadName := fmt.Sprintf("%s%s%s", PREFIX_UPLOAD, jobNameSchema.Sep, name)
boreneted20a702016-10-20 11:04:31 -0700762 b.MustAddTask(uploadName, &specs.TaskSpec{
borenetdb182c72016-09-30 12:53:12 -0700763 Dependencies: []string{name},
Eric Boren4b254b92016-11-08 12:55:32 -0500764 Dimensions: LINUX_GCE_DIMENSIONS,
borenetdb182c72016-09-30 12:53:12 -0700765 ExtraArgs: []string{
766 "--workdir", "../../..", "upload_nano_results",
skia.buildbots2478c732016-11-04 14:37:26 -0400767 fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO),
borenetdb182c72016-09-30 12:53:12 -0700768 fmt.Sprintf("buildername=%s", name),
769 "mastername=fake-master",
770 "buildnumber=2",
771 "slavename=fake-buildslave",
borenet98b2e7a2016-10-13 06:23:45 -0700772 "nobuildbot=True",
borenetdb182c72016-09-30 12:53:12 -0700773 fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR),
774 fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION),
borenet98b2e7a2016-10-13 06:23:45 -0700775 fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE),
skia.buildbots2478c732016-11-04 14:37:26 -0400776 fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE),
777 fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET),
borenetdb182c72016-09-30 12:53:12 -0700778 },
779 Isolate: "upload_nano_results.isolate",
780 Priority: 0.8,
boreneted20a702016-10-20 11:04:31 -0700781 })
borenetdb182c72016-09-30 12:53:12 -0700782 return uploadName
783 }
784 return name
785}
786
787// process generates tasks and jobs for the given job name.
boreneted20a702016-10-20 11:04:31 -0700788func process(b *specs.TasksCfgBuilder, name string) {
borenetdb182c72016-09-30 12:53:12 -0700789 deps := []string{}
790
791 parts, err := jobNameSchema.ParseJobName(name)
792 if err != nil {
793 glog.Fatal(err)
794 }
795
796 // RecreateSKPs.
797 if strings.Contains(name, "RecreateSKPs") {
boreneted20a702016-10-20 11:04:31 -0700798 deps = append(deps, recreateSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -0700799 }
800
801 // CT bots.
802 if strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700803 deps = append(deps, ctSKPs(b, name))
borenetdb182c72016-09-30 12:53:12 -0700804 }
805
borenet2dbbfa52016-10-14 06:32:09 -0700806 // Infra tests.
807 if name == "Housekeeper-PerCommit-InfraTests" {
boreneted20a702016-10-20 11:04:31 -0700808 deps = append(deps, infra(b, name))
borenet2dbbfa52016-10-14 06:32:09 -0700809 }
810
borenetdb182c72016-09-30 12:53:12 -0700811 // Compile bots.
812 if parts["role"] == "Build" {
boreneted20a702016-10-20 11:04:31 -0700813 deps = append(deps, compile(b, name, parts))
borenetdb182c72016-09-30 12:53:12 -0700814 }
815
Eric Borenf5a90e82016-11-15 15:18:20 -0500816 // Most remaining bots need a compile task.
borenetdb182c72016-09-30 12:53:12 -0700817 compileTaskName := deriveCompileTaskName(name, parts)
borenet52383432016-10-17 10:17:53 -0700818 compileTaskParts, err := jobNameSchema.ParseJobName(compileTaskName)
819 if err != nil {
820 glog.Fatal(err)
821 }
Eric Boren628e78b2016-11-17 11:33:27 -0500822 // These bots do not need a compile task.
Eric Borenf5a90e82016-11-15 15:18:20 -0500823 if parts["role"] != "Build" &&
824 name != "Housekeeper-PerCommit-InfraTests" &&
Eric Boren71b762f2016-11-30 14:05:16 -0500825 !strings.Contains(name, "RecreateSKPs") &&
826 !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700827 compile(b, compileTaskName, compileTaskParts)
borenet52383432016-10-17 10:17:53 -0700828 }
borenetdb182c72016-09-30 12:53:12 -0700829
830 // Housekeeper.
Eric Boren22f5ef72016-12-02 11:01:33 -0500831 if name == "Housekeeper-PerCommit" {
boreneted20a702016-10-20 11:04:31 -0700832 deps = append(deps, housekeeper(b, name, compileTaskName))
borenetdb182c72016-09-30 12:53:12 -0700833 }
834
835 // Common assets needed by the remaining bots.
836 pkgs := []*specs.CipdPackage{
boreneted20a702016-10-20 11:04:31 -0700837 b.MustGetCipdPackageFromAsset("skimage"),
838 b.MustGetCipdPackageFromAsset("skp"),
839 b.MustGetCipdPackageFromAsset("svg"),
borenetdb182c72016-09-30 12:53:12 -0700840 }
Eric Boren4b254b92016-11-08 12:55:32 -0500841 if strings.Contains(name, "Ubuntu") && strings.Contains(name, "SAN") {
842 pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("clang_linux"))
843 }
Kevin Lubickb03b5ac2016-11-14 13:42:27 -0500844 // Skpbench only needs skps
845 if strings.Contains(name, "Skpbench") {
846 pkgs = []*specs.CipdPackage{
847 b.MustGetCipdPackageFromAsset("skp"),
848 }
849 }
borenetdb182c72016-09-30 12:53:12 -0700850
851 // Test bots.
Eric Boren71b762f2016-11-30 14:05:16 -0500852 if parts["role"] == "Test" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700853 deps = append(deps, test(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -0700854 }
855
856 // Perf bots.
Eric Boren71b762f2016-11-30 14:05:16 -0500857 if parts["role"] == "Perf" && !strings.Contains(name, "-CT_") {
boreneted20a702016-10-20 11:04:31 -0700858 deps = append(deps, perf(b, name, parts, compileTaskName, pkgs))
borenetdb182c72016-09-30 12:53:12 -0700859 }
860
861 // Add the Job spec.
Eric Borenf5a90e82016-11-15 15:18:20 -0500862 j := &specs.JobSpec{
borenetdb182c72016-09-30 12:53:12 -0700863 Priority: 0.8,
864 TaskSpecs: deps,
Eric Borenf5a90e82016-11-15 15:18:20 -0500865 }
866 if name == "Housekeeper-Nightly-RecreateSKPs_Canary" {
867 j.Trigger = "nightly"
868 }
869 if name == "Housekeeper-Weekly-RecreateSKPs" {
870 j.Trigger = "weekly"
871 }
Eric Boren71b762f2016-11-30 14:05:16 -0500872 if name == "Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs" {
873 j.Trigger = "weekly"
874 }
Eric Boren8615fe52016-12-12 14:30:12 -0500875 b.MustAddJob(name, j)
borenetdb182c72016-09-30 12:53:12 -0700876}
877
borenetdb182c72016-09-30 12:53:12 -0700878// Regenerate the tasks.json file.
879func main() {
boreneted20a702016-10-20 11:04:31 -0700880 b := specs.MustNewTasksCfgBuilder()
borenetdb182c72016-09-30 12:53:12 -0700881 // Create the JobNameSchema.
Eric Boren6441a462017-01-13 13:37:53 -0500882 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 -0700883 if err != nil {
884 glog.Fatal(err)
885 }
886 jobNameSchema = schema
887
borenetdb182c72016-09-30 12:53:12 -0700888 // Create Tasks and Jobs.
boreneted20a702016-10-20 11:04:31 -0700889 for _, name := range JOBS {
890 process(b, name)
borenetdb182c72016-09-30 12:53:12 -0700891 }
892
boreneted20a702016-10-20 11:04:31 -0700893 b.MustFinish()
borenetdb182c72016-09-30 12:53:12 -0700894}
895
896// TODO(borenet): The below really belongs in its own file, probably next to the
897// builder_name_schema.json file.
898
899// JobNameSchema is a struct used for (de)constructing Job names in a
900// predictable format.
901type JobNameSchema struct {
902 Schema map[string][]string `json:"builder_name_schema"`
903 Sep string `json:"builder_name_sep"`
904}
905
906// NewJobNameSchema returns a JobNameSchema instance based on the given JSON
907// file.
908func NewJobNameSchema(jsonFile string) (*JobNameSchema, error) {
909 var rv JobNameSchema
910 f, err := os.Open(jsonFile)
911 if err != nil {
912 return nil, err
913 }
914 defer util.Close(f)
915 if err := json.NewDecoder(f).Decode(&rv); err != nil {
916 return nil, err
917 }
918 return &rv, nil
919}
920
921// ParseJobName splits the given Job name into its component parts, according
922// to the schema.
923func (s *JobNameSchema) ParseJobName(n string) (map[string]string, error) {
924 split := strings.Split(n, s.Sep)
925 if len(split) < 2 {
926 return nil, fmt.Errorf("Invalid job name: %q", n)
927 }
928 role := split[0]
929 split = split[1:]
930 keys, ok := s.Schema[role]
931 if !ok {
932 return nil, fmt.Errorf("Invalid job name; %q is not a valid role.", role)
933 }
934 extraConfig := ""
935 if len(split) == len(keys)+1 {
936 extraConfig = split[len(split)-1]
937 split = split[:len(split)-1]
938 }
939 if len(split) != len(keys) {
940 return nil, fmt.Errorf("Invalid job name; %q has incorrect number of parts.", n)
941 }
942 rv := make(map[string]string, len(keys)+2)
943 rv["role"] = role
944 if extraConfig != "" {
945 rv["extra_config"] = extraConfig
946 }
947 for i, k := range keys {
948 rv[k] = split[i]
949 }
950 return rv, nil
951}
952
953// MakeJobName assembles the given parts of a Job name, according to the schema.
954func (s *JobNameSchema) MakeJobName(parts map[string]string) (string, error) {
955 role, ok := parts["role"]
956 if !ok {
957 return "", fmt.Errorf("Invalid job parts; jobs must have a role.")
958 }
959 keys, ok := s.Schema[role]
960 if !ok {
961 return "", fmt.Errorf("Invalid job parts; unknown role %q", role)
962 }
963 rvParts := make([]string, 0, len(parts))
964 rvParts = append(rvParts, role)
965 for _, k := range keys {
966 v, ok := parts[k]
967 if !ok {
968 return "", fmt.Errorf("Invalid job parts; missing %q", k)
969 }
970 rvParts = append(rvParts, v)
971 }
972 if _, ok := parts["extra_config"]; ok {
973 rvParts = append(rvParts, parts["extra_config"])
974 }
975 return strings.Join(rvParts, s.Sep), nil
976}