1# Copyright 2014 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6"""Recipe for the Skia RecreateSKPs Bot.""" 7 8 9DEPS = [ 10 'core', 11 'depot_tools/gclient', 12 'infra', 13 'recipe_engine/context', 14 'recipe_engine/file', 15 'recipe_engine/path', 16 'recipe_engine/properties', 17 'recipe_engine/python', 18 'recipe_engine/raw_io', 19 'recipe_engine/step', 20 'run', 21 'vars', 22] 23 24 25TEST_BUILDERS = { 26 'client.skia.compile': { 27 'skiabot-linux-swarm-000': [ 28 'Housekeeper-Nightly-RecreateSKPs_Canary', 29 'Housekeeper-Weekly-RecreateSKPs', 30 ], 31 }, 32} 33 34 35UPDATE_SKPS_GITCOOKIES_FILE = 'update_skps.git_cookies' 36 37UPDATE_SKPS_GITCOOKIES_GS_PATH = ( 38 'gs://skia-buildbots/artifacts/server/.gitcookies_update-skps') 39 40 41def RunSteps(api): 42 # Check out Chrome. 43 api.core.setup() 44 45 src_dir = api.vars.checkout_root.join('src') 46 out_dir = src_dir.join('out', 'Release') 47 48 with api.context(cwd=src_dir): 49 # Call GN. 50 platform = 'linux64' # This bot only runs on linux; don't bother checking. 51 gn = src_dir.join('buildtools', platform, 'gn') 52 gn_env = {'CPPFLAGS': '-DSK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS=1', 53 'GYP_GENERATORS': 'ninja'} 54 with api.context(env=gn_env): 55 api.run(api.step, 'GN', cmd=[gn, 'gen', out_dir]) 56 57 # Build Chrome. 58 api.run(api.step, 'Build Chrome', cmd=['ninja', '-C', out_dir, 'chrome']) 59 60 # Clean up the output dir. 61 output_dir = api.path['start_dir'].join('skp_output') 62 if api.path.exists(output_dir): 63 api.run.rmtree(output_dir) 64 api.file.ensure_directory('makedirs skp_output', output_dir) 65 66 # Capture the SKPs. 67 asset_dir = api.vars.infrabots_dir.join('assets', 'skp') 68 cmd = ['python', asset_dir.join('create.py'), 69 '--chrome_src_path', src_dir, 70 '--browser_executable', src_dir.join('out', 'Release', 'chrome'), 71 '--target_dir', output_dir] 72 # TODO(rmistry): Uncomment the below after skbug.com/6797 is fixed. 73 # if 'Canary' not in api.properties['buildername']: 74 # cmd.append('--upload_to_partner_bucket') 75 with api.context(cwd=api.vars.skia_dir): 76 api.run(api.step, 'Recreate SKPs', cmd=cmd) 77 78 # Upload the SKPs. 79 if 'Canary' not in api.properties['buildername']: 80 api.infra.update_go_deps() 81 update_skps_gitcookies = api.path['start_dir'].join( 82 UPDATE_SKPS_GITCOOKIES_FILE) 83 cmd = ['python', 84 api.vars.skia_dir.join('infra', 'bots', 'upload_skps.py'), 85 '--target_dir', output_dir, 86 '--gitcookies', str(update_skps_gitcookies)] 87 with api.infra.DownloadGitCookies( 88 UPDATE_SKPS_GITCOOKIES_GS_PATH, update_skps_gitcookies, api): 89 with api.context(cwd=api.vars.skia_dir, env=api.infra.go_env): 90 api.run(api.step, 'Upload SKPs', cmd=cmd) 91 92 93def GenTests(api): 94 builder = 'Housekeeper-Nightly-RecreateSKPs_Canary' 95 yield ( 96 api.test(builder) + 97 api.properties(buildername=builder, 98 repository='https://skia.googlesource.com/skia.git', 99 revision='abc123', 100 path_config='kitchen', 101 swarm_out_dir='[SWARM_OUT_DIR]') + 102 api.path.exists(api.path['start_dir'].join('skp_output')) 103 ) 104 105 builder = 'Housekeeper-Weekly-RecreateSKPs' 106 yield ( 107 api.test(builder) + 108 api.properties(buildername=builder, 109 repository='https://skia.googlesource.com/skia.git', 110 revision='abc123', 111 path_config='kitchen', 112 swarm_out_dir='[SWARM_OUT_DIR]') + 113 api.path.exists(api.path['start_dir'].join('skp_output')) + 114 api.path.exists(api.path['start_dir'].join(UPDATE_SKPS_GITCOOKIES_FILE)) 115 ) 116 117 yield ( 118 api.test('failed_upload') + 119 api.properties(buildername=builder, 120 repository='https://skia.googlesource.com/skia.git', 121 revision='abc123', 122 path_config='kitchen', 123 swarm_out_dir='[SWARM_OUT_DIR]') + 124 api.path.exists(api.path['start_dir'].join('skp_output')) + 125 api.step_data('Upload SKPs', retcode=1) 126 ) 127