blob: 926f2d85a13ef4ebec2b6e3e3c91855c123564d3 [file] [log] [blame]
# Copyright 2019 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 checking lockfile integrity."""
from recipe_engine.recipe_api import Property
DEPS = [
"fuchsia/checkout",
"fuchsia/git",
"fuchsia/jiri",
"fuchsia/status_check",
"recipe_engine/buildbucket",
"recipe_engine/context",
"recipe_engine/path",
"recipe_engine/properties",
"recipe_engine/step",
]
PROPERTIES = {
"project": Property(kind=str, help="Jiri remote manifest project", default=None),
"manifest": Property(kind=str, help="Jiri manifest to use"),
"remote": Property(kind=str, help="Remote manifest repository"),
"lockfile_script": Property(
kind=str,
help="Script file that updates the lockfiles",
default="update-lockfiles.sh",
),
}
def RunSteps(api, project, manifest, remote, lockfile_script):
with api.context(infra_steps=True):
api.checkout.with_options(
path=api.path["start_dir"],
manifest=manifest,
remote=remote,
project=project,
)
project_dir = api.path["start_dir"].join(*project.split("/"))
lockfile_script_path = project_dir.join(lockfile_script)
with api.context(cwd=project_dir):
diff_before_script = api.git.diff().stdout.strip()
api.step(
"run %s" % lockfile_script, [lockfile_script_path, "--jiri", api.jiri.jiri]
)
diff_after_script = api.git.diff().stdout.strip()
if diff_before_script != diff_after_script: # pragma: no cover
raise api.step.StepFailure(
"lockfiles are not properly updated, please run {} and resubmit your change\nBefore:{}\nAfter:{}".format(
lockfile_script, diff_before_script, diff_after_script
)
)
def GenTests(api):
default_properties = api.properties(
project="integration",
manifest="minimal",
remote="https://fuchsia.googlesource.com",
lockfile_script="update-lockfiles.sh",
)
yield api.status_check.test(
"default"
) + default_properties + api.buildbucket.try_build(
git_repo="https://fuchsia.googlesource.com/integration"
)