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 'checkout', 11 'depot_tools/gclient', 12 'flavor', 13 'infra', 14 'recipe_engine/context', 15 'recipe_engine/file', 16 'recipe_engine/path', 17 'recipe_engine/properties', 18 'recipe_engine/python', 19 'recipe_engine/raw_io', 20 'recipe_engine/step', 21 'run', 22 'vars', 23] 24 25 26TEST_BUILDERS = { 27 'client.skia.compile': { 28 'skiabot-linux-swarm-000': [ 29 'Housekeeper-Nightly-RecreateSKPs_Canary', 30 'Housekeeper-Weekly-RecreateSKPs', 31 ], 32 }, 33} 34 35 36def RunSteps(api): 37 # Check out Chrome. 38 api.vars.setup() 39 40 checkout_root = api.checkout.default_checkout_root 41 extra_gclient_env = { 42 'CPPFLAGS': '-DSK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS=1'} 43 api.checkout.bot_update( 44 checkout_root=checkout_root, 45 checkout_chromium=True, 46 extra_gclient_env=extra_gclient_env) 47 48 api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir) 49 api.flavor.setup() 50 51 src_dir = checkout_root.join('src') 52 skia_dir = checkout_root.join('skia') 53 out_dir = src_dir.join('out', 'Release') 54 55 with api.context(cwd=src_dir): 56 # Call GN. 57 platform = 'linux64' # This bot only runs on linux; don't bother checking. 58 gn = src_dir.join('buildtools', platform, 'gn') 59 gn_env = {'CPPFLAGS': '-DSK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS=1', 60 'GYP_GENERATORS': 'ninja'} 61 with api.context(env=gn_env): 62 api.run(api.step, 'GN', cmd=[gn, 'gen', out_dir]) 63 64 # Build Chrome. 65 api.run(api.step, 'Build Chrome', cmd=['ninja', '-C', out_dir, 'chrome']) 66 67 # Clean up the output dir. 68 output_dir = api.path['start_dir'].join('skp_output') 69 if api.path.exists(output_dir): 70 api.run.rmtree(output_dir) 71 api.file.ensure_directory('makedirs skp_output', output_dir) 72 73 # Capture the SKPs. 74 asset_dir = skia_dir.join('infra', 'bots', 'assets', 'skp') 75 cmd = ['python', asset_dir.join('create.py'), 76 '--chrome_src_path', src_dir, 77 '--browser_executable', src_dir.join('out', 'Release', 'chrome'), 78 '--target_dir', output_dir] 79 if 'Canary' not in api.properties['buildername']: 80 cmd.append('--upload_to_partner_bucket') 81 with api.context(cwd=skia_dir): 82 api.run(api.step, 'Recreate SKPs', cmd=cmd) 83 84 # Upload the SKPs. 85 if 'Canary' not in api.properties['buildername']: 86 cmd = ['python', 87 skia_dir.join('infra', 'bots', 'upload_skps.py'), 88 '--target_dir', output_dir, 89 '--chromium_path', src_dir] 90 with api.context(cwd=skia_dir, env=api.infra.go_env): 91 api.run(api.step, 'Upload SKPs', cmd=cmd) 92 93 94def GenTests(api): 95 builder = 'Housekeeper-Nightly-RecreateSKPs_Canary' 96 yield ( 97 api.test(builder) + 98 api.properties(buildername=builder, 99 repository='https://skia.googlesource.com/skia.git', 100 revision='abc123', 101 path_config='kitchen', 102 swarm_out_dir='[SWARM_OUT_DIR]') + 103 api.path.exists(api.path['start_dir'].join('skp_output')) 104 ) 105 106 builder = 'Housekeeper-Weekly-RecreateSKPs' 107 yield ( 108 api.test(builder) + 109 api.properties(buildername=builder, 110 repository='https://skia.googlesource.com/skia.git', 111 revision='abc123', 112 path_config='kitchen', 113 swarm_out_dir='[SWARM_OUT_DIR]') + 114 api.path.exists(api.path['start_dir'].join('skp_output')) 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