blob: 84f2195e8fbb68d45b2677a1618ea05a48b4363a [file] [log] [blame]
# -*- coding: utf-8 -*-
# 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.
from PB.go.chromium.org.luci.buildbucket.proto import builder as builder_pb2
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
DEPS = [
"fuchsia/buildbucket_util",
"fuchsia/status_check",
"recipe_engine/buildbucket",
"recipe_engine/properties",
]
def RunSteps(api):
builds = api.buildbucket.collect_builds(
build_ids=[
123456789012345678,
987654321098765432,
112233445566778899,
199887766554433221,
]
)
build = builds.values()[0]
api.buildbucket_util.last_build(
build.builder.project,
build.builder.bucket,
build.builder.builder,
status=common_pb2.FAILURE,
)
api.buildbucket_util.full_builder_name(
builder_pb2.BuilderID(
project=build.builder.project,
bucket=build.builder.bucket,
builder=build.builder.builder,
),
)
# Truncation should happen here due to overlarge raw text and small max line
# length.
api.buildbucket_util.summary_message(
"INFO: useful information\n" * 1000, "(message truncated)", max_line_length=5,
)
# No truncation should happen here.
api.buildbucket_util.summary_message(
"INFO: useful information\n" * 10, "(message truncated)",
)
# Truncation should happen here, but the split must not be in the middle of
# a unicode char's bytes or else the string will no longer be valid utf-8
# and passing it into a Build proto's summary_markdown field will fail.
char = "😊"
original_summary = char * 10
truncated_summary = api.buildbucket_util.summary_message(
original_summary, "(message truncated)", max_line_length=(5 * len(char)) - 1
)
# This should not fail (the summary should be valid UTF-8).
truncated_summary.decode("utf-8")
# pylint: disable=pointless-statement
api.buildbucket_util.is_tryjob
api.buildbucket_util.id
api.buildbucket_util.build_url
# pylint: enable=pointless-statement
def GenTests(api):
yield (
api.status_check.test("basic_tryjob")
+ api.buildbucket.build(api.buildbucket.ci_build_message(bucket="try"))
+ api.buildbucket.simulated_search_results([api.buildbucket.ci_build_message()])
)
yield (
api.status_check.test("led_job")
+ api.properties(
**{"$recipe_engine/led": {"led_run_id": "led/user_example.com/abc123"},}
)
)