blob: 21743f53e0ef9f2cd8a9aea06317c750b6bdc3c1 [file] [log] [blame]
# Copyright 2020 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 testing Recipes."""
from PB.recipes.fuchsia.recipes import InputProperties
DEPS = [
"fuchsia/commit_queue",
"fuchsia/git_checkout",
"fuchsia/recipe_testing",
"recipe_engine/buildbucket",
"recipe_engine/defer",
"recipe_engine/properties",
]
PROPERTIES = InputProperties
# If this build is being triggered from a change to this recipe, we need
# to explicitly pass a CL. The most recent passing run of
# fuchsia.try/recipes could take anywhere from about three to 200 minutes,
# and the three minute version does not test much of what this recipe
# actually does. In that case alter the recipes build to run on a specific
# CL that modifies the cobalt recipe alone. (The cobalt build usually
# takes less than 10 minutes.)
SELFTEST_CL = "https://fuchsia-review.googlesource.com/c/infra/recipes/+/303171"
# If this build is being triggered from a change to this recipe, and we're
# using the Buildbucket testing codepath, then we need to explicitly pass a
# builder. This builder will run in the case that the only affected recipe is
# this one, so we are guaranteed to exercise the scheduling codepath without
# recursing infinitely.
SELFTEST_BUILDER = "fuchsia/try/bringup.x64-debug-no_opt-build_only"
def RunSteps(api, props):
"""Run tests for recipes."""
recipes_path, _ = api.git_checkout(props.remote)
deferred = []
# TODO(olivernewman): Stop allowlisting pipes after it's no longer used by
# gcc_toolchain.
deferred.append(
api.defer(
api.recipe_testing.run_lint,
recipes_path,
allowlist=r"^(pipes|shlex)$",
)
)
deferred.append(api.defer(api.recipe_testing.run_unit_tests, recipes_path))
api.defer.collect(deferred)
if not props.unittest_only:
api.recipe_testing.run_tests(
recipes_path,
SELFTEST_CL,
props.recipe_testing_options,
selftest_builder=SELFTEST_BUILDER,
)
def GenTests(api): # pylint: disable=invalid-name
def test(name, status="SUCCESS", run_tests=True, projects=(), **props):
ret = (
api.test(name, status=status)
+ api.buildbucket.try_build(
project="fuchsia",
git_repo="https://fuchsia.googlesource.com/infra/recipes",
)
+ api.properties(
manifest="manifest/minimal",
remote="https://fuchsia.googlesource.com/infra/recipes",
**props,
)
)
if projects:
ret += api.recipe_testing.options(projects=projects)
if run_tests:
ret += api.commit_queue.test_data(
"fuchsia", config_name=projects[0].cq_config_name
) + api.recipe_testing.affected_recipes_data(["none"])
return ret
yield (
test(
"cq_try",
projects=(
api.recipe_testing.project(
cq_config_name="alternate-commit-queue.cfg",
),
),
)
+ api.recipe_testing.build_data(
"fuchsia/try/core.x64-debug", "fuchsia", skip=True
)
+ api.recipe_testing.build_data(
"fuchsia/try/core.arm64-debug", "fuchsia", skip=True
)
+ api.recipe_testing.build_data(
"fuchsia/try/cobalt-x64-linux", "cobalt", skip=True
)
)
yield (
test(
"cq_try_restricted",
projects=(
api.recipe_testing.project(
include_unrestricted=False,
include_restricted=True,
cq_config_name="alternate-commit-queue.cfg",
),
),
)
+ api.recipe_testing.build_data("fuchsia/try/secret-tryjob", "docs", skip=True)
)