blob: c74b0933ad7204efd2c5429efc7eb945533114cd [file] [log] [blame]
# Copyright 2018 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.
from google.protobuf import json_format
from recipe_engine.config import List
from recipe_engine.recipe_api import Property
from PB.infra.fuchsia import Fuchsia
DEPS = [
"fuchsia/checkout",
"fuchsia/jiri",
"recipe_engine/buildbucket",
"recipe_engine/json",
"recipe_engine/raw_io",
]
PROPERTIES = {
"project": Property(
kind=str,
help="The name of that jiri should assign to the project",
default="garnet",
),
"remote": Property(
kind=str,
help="The remote URL of the manifest repo",
default="https://fuchsia.googlesource.com/manifest",
),
"manifest": Property(
kind=str,
help="The name of the manifest to import from the integration repo",
default="minimal",
),
"is_release_version": Property(
kind=bool, help="Whether or not checkout is a release version", default=False
),
"attributes": Property(
kind=List(str),
help="Attributes corresponding to optional packages or projects to checkout",
default=(),
),
}
def RunSteps(api, project, remote, manifest, is_release_version, attributes):
checkout_spec = Fuchsia.Checkout(
project=project,
remote=remote,
manifest=manifest,
is_release_version=is_release_version,
attributes=attributes,
)
checkout = api.checkout.from_spec(checkout_spec)
assert checkout.root_dir
assert checkout.snapshot_file
checkout.release_version # pylint: disable=pointless-statement
checkout.changed_files(api.buildbucket.build.input)
checkout.upload_results("gcs_bucket")
checkout.upload_source_manifest("gcs_artifact_bucket")
def GenTests(api):
yield api.checkout.test(
"default", source_info={}, # Just to cover part of test API
)
yield api.checkout.test(
"global_integration_tryjob", properties=dict(project="integration",),
)
yield api.checkout.test(
"global_integration_ci",
properties=dict(project="integration", bucket="global",),
) + api.buildbucket.ci_build(
git_repo="https://fuchsia.googlesource.com/integration"
)
yield api.checkout.test(
"global_integration_release_ci",
tryjob=False,
properties=dict(
project="integration",
bucket="global",
is_release_version=True,
attributes=["attr1", "attr2"],
),
) + api.buildbucket.ci_build(
git_repo="https://fuchsia.googlesource.com/integration"
) + api.step_data(
"checkout.git describe", api.raw_io.stream_output("releases/0.20190603.0.1")
)
yield api.checkout.test(
"global_integration_release_ci_invalid_tag",
status="failure",
tryjob=False,
properties=dict(
project="integration", bucket="global", is_release_version=True,
),
) + api.buildbucket.ci_build(
git_repo="https://fuchsia.googlesource.com/integration"
) + api.step_data(
"checkout.git describe", api.raw_io.stream_output("invalidtag")
)
yield api.checkout.test(
"local_integration_tryjob", properties=dict(project="garnet",),
)
yield api.checkout.test(
"local_integration_tryjob_patch_failure",
status="infra_failure",
properties=dict(project="garnet",),
) + api.step_data("checkout.jiri patch", retcode=1)
yield api.checkout.test(
"local_integration_tryjob_patch_rebase_failure",
status="failure",
properties=dict(project="garnet",),
) + api.step_data("checkout.jiri patch", retcode=api.jiri.RebaseError.EXIT_CODE)
yield api.checkout.test(
"local_integration_ci", tryjob=False,
) + api.buildbucket.ci_build(git_repo="https://fuchsia.googlesource.com/not-garnet")
yield api.checkout.test(
"tryjob_with_patchfile",
properties=dict(project="garnet",),
patchfile=[
{
"ref": "refs/changes/cc/aabbcc/1",
"host": "example-review.googlesource.com",
"project": "not_garnet",
}
],
)
yield api.checkout.test(
"fail_to_patch_over_gerrit_change",
status="failure",
properties=dict(project="garnet",),
patchfile=[
{
"ref": "refs/changes/cc/aabbcc/1",
"host": "fuchsia-review.googlesource.com",
"project": "garnet",
}
],
)
yield api.checkout.test(
"fail_to_patch_same_project_many_times",
status="failure",
properties=dict(project="garnet",),
patchfile=[
{
"ref": "refs/changes/cc/aabbcc/1",
"host": "fuchsia-review.googlesource.com",
"project": "zircon",
},
{
"ref": "refs/changes/ff/ddeeff/2",
"host": "fuchsia-review.googlesource.com",
"project": "zircon",
},
],
)
yield api.checkout.test(
"when_patchfile_host_has_protocol",
properties=dict(project="garnet",),
patchfile=[
{
"ref": "refs/changes/cc/aabbcc/1",
"host": "https://fuchsia-review.googlesource.com",
"project": "zircon",
}
],
)
yield api.checkout.test(
"should_ignore_patches_for_non_dependant_projects",
properties=dict(project="zircon",),
patchfile=[
{
"ref": "refs/changes/cc/aabbcc/1",
"host": "https://fuchsia-review.googlesource.com",
"project": "topaz",
# TODO(tonglisayhi): Figure out a way to inject this step_data with
# whatever nesting this step is
}
],
) + api.step_data("checkout.jiri project", api.json.output([]))
yield api.checkout.test(
"sso_manifest_remote", properties=dict(remote="sso://manifest-host/manifest")
) + api.buildbucket.ci_build(git_repo="https://fuchsia.googlesource.com/not-garnet")
yield api.checkout.test(
"subbuild_from_spec",
properties={
"spec_msg": json_format.MessageToJson(
Fuchsia(
checkout=Fuchsia.Checkout(
project="integration",
manifest="minimal",
remote="https://fuchsia.googlesource.com/manifest",
)
)
),
},
)
yield api.checkout.test(
"use_gitiles_commit_from_properties",
tryjob=False,
properties={
"checkout.buildset": "commit/gitiles/fuchsia.googlesource.com/foo/+/deadbeef",
},
)