Skip to content

Commit

Permalink
Add CL link in G3 trybot
Browse files Browse the repository at this point in the history
NoTry: true
Bug: skia:9169
Change-Id: I9fca155d0e8b238e5a38348a40fb3351f0aef2fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221276
Reviewed-by: Ravi Mistry <[email protected]>
Reviewed-by: Eric Boren <[email protected]>
Commit-Queue: Ravi Mistry <[email protected]>
  • Loading branch information
rmistry authored and Skia Commit-Bot committed Jun 17, 2019
1 parent ddc0ccd commit 92b81e1
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 9 deletions.
7 changes: 7 additions & 0 deletions infra/bots/g3_compile/trigger_wait_g3_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def trigger_and_wait(options):
if ret.get('status'):
# The task is done, delete the file.
subprocess.check_call(['gsutil', 'rm', gs_file])
if options.output_file:
# Write the task to the output_file.
with open(options.output_file, 'w') as output_file:
json.dump(ret, output_file)

# Now either raise an Exception or return success based on the status.
if ret['status'] == 'exception':
Expand Down Expand Up @@ -194,6 +198,9 @@ def main():
option_parser.add_option(
'', '--patchset', type=int, default=0,
help='The Gerrit change patchset to use.')
option_parser.add_option(
'', '--output_file', type=str,
help='The file to write the task to.')
options, _ = option_parser.parse_args()
sys.exit(trigger_and_wait(options))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
" arg_names, **additional_args)",
" File \"RECIPE_REPO[recipe_engine]/recipe_engine/internal/property_invoker.py\", in _invoke_with_properties",
" return callable_obj(*props, **additional_args)",
" File \"RECIPE_REPO[skia]/infra/bots/recipes/g3_compile.py\", line 18, in RunSteps",
" File \"RECIPE_REPO[skia]/infra/bots/recipes/g3_compile.py\", line 22, in RunSteps",
" raise Exception('%s can only be run as a trybot.' % buildername)",
"Exception: Build-Debian9-Clang-TAP-Presubmit-G3_Framework can only be run as a trybot."
]
Expand Down
17 changes: 16 additions & 1 deletion infra/bots/recipes/g3_compile.expected/g3_compile_trybot.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@
"--issue",
"1234",
"--patchset",
"1"
"1",
"--output_file",
"[CLEANUP]/g3_try_tmp_1/output_file"
],
"name": "Trigger and wait for g3 compile task"
},
{
"cmd": [
"python",
"-u",
"RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
"--json-output",
"/path/to/tmp/json",
"rmtree",
"[CLEANUP]/g3_try_tmp_1"
],
"infra_step": true,
"name": "rmtree [CLEANUP]/g3_try_tmp_1"
},
{
"name": "$result"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,45 @@
"--issue",
"1234",
"--patchset",
"1"
"1",
"--output_file",
"[CLEANUP]/g3_try_tmp_1/output_file"
],
"name": "Trigger and wait for g3 compile task",
"~followup_annotations": [
"@@@STEP_FAILURE@@@"
]
},
{
"cmd": [
"python",
"-u",
"RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
"--json-output",
"/path/to/tmp/json",
"copy",
"[CLEANUP]/g3_try_tmp_1/output_file",
"/path/to/tmp/"
],
"infra_step": true,
"name": "Read task json",
"~followup_annotations": [
"@@@STEP_LINK@CL link@http://cl/12345@@@"
]
},
{
"cmd": [
"python",
"-u",
"RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
"--json-output",
"/path/to/tmp/json",
"rmtree",
"[CLEANUP]/g3_try_tmp_1"
],
"infra_step": true,
"name": "rmtree [CLEANUP]/g3_try_tmp_1"
},
{
"failure": {
"failure": {},
Expand Down
28 changes: 22 additions & 6 deletions infra/bots/recipes/g3_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@


DEPS = [
'recipe_engine/file',
'recipe_engine/json',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/raw_io',
'recipe_engine/step',
'recipe_engine/tempfile',
]


Expand All @@ -21,12 +25,24 @@ def RunSteps(api):
trigger_wait_g3_script = infrabots_dir.join('g3_compile',
'trigger_wait_g3_task.py')

# Trigger a compile task and wait for it to complete.
cmd = ['python', trigger_wait_g3_script,
'--issue', issue,
'--patchset', patchset,
]
api.step('Trigger and wait for g3 compile task', cmd=cmd)
with api.tempfile.temp_dir('g3_try') as output_dir:
output_file = output_dir.join('output_file')
# Trigger a compile task and wait for it to complete.
cmd = ['python', trigger_wait_g3_script,
'--issue', issue,
'--patchset', patchset,
'--output_file', output_file,
]
try:
api.step('Trigger and wait for g3 compile task', cmd=cmd)
except api.step.StepFailure as e:
# Add CL link if it exists in the output_file.
task_json = api.file.read_json(
'Read task json', output_file, test_data={'cl': 12345})
if task_json.get('cl'):
api.step.active_result.presentation.links['CL link'] = (
'http://cl/%d' % task_json['cl'])
raise e


def GenTests(api):
Expand Down

0 comments on commit 92b81e1

Please sign in to comment.