blob: 0dc062b0fc855e188c6d2dc25eb2778cf57ff7fe [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 updating CIPD refs based on the contents of Fuchsia integration."""
from recipe_engine.config import List
from recipe_engine.recipe_api import Property
PYTHON_VERSION_COMPATIBILITY = "PY3"
DEPS = [
"fuchsia/checkout",
"fuchsia/jiri",
"fuchsia/status_check",
"recipe_engine/cipd",
"recipe_engine/path",
"recipe_engine/properties",
]
PROPERTIES = {
"manifest": Property(kind=str, help="Jiri manifest to use.", default="flower"),
"remote": Property(
kind=str,
help="Remote manifest repository.",
default="https://fuchsia.googlesource.com/integration",
),
"packages": Property(
kind=List(str),
help="List of CIPD packages to set <ref> on.",
),
"ref": Property(
kind=str,
help="Ref to set on the CIPD packages.",
default="integration",
),
}
def RunSteps(api, manifest, remote, packages, ref):
# TODO(nmulcahey): Get the manifest structure without checkout out all of
# Fuchsia. Jiri doesn't currently expose this as an explicit option, it
# may be possible to do it by running int + import + using remote
# manifests.
api.checkout.fuchsia_with_options(
manifest=manifest,
path=api.path["start_dir"],
remote=remote,
)
package_data = api.jiri.package(packages).json.output
for package in package_data:
platforms = package.get("platforms", None)
if not platforms:
api.cipd.set_ref(
package_name=package["name"], version=package["version"], refs=[ref]
)
continue
for platform in platforms:
package_name = package["name"].replace("${platform}", platform)
api.cipd.set_ref(
package_name=package_name, version=package["version"], refs=[ref]
)
def GenTests(api):
package_test_data = [
{
"name": "ref-set/${platform}",
"platforms": ["linux-x64", "mac-x64"],
"version": "0123456789ABCDEF",
},
{"name": "ref-set/linux-arm64", "version": "0123456789ABCDEF,1"},
{
"name": "ref-unset/${platform}",
"platforms": ["linux-x64"],
"version": "DEADBEAF",
},
]
properties = {"packages": ["ref-set", "ref-unset"]}
yield (
api.status_check.test("default")
+ api.properties(**properties)
+ api.step_data("jiri package", api.jiri.package(package_test_data))
)