diff options
author | borenet <borenet@chromium.org> | 2016-07-28 10:50:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-28 10:50:54 -0700 |
commit | f49d9d77bbaf9b075426046173c976a15bde8ee5 (patch) | |
tree | 1b3a8d9929fefc383e751cc8d2a1aa1208e1378b /infra | |
parent | a0605bf9d13f5758a6fa2fa366c4dc5341c2cf61 (diff) |
Add swarmbucket_wrapper recipe
BUG=skia:5581
NOTRY=true
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2185203003
Review-Url: https://codereview.chromium.org/2185203003
Diffstat (limited to 'infra')
-rw-r--r-- | infra/bots/recipes/swarmbucket_wrapper.expected/trigger_recipe.json | 118 | ||||
-rw-r--r-- | infra/bots/recipes/swarmbucket_wrapper.py | 121 |
2 files changed, 239 insertions, 0 deletions
diff --git a/infra/bots/recipes/swarmbucket_wrapper.expected/trigger_recipe.json b/infra/bots/recipes/swarmbucket_wrapper.expected/trigger_recipe.json new file mode 100644 index 0000000000..55268665b9 --- /dev/null +++ b/infra/bots/recipes/swarmbucket_wrapper.expected/trigger_recipe.json @@ -0,0 +1,118 @@ +[ + { + "cmd": [ + "python", + "-u", + "\nimport json\nimport sys\n\nwith open(sys.argv[1]) as f:\n content = json.load(f)\n\nprint json.dumps(content, indent=2)\n", + "{\"buildername\": \"Some-Builder\", \"buildnumber\": 5, \"mastername\": \"client.skia.fyi\", \"path_config\": \"swarmbucket\", \"recipe\": \"swarmbucket_wrapper\", \"slavename\": \"some-slave\"}" + ], + "name": "print properties", + "~followup_annotations": [ + "@@@STEP_LOG_LINE@python.inline@@@@", + "@@@STEP_LOG_LINE@python.inline@import json@@@", + "@@@STEP_LOG_LINE@python.inline@import sys@@@", + "@@@STEP_LOG_LINE@python.inline@@@@", + "@@@STEP_LOG_LINE@python.inline@with open(sys.argv[1]) as f:@@@", + "@@@STEP_LOG_LINE@python.inline@ content = json.load(f)@@@", + "@@@STEP_LOG_LINE@python.inline@@@@", + "@@@STEP_LOG_LINE@python.inline@print json.dumps(content, indent=2)@@@", + "@@@STEP_LOG_END@python.inline@@@" + ] + }, + { + "cmd": [ + "python", + "-u", + "\nimport sys, os\npath = sys.argv[1]\nmode = int(sys.argv[2])\nif not os.path.isdir(path):\n if os.path.exists(path):\n print \"%s exists but is not a dir\" % path\n sys.exit(1)\n os.makedirs(path, mode)\n", + "[B]/work", + "511" + ], + "name": "makedirs workdir", + "~followup_annotations": [ + "@@@STEP_LOG_LINE@python.inline@@@@", + "@@@STEP_LOG_LINE@python.inline@import sys, os@@@", + "@@@STEP_LOG_LINE@python.inline@path = sys.argv[1]@@@", + "@@@STEP_LOG_LINE@python.inline@mode = int(sys.argv[2])@@@", + "@@@STEP_LOG_LINE@python.inline@if not os.path.isdir(path):@@@", + "@@@STEP_LOG_LINE@python.inline@ if os.path.exists(path):@@@", + "@@@STEP_LOG_LINE@python.inline@ print \"%s exists but is not a dir\" % path@@@", + "@@@STEP_LOG_LINE@python.inline@ sys.exit(1)@@@", + "@@@STEP_LOG_LINE@python.inline@ os.makedirs(path, mode)@@@", + "@@@STEP_LOG_END@python.inline@@@" + ] + }, + { + "cmd": [ + "python", + "-u", + "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", + "--master", + "client.skia.fyi", + "--builder", + "Some-Builder", + "--slave", + "some-slave", + "--spec", + "cache_dir = '[B]/cache'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'skia', 'url': 'https://skia.googlesource.com/skia.git'}]", + "--root", + "skia", + "--revision_mapping_file", + "{\"skia\": \"got_revision\"}", + "--git-cache-dir", + "[B]/cache", + "--output_json", + "/path/to/tmp/json", + "--revision", + "skia@origin/master" + ], + "cwd": "[B]/work", + "env": { + "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]" + }, + "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@ \"skia\": \"origin/master\"@@@", + "@@@STEP_LOG_LINE@json.output@ }, @@@", + "@@@STEP_LOG_LINE@json.output@ \"patch_failure\": false, @@@", + "@@@STEP_LOG_LINE@json.output@ \"patch_root\": \"skia\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"properties\": {@@@", + "@@@STEP_LOG_LINE@json.output@ \"got_revision\": \"9046e2e693bb92a76e972b694580e5d17ad10748\", @@@", + "@@@STEP_LOG_LINE@json.output@ \"got_revision_cp\": \"refs/heads/master@{#164710}\"@@@", + "@@@STEP_LOG_LINE@json.output@ }, @@@", + "@@@STEP_LOG_LINE@json.output@ \"root\": \"skia\", @@@", + "@@@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@\"9046e2e693bb92a76e972b694580e5d17ad10748\"@@@", + "@@@SET_BUILD_PROPERTY@got_revision_cp@\"refs/heads/master@{#164710}\"@@@" + ] + }, + { + "allow_subannotations": true, + "cmd": [ + "python", + "[B]/work/skia/infra/bots/recipes.py", + "run", + "--workdir", + "[B]/work", + "swarm_trigger", + "path_config=kitchen", + "buildername=Some-Builder", + "recipe=swarmbucket_wrapper", + "mastername=client.skia.fyi", + "buildnumber=5", + "slavename=some-slave", + "path_config=swarmbucket" + ], + "name": "run recipe" + }, + { + "name": "$result", + "recipe_result": null, + "status_code": 0 + } +]
\ No newline at end of file diff --git a/infra/bots/recipes/swarmbucket_wrapper.py b/infra/bots/recipes/swarmbucket_wrapper.py new file mode 100644 index 0000000000..0e4b78b661 --- /dev/null +++ b/infra/bots/recipes/swarmbucket_wrapper.py @@ -0,0 +1,121 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +# Recipe wrapper used in SwarmBucket. + + +DEPS = [ + 'build/file', + 'depot_tools/bot_update', + 'depot_tools/gclient', + 'recipe_engine/json', + 'recipe_engine/path', + 'recipe_engine/properties', + 'recipe_engine/python', + 'recipe_engine/step', +] + + +def checkout_steps(api): + """Run the steps to obtain a checkout of Skia.""" + # Find the workdir and cache dir. + workdir = api.path['b'].join('work') + if not api.path.exists(workdir): + api.file.makedirs('workdir', workdir, infra_step=True) + cache_dir = api.path['b'].join('cache') + + # Set up gclient config. + api.gclient.use_mirror = True + gclient_cfg = api.gclient.make_config(GIT_MODE=True, CACHE_DIR=cache_dir) + soln = gclient_cfg.solutions.add() + soln.name = 'skia' + soln.url = 'https://skia.googlesource.com/skia.git' + soln.revision = api.properties.get('revision', 'origin/master') + api.gclient.c = gclient_cfg + api.gclient.c.got_revision_mapping['skia'] = 'got_revision' + + # Set up options for bot_update based on properties. In general, these will + # all take the default value. + patch = api.properties.get('patch', True) + clobber = True if api.properties.get('clobber') else False + force = True if api.properties.get('force') else False + no_shallow = True if api.properties.get('no_shallow') else False + output_manifest = api.properties.get('output_manifest', False) + with_branch_heads = api.properties.get('with_branch_heads', False) + refs = api.properties.get('refs', []) + oauth2 = api.properties.get('oauth2', False) + root_solution_revision = api.properties.get('root_solution_revision') + suffix = api.properties.get('suffix') + gerrit_no_reset = True if api.properties.get('gerrit_no_reset') else False + + # Run bot_update to sync the code and apply a patch if necessary. + api.bot_update.ensure_checkout(force=force, + no_shallow=no_shallow, + patch=patch, + with_branch_heads=with_branch_heads, + output_manifest=output_manifest, + refs=refs, patch_oauth2=oauth2, + clobber=clobber, + root_solution_revision=root_solution_revision, + suffix=suffix, + gerrit_no_reset=gerrit_no_reset, + cwd=workdir) + + # Ensure that we ended up with the desired revision. + got_revision = api.step.active_result.presentation.properties['got_revision'] + if soln.revision != 'origin/master': # pragma: no cover + assert got_revision == soln.revision + return got_revision + + +def forward_to_recipe_in_repo(api): + workdir = api.path['b'].join('work') + recipes_py = workdir.join('skia', 'infra', 'bots', 'recipes.py') + cmd = ['python', recipes_py, 'run', + '--workdir', workdir, + 'swarm_trigger', 'path_config=kitchen'] + for k, v in api.properties.iteritems(): + cmd.append('%s=%s' % (k, v)) + api.step('run recipe', cmd=cmd, allow_subannotations=True) + + +def print_properties(api): + """Dump out all properties for debugging purposes.""" + props = {} + for k, v in api.properties.iteritems(): + props[k] = v + api.python.inline( + 'print properties', + ''' +import json +import sys + +with open(sys.argv[1]) as f: + content = json.load(f) + +print json.dumps(content, indent=2) +''', + args=[api.json.input(props)]) + + +def RunSteps(api): + api.path.c.base_paths['b'] = ('/', 'b') + + # TODO(borenet): Remove this once SwarmBucket is working. + print_properties(api) + + checkout_steps(api) + forward_to_recipe_in_repo(api) + + +def GenTests(api): + yield ( + api.test('trigger_recipe') + + api.properties(buildername='Some-Builder', + buildnumber=5, + mastername='client.skia.fyi', + slavename='some-slave', + path_config='swarmbucket') + ) |