blob: 1c281116f3ef036bb0a559a9b7cbad8e74fb3c88 [file] [log] [blame]
# Copyright 2023 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.
"""
Runs static analysis checks defined in shac.star in an arbitrary repository.
"""
from PB.recipes.fuchsia.shac import InputProperties
DEPS = [
"fuchsia/buildbucket_util",
"fuchsia/cipd_ensure",
"fuchsia/git_checkout",
"fuchsia/shac",
"recipe_engine/context",
"recipe_engine/properties",
"recipe_engine/step",
]
PROPERTIES = InputProperties
def RunSteps(api, props):
checkout_dir, revision = api.git_checkout(repo=props.remote)
if props.bootstrap_step:
with api.context(cwd=checkout_dir):
api.step(
props.bootstrap_step,
[checkout_dir / props.bootstrap_step],
)
if props.shac_path:
shac_path = checkout_dir / props.shac_path
else:
shac_path = api.cipd_ensure(
api.resource("cipd.ensure"),
"fuchsia/shac/${platform}",
)
api.shac.check(
root=checkout_dir,
shac_path=shac_path,
revision=revision,
entrypoint=props.entrypoint,
)
def GenTests(api):
def properties(**kwargs):
return api.properties(remote="https://foo.googlesource.com/bar", **kwargs)
yield api.buildbucket_util.test("basic") + properties()
yield api.buildbucket_util.test("shac_path") + properties(
bootstrap_step="scripts/bootstrap.sh",
shac_path="tools/shac",
)