blob: 69d37523701ce3abe239d08cb5e0f86810ad0bfd [file] [log] [blame]
# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Recipe for testing recipes."""
from PB.recipes.pigweed.recipes import InputProperties
DEPS = [
'fuchsia/commit_queue',
'fuchsia/recipe_testing',
'fuchsia/status_check',
'pigweed/checkout',
'recipe_engine/properties',
'recipe_engine/step',
]
PROPERTIES = InputProperties
PYTHON_VERSION_COMPATIBILITY = "PY3"
# 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
# pigweed.try/recipes could have any number of different subbuilds kicked
# off. In that case alter the recipes build to run on a specific CL that
# modifies the xrefs recipe alone, because that recipe is used by
# relatively few CQ builders.
SELFTEST_CL = (
'https://pigweed-review.googlesource.com/c/infra/recipes/+/21160/2'
)
COMMIT_QUEUE_CFG = """
submit_options: <
max_burst: 4
burst_delay: <
seconds: 480
>
>
config_groups: <
gerrit: <
url: "https://pigweed-review.googlesource.com"
projects: <
name: "project"
ref_regexp: "refs/heads/.+"
>
>
verifiers: <
gerrit_cq_ability: <
committer_list: "project-pigweed-committers"
dry_run_access_list: "project-pigweed-tryjob-access"
>
tryjob: <
builders: <
name: "pigweed/try/pigweed-baz"
location_regexp: ".*"
location_regexp_exclude: ".+/[+]/.*\\.md"
>
>
>
>
config_groups: <
gerrit: <
url: "https://pigweed-review.googlesource.com"
projects: <
name: "pigweed/pigweed"
ref_regexp: "refs/heads/.+"
>
>
verifiers: <
gerrit_cq_ability: <
committer_list: "project-pigweed-committers"
dry_run_access_list: "project-pigweed-tryjob-access"
>
tryjob: <
builders: <
name: "pigweed/try/pigweed-bar"
location_regexp: ".*"
location_regexp_exclude: ".+/[+]/.*\\.md"
location_regexp_exclude: ".+/[+].*/docs/.+"
>
builders: <
name: "pigweed/try/pigweed-foo"
location_regexp: ".*"
location_regexp_exclude: ".+/[+]/.*\\.md"
location_regexp_exclude: ".+/[+].*/docs/.+"
>
>
>
>
"""
def RunSteps(api, props):
api.checkout()
with api.step.defer_results():
api.recipe_testing.run_lint(
api.checkout.root,
allowlist='xml|ConfigParser|StringIO|six.moves.urllib',
)
api.recipe_testing.run_unit_tests(api.checkout.root)
if not props.unittest_only:
api.recipe_testing.run_tests(
api.checkout.root, SELFTEST_CL, props.recipe_testing_options,
)
def GenTests(api): # pylint: disable=invalid-name
"""Create tests."""
def properties(**kwargs):
new_kwargs = api.checkout.git_properties()
new_kwargs.update(kwargs)
return api.properties(**new_kwargs)
yield (
api.status_check.test('cq_try')
+ properties(unittest_only=False)
+ api.recipe_testing.config((api.recipe_testing.project('pigweed'),))
+ api.checkout.try_test_data()
+ api.commit_queue.test_data('pigweed', COMMIT_QUEUE_CFG)
+ api.recipe_testing.affected_recipes_data(['none'])
+ api.recipe_testing.build_data(
'pigweed/try/pigweed-foo', 'pigweed', skip=True, project='pigweed'
)
+ api.recipe_testing.build_data(
'pigweed/try/pigweed-bar', 'pigweed', skip=True, project='pigweed'
)
+ api.recipe_testing.build_data(
'pigweed/try/pigweed-baz', 'project', skip=True, project='pigweed'
)
)