| # Copyright 2023 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. |
| |
| """Ensure supported API levels in a config repo are in sync with fuchsia.git.""" |
| |
| from PB.go.chromium.org.luci.buildbucket.proto import build as build_pb2 |
| from PB.recipes.fuchsia.release.api_level_roller import InputProperties |
| |
| DEPS = [ |
| "fuchsia/auto_roller", |
| "fuchsia/checkout", |
| "fuchsia/gitiles", |
| "fuchsia/jiri", |
| "recipe_engine/context", |
| "recipe_engine/file", |
| "recipe_engine/json", |
| "recipe_engine/properties", |
| "recipe_engine/step", |
| ] |
| |
| PROPERTIES = InputProperties |
| COMMIT_MESSAGE = """[roll] Synchronize supported API levels""" |
| |
| |
| def RunSteps(api, props): |
| with api.step.nest("resolve target API levels"): |
| file_content = api.gitiles.fetch( |
| "fuchsia.googlesource.com", |
| "fuchsia", |
| "sdk/version_history.json", |
| ).decode() |
| target_platform_version = api.json.loads(file_content) |
| |
| checkout = api.checkout.fuchsia_with_options( |
| manifest=props.manifest, |
| remote=props.remote, |
| project=props.project, |
| # Ignore the build input; we should always check out the manifest |
| # repository at HEAD before updating the manifest to reduce the |
| # likelihood of merge conflicts. |
| build_input=build_pb2.Build.Input(), |
| fetch_packages=False, |
| use_lock_file=True, |
| ) |
| project_path = checkout.project_path(props.project) |
| |
| api.file.write_json( |
| "synchronize supported API levels", |
| project_path / props.platform_version_path, |
| target_platform_version, |
| ) |
| api.step( |
| "initialize CTF manifests", |
| [project_path / props.ctf_manifest_generator_path, "--no-dry-run"], |
| ) |
| api.step( |
| "generate configs", |
| [project_path / props.config_generator_path], |
| ) |
| with api.context(cwd=project_path): |
| api.step( |
| "update lockfiles", |
| [project_path / props.update_lockfiles_path, "--jiri", api.jiri.jiri], |
| ) |
| |
| change = api.auto_roller.attempt_roll( |
| props.roll_options, |
| repo_dir=project_path, |
| commit_message=COMMIT_MESSAGE, |
| ) |
| return api.auto_roller.raw_result(change) |
| |
| |
| def GenTests(api): |
| default_props = api.properties( |
| project="integration", |
| manifest="minimal", |
| remote="https://fuchsia.googlesource.com/integration", |
| platform_version_path="config/version_history.json", |
| config_generator_path="config/generator.sh", |
| ctf_manifest_generator_path="fuchsia/ctf/ctf_generate_manifest.py", |
| update_lockfiles_path="update-lockfiles.sh", |
| roll_options=api.auto_roller.Options( |
| remote="https://fuchsia.googlesource.com/integration", |
| ), |
| ) |
| |
| default_platform_version = { |
| "data": { |
| "api_levels": { |
| "1": { |
| "status": "unsupported", |
| }, |
| "2": { |
| "status": "supported", |
| }, |
| "3": { |
| "status": "supported", |
| }, |
| "4": { |
| "status": "in-development", |
| }, |
| } |
| } |
| } |
| |
| yield api.test( |
| "roll_and_generate_version_history" |
| ) + api.auto_roller.success() + api.gitiles.fetch( |
| "resolve target API levels.fetch", |
| api.json.dumps(default_platform_version).encode(), |
| ) + default_props |