| // Copyright 2023 The Fuchsia Authors. All rights reserved |
| // Use of this source code is governed by a BSD-style license that can |
| // found in the LICENSE file. |
| package main |
| |
| import ( |
| "context" |
| "fmt" |
| |
| "github.com/golang/protobuf/ptypes/any" |
| "go.chromium.org/luci/luciexe/build" |
| ftxproto "go.fuchsia.dev/infra/cmd/ftxtest/proto" |
| ) |
| |
| func main() { |
| input := &ftxproto.InputProperties{} |
| var writeOutputProps func(*any.Any) |
| build.Main(input, &writeOutputProps, nil, func(ctx context.Context, extraArgs []string, state *build.State) error { |
| _, _, err := LaunchTaskStep(ctx) |
| if err != nil { |
| return fmt.Errorf("LaunchTaskStep: %v", err) |
| } |
| return nil |
| }) |
| } |
| |
| func LaunchTaskStep(ctx context.Context) (*Swarming, string, error) { |
| step, ctx := build.StartStep(ctx, "Launch Swarming Task") |
| swarming, err := NewSwarming(ctx) |
| if err != nil { |
| step.End(err) |
| return nil, "", fmt.Errorf("NewSwarming: %v", err) |
| } |
| taskId, err := swarming.LaunchTask() |
| if err != nil { |
| step.End(err) |
| return nil, "", fmt.Errorf("LaunchTask: %v", err) |
| } |
| md := fmt.Sprintf("* [swarming task](https://chrome-swarming.appspot.com/task?id=%s)", taskId) |
| step.SetSummaryMarkdown(md) |
| step.End(nil) |
| return swarming, taskId, nil |
| } |