From 1f43c67a122d09c2604ed62226a3d0c369760574 Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Wed, 4 May 2022 23:07:55 +0000 Subject: [PATCH] infra: Also support gitlies input to support use as post-submit BUG=1300370 TEST=./recipes.py test run Change-Id: I5db70526f728aebd9dd253da0d85056a340c7c22 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627054 Tested-by: kokoro Reviewed-by: Daniel Verkamp Reviewed-by: Yuanjun Huang --- .../recipes/verify_cl.expected/basic ci.json | 91 +++++++++++++++++++ .../{basic.json => basic try.json} | 2 +- infra/recipes/verify_cl.py | 39 ++++---- 3 files changed, 114 insertions(+), 18 deletions(-) create mode 100644 infra/recipes/verify_cl.expected/basic ci.json rename infra/recipes/verify_cl.expected/{basic.json => basic try.json} (98%) diff --git a/infra/recipes/verify_cl.expected/basic ci.json b/infra/recipes/verify_cl.expected/basic ci.json new file mode 100644 index 0000000000..3715eaf07b --- /dev/null +++ b/infra/recipes/verify_cl.expected/basic ci.json @@ -0,0 +1,91 @@ +[ + { + "cmd": [ + "vpython3", + "-u", + "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", + "--spec-path", + "cache_dir = '[CACHE]/git'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'http://chromium.googlesource.com/crosvm/crosvm'}]", + "--revision_mapping_file", + "{\"got_revision\": \"src\"}", + "--git-cache-dir", + "[CACHE]/git", + "--cleanup-dir", + "[CLEANUP]/bot_update", + "--output_json", + "/path/to/tmp/json", + "--revision", + "src@2d72510e447ab60a9728aeea2362d8be2cbd7789", + "--refs", + "refs/heads/main" + ], + "cwd": "[CACHE]/builder", + "env": { + "DEPOT_TOOLS_REPORT_BUILD": "crosvm/ci/builder/8945511751514863184", + "GIT_HTTP_LOW_SPEED_LIMIT": "102400", + "GIT_HTTP_LOW_SPEED_TIME": "1800" + }, + "env_suffixes": { + "DEPOT_TOOLS_UPDATE": [ + "0" + ], + "PATH": [ + "RECIPE_REPO[depot_tools]" + ] + }, + "infra_step": true, + "luci_context": { + "realm": { + "name": "crosvm:ci" + }, + "resultdb": { + "current_invocation": { + "name": "invocations/build:8945511751514863184", + "update_token": "token" + }, + "hostname": "rdbhost" + } + }, + "name": "bot_update", + "~followup_annotations": [ + "@@@STEP_TEXT@Some step text@@@", + "@@@STEP_LOG_LINE@json.output@{@@@", + "@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@", + "@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"src\": \"2d72510e447ab60a9728aeea2362d8be2cbd7789\"@@@", + "@@@STEP_LOG_LINE@json.output@ }, @@@", + "@@@STEP_LOG_LINE@json.output@ \"manifest\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"src\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"repository\": \"https://fake.org/src.git\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"revision\": \"2d72510e447ab60a9728aeea2362d8be2cbd7789\"@@@", + "@@@STEP_LOG_LINE@json.output@ }@@@", + "@@@STEP_LOG_LINE@json.output@ }, @@@", + "@@@STEP_LOG_LINE@json.output@ \"patch_failure\": false, @@@", + "@@@STEP_LOG_LINE@json.output@ \"patch_root\": \"src\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"properties\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"got_revision\": \"2d72510e447ab60a9728aeea2362d8be2cbd7789\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"got_revision_cp\": \"refs/heads/main@{#170242}\"@@@", + "@@@STEP_LOG_LINE@json.output@ }, @@@", + "@@@STEP_LOG_LINE@json.output@ \"root\": \"src\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"source_manifest\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"directories\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"src\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"git_checkout\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"repo_url\": \"https://fake.org/src.git\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"revision\": \"2d72510e447ab60a9728aeea2362d8be2cbd7789\"@@@", + "@@@STEP_LOG_LINE@json.output@ }@@@", + "@@@STEP_LOG_LINE@json.output@ }@@@", + "@@@STEP_LOG_LINE@json.output@ }, @@@", + "@@@STEP_LOG_LINE@json.output@ \"version\": 0@@@", + "@@@STEP_LOG_LINE@json.output@ }, @@@", + "@@@STEP_LOG_LINE@json.output@ \"step_text\": \"Some step text\"@@@", + "@@@STEP_LOG_LINE@json.output@}@@@", + "@@@STEP_LOG_END@json.output@@@", + "@@@SET_BUILD_PROPERTY@got_revision@\"2d72510e447ab60a9728aeea2362d8be2cbd7789\"@@@", + "@@@SET_BUILD_PROPERTY@got_revision_cp@\"refs/heads/main@{#170242}\"@@@" + ] + }, + { + "name": "$result" + } +] \ No newline at end of file diff --git a/infra/recipes/verify_cl.expected/basic.json b/infra/recipes/verify_cl.expected/basic try.json similarity index 98% rename from infra/recipes/verify_cl.expected/basic.json rename to infra/recipes/verify_cl.expected/basic try.json index 5dfb69f904..01524c582e 100644 --- a/infra/recipes/verify_cl.expected/basic.json +++ b/infra/recipes/verify_cl.expected/basic try.json @@ -61,7 +61,7 @@ "-u", "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec-path", - "cache_dir = '[CACHE]/git'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/crosvm/crosvm'}]", + "cache_dir = '[CACHE]/git'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'http://chromium.googlesource.com/crosvm/crosvm'}]", "--patch_root", "src", "--revision_mapping_file", diff --git a/infra/recipes/verify_cl.py b/infra/recipes/verify_cl.py index cb899f5f4e..ee10c2c612 100644 --- a/infra/recipes/verify_cl.py +++ b/infra/recipes/verify_cl.py @@ -11,25 +11,20 @@ DEPS = [ def RunSteps(api): # TODO(denniskempin): Consider using git directly for simpler config - cl = api.buildbucket.build.input.gerrit_changes[0] - - gs_suffix = "-review.googlesource.com" - host = cl.host - if host.endswith(gs_suffix): - host = "%s.googlesource.com" % host[: -len(gs_suffix)] + gitilies = api.buildbucket.build.input.gitiles_commit + if gitilies.host: + url = "http://%s/%s" % (gitilies.host, gitilies.project) + else: + cl = api.buildbucket.build.input.gerrit_changes[0] + gs_suffix = "-review.googlesource.com" + host = cl.host + if host.endswith(gs_suffix): + host = "%s.googlesource.com" % host[: -len(gs_suffix)] + url = "http://%s/%s" % (host, cl.project) gclient_config = api.gclient.make_config() s = gclient_config.solutions.add() - s.url = "https://%s/%s" % (host, cl.project) - - # name is the subfolder under api.path['cache'].join('builder') the - # repo will be checked out at. For simplicity, I've picked `src`. - # - # Note that gclient (and by extension, bot_update), allow for complicated - # multi-repo layouts and dependency inclusion (via "DEPS" files). There are - # other repo management tools and techniques available, but this one is what - # chrome currently uses and is tuned to have reasonable performance by default - # via caches. + s.url = url s.name = "src" gclient_config.got_revision_mapping[s.name] = "got_revision" @@ -46,7 +41,7 @@ def RunSteps(api): def GenTests(api): yield api.test( - "basic", + "basic try", # These are just to make the JSON expectation file data look closer to # reality. Project and git_repo will be filled in "for real" by the LUCI # Change Verifier service when it creates your build. @@ -55,3 +50,13 @@ def GenTests(api): git_repo="https://chromium.googlesource.com/crosvm/crosvm", ), ) + yield api.test( + "basic ci", + # These are just to make the JSON expectation file data look closer to + # reality. Project and git_repo will be filled in "for real" by the LUCI + # Change Verifier service when it creates your build. + api.buildbucket.ci_build( + project="crosvm", + git_repo="https://chromium.googlesource.com/crosvm/crosvm", + ), + )