| # Copyright 2022 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| """Recipe for triggering builders required by ci in presubmit.""" |
| |
| from PB.recipes.fuchsia.run_postsubmit_tryjobs import InputProperties |
| |
| DEPS = [ |
| "fuchsia/buildbucket_util", |
| "fuchsia/cl_util", |
| "fuchsia/subbuild", |
| "recipe_engine/buildbucket", |
| "recipe_engine/properties", |
| "recipe_engine/step", |
| ] |
| |
| PROPERTIES = InputProperties |
| |
| |
| def RunSteps(api, props): |
| gerrit_change = api.buildbucket.build.input.gerrit_changes[0] |
| rpt_builder_names = api.cl_util.get_postsubmit_tryjobs( |
| change_id=str(gerrit_change.change), |
| host=gerrit_change.host, |
| project=gerrit_change.project, |
| trigger_all_presubmit=props.trigger_all_presubmit, |
| ) |
| |
| with api.step.nest("launch postsubmit builders") as presentation: |
| rpt_builds = api.subbuild.launch( |
| builder_names=rpt_builder_names, |
| presentation=presentation, |
| hide_in_gerrit=False, |
| set_swarming_parent_run_id=False, |
| include_sub_invs=False, |
| ) |
| |
| with api.step.nest("collect postsubmit builds"): |
| rpt_builds = api.subbuild.collect( |
| build_ids=[b.build_id for b in rpt_builds.values()], |
| ) |
| |
| rpt_build_protos = [b.build_proto for b in rpt_builds.values()] |
| # Display postsubmit builds status and show failures on UI, if any. |
| api.buildbucket_util.display_builds( |
| step_name="display postsubmit subbuilds", |
| builds=rpt_build_protos, |
| raise_on_failure=True, |
| ) |
| |
| |
| def GenTests(api): |
| def properties(): |
| return api.properties( |
| trigger_all_presubmit=False, |
| ) |
| |
| yield (api.buildbucket_util.test("basic", tryjob=True) + properties()) |