| # Copyright 2017 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. |
| |
| DEPS = [ |
| "fuchsia/gerrit", |
| "recipe_engine/buildbucket", |
| "recipe_engine/json", |
| ] |
| |
| |
| def RunSteps(api): |
| gerrit_changes = api.buildbucket.build.input.gerrit_changes |
| if gerrit_changes: |
| api.gerrit.resolve_change(gerrit_changes[0]) |
| |
| assert ( |
| api.gerrit.host_from_remote_url("fuchsia.googlesource.com/foo") |
| == "fuchsia-review.googlesource.com" |
| ) |
| assert api.gerrit.project_from_remote_url("fuchsia.googlesource.com/foo") == "foo" |
| |
| remote = "sso://fuchsia/fuchsia/config" |
| |
| change = api.gerrit.create_change( |
| "create change", |
| api.gerrit.project_from_remote_url(remote), |
| "hello", |
| "main", |
| host=api.gerrit.host_from_remote_url(remote), |
| topic="some-topic", |
| test_data=api.json.test_api.output({"id": "some id"}), |
| ).json.output |
| change_id = change["id"] |
| |
| api.gerrit.change_details( |
| "get details", |
| change_id, |
| host="fuchsia", |
| query_params=["CURRENT_REVISION", "DOWNLOAD_COMMANDS"], |
| max_attempts=3, |
| ) |
| |
| api.gerrit.change_query( |
| "search for change", |
| f"change:{change_id}+status:open", |
| query_params=["ALL_REVISIONS"], |
| ) |
| |
| api.gerrit.list_change_comments("list change comments", change_id) |
| |
| api.gerrit.set_review( |
| "-1", |
| change_id, |
| host="fuchsia-review", |
| labels={"Code-Review": -1}, |
| message="set review", |
| reviewers=["test@example.com"], |
| ccs=["test2@example.com"], |
| notify="ALL", |
| tag="testing", |
| patchset_level_comment={ |
| "message": "test comment", |
| "unresolved": True, |
| }, |
| ) |
| |
| api.gerrit.submit( |
| "submit", |
| change_id, |
| host="https://fuchsia.googlesource.com", |
| ) |
| |
| api.gerrit.abandon( |
| "abandon", |
| change_id, |
| host="https://fuchsia-review.googlesource.com", |
| message="bad CL", |
| notify="ALL", |
| ) |
| |
| api.gerrit.restore_change("restore", change_id, message="retry") |
| |
| api.gerrit.rebase("rebase", change_id) |
| api.gerrit.rebase("rebase", change_id, on_behalf_of_uploader=True) |
| |
| api.gerrit.get_mergeable("get mergeable", change_id) |
| |
| api.gerrit.changes_submitted_together( |
| "submitted together", change_id, query_params=["SUBMITTABLE"] |
| ) |
| |
| api.gerrit.create_branch("create branch", "project", "new-branch", "abcdef") |
| |
| api.gerrit.account_query( |
| "accounts", "email:nobody@google.com", query_params=["DETAILS"] |
| ) |
| |
| |
| def GenTests(api): |
| yield api.test("basic", status="INFRA_FAILURE") + api.step_data( |
| "restore", retcode=1 # Cover exception handling. |
| ) + api.buildbucket.try_build( |
| project="manifest", |
| git_repo="https://fuchsia.googlesource.com/manifest", |
| ) + api.step_data( |
| "get details", retcode=1 |
| ) |
| |
| yield api.test("ci") + api.buildbucket.ci_build( |
| project="manifest", |
| git_repo="https://fuchsia.googlesource.com/manifest", |
| ) |