| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| package main |
| |
| /* |
| Generate the tasks.json file. |
| */ |
| |
| import ( |
| "fmt" |
| "strings" |
| |
| "go.skia.org/infra/task_scheduler/go/specs" |
| ) |
| |
| const ( |
| DEFAULT_OS = DEFAULT_OS_LINUX |
| DEFAULT_OS_LINUX = "Debian-9.1" |
| |
| // Pool for Skia bots. |
| POOL_SKIA = "Skia" |
| ) |
| |
| var ( |
| // "Constants" |
| |
| // Top-level list of all Jobs to run at each commit. |
| JOBS = []string{ |
| "Infra-PerCommit-Small", |
| "Infra-PerCommit-Medium", |
| "Infra-PerCommit-Large", |
| "Infra-PerCommit-Race", |
| } |
| ) |
| |
| // infra generates an infra test Task. Returns the name of the last Task in the |
| // generated chain of Tasks, which the Job should add as a dependency. |
| func infra(b *specs.TasksCfgBuilder, name string) string { |
| pkgs := []*specs.CipdPackage{b.MustGetCipdPackageFromAsset("go")} |
| if strings.Contains(name, "Large") { |
| pkgs = append(pkgs, b.MustGetCipdPackageFromAsset("protoc")) |
| } |
| attempts := 2 |
| if strings.Contains(name, "Race") { |
| attempts = 1 |
| } |
| b.MustAddTask(name, &specs.TaskSpec{ |
| CipdPackages: pkgs, |
| Dimensions: []string{ |
| "pool:Skia", |
| fmt.Sprintf("os:%s", DEFAULT_OS_LINUX), |
| "gpu:none", |
| "cpu:x86-64-Haswell_GCE", |
| }, |
| ExtraArgs: []string{ |
| "--workdir", "../../..", "swarm_infra", |
| fmt.Sprintf("repository=%s", specs.PLACEHOLDER_REPO), |
| fmt.Sprintf("buildername=%s", name), |
| "mastername=fake-master", |
| "buildnumber=2", |
| "slavename=fake-buildslave", |
| "nobuildbot=True", |
| fmt.Sprintf("swarm_out_dir=%s", specs.PLACEHOLDER_ISOLATED_OUTDIR), |
| fmt.Sprintf("revision=%s", specs.PLACEHOLDER_REVISION), |
| fmt.Sprintf("patch_storage=%s", specs.PLACEHOLDER_PATCH_STORAGE), |
| fmt.Sprintf("patch_issue=%s", specs.PLACEHOLDER_ISSUE), |
| fmt.Sprintf("patch_set=%s", specs.PLACEHOLDER_PATCHSET), |
| }, |
| Isolate: "swarm_recipe.isolate", |
| Priority: 0.8, |
| MaxAttempts: attempts, |
| }) |
| return name |
| } |
| |
| // process generates Tasks and Jobs for the given Job name. |
| func process(b *specs.TasksCfgBuilder, name string) { |
| deps := []string{} |
| |
| // Infra tests. |
| if strings.Contains(name, "Infra-PerCommit") { |
| deps = append(deps, infra(b, name)) |
| } |
| |
| // Add the Job spec. |
| b.MustAddJob(name, &specs.JobSpec{ |
| Priority: 0.8, |
| TaskSpecs: deps, |
| }) |
| } |
| |
| // Regenerate the tasks.json file. |
| func main() { |
| b := specs.MustNewTasksCfgBuilder() |
| |
| // Create Tasks and Jobs. |
| for _, name := range JOBS { |
| process(b, name) |
| } |
| |
| b.MustFinish() |
| } |