| # Copyright 2021 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_common as builder_common_pb2, |
| ) |
| |
| DEPS = [ |
| "fuchsia/binary_size", |
| "fuchsia/status_check", |
| "recipe_engine/json", |
| "recipe_engine/path", |
| "recipe_engine/raw_io", |
| ] |
| |
| |
| def RunSteps(api): |
| binary_sizes_json_input = api.path["start_dir"].join("binary_sizes.json") |
| api.binary_size.check_budgets( |
| "check budgets", |
| binary_sizes_json_input, |
| ) |
| api.binary_size.diff_ci( |
| "size diff against ci", |
| "https://fuchsia.googlesource.com/project", |
| "basecommit", |
| builder_common_pb2.BuilderID( |
| project="fuchsia", |
| bucket="ci", |
| builder="size-builder", |
| ), |
| binary_sizes_json_input, |
| ) |
| |
| |
| def GenTests(api): |
| yield ( |
| api.status_check.test("basic") |
| + api.step_data( |
| "size diff against ci", |
| api.json.output( |
| { |
| "component_diffs": [ |
| { |
| "name": "componentA", |
| "baseline_size": 16, |
| "size": 32, |
| "size_diff": 16, |
| "budget": 48, |
| "creep_budget": 8, |
| "budget_exceeded": False, |
| "creep_budget_exceeded": True, |
| }, |
| ], |
| "creep_budget_exceeded": True, |
| "baseline_build_id": 123456, |
| } |
| ), |
| ) |
| ) |
| |
| yield ( |
| api.status_check.test("budget_checks_failed", status="failure") |
| + api.step_data( |
| "check budgets", |
| stderr=api.raw_io.output_text("componentA size exceeds budget by 8 bytes"), |
| retcode=1, |
| ) |
| ) |
| |
| yield ( |
| api.status_check.test("ci_build_not_successful") |
| + api.step_data( |
| "size diff against ci", |
| retcode=2, |
| ) |
| ) |