blob: 60b44b69a2c30ef381b0a9d688f0fbcadea5b3b7 [file] [log] [blame]
borenet1ed2ae42016-07-26 11:52:17 -07001# 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 = [
Eric Boren3e2ffd72017-06-16 13:10:22 -040010 'core',
borenet1ed2ae42016-07-26 11:52:17 -070011 'depot_tools/gclient',
Ravi Mistry9d3e1622017-07-13 14:27:45 -040012 'depot_tools/gsutil',
Eric Boren3e2ffd72017-06-16 13:10:22 -040013 'infra',
Robert Iannucci297a7ef2017-05-12 19:09:38 -070014 'recipe_engine/context',
Eric Boren3e2ffd72017-06-16 13:10:22 -040015 'recipe_engine/file',
borenet1ed2ae42016-07-26 11:52:17 -070016 'recipe_engine/path',
17 'recipe_engine/properties',
18 'recipe_engine/python',
19 'recipe_engine/raw_io',
20 'recipe_engine/step',
Eric Boren81340c62017-04-17 10:29:04 -040021 'run',
Eric Boren7e97dc02017-02-02 09:02:37 -050022 'vars',
borenet1ed2ae42016-07-26 11:52:17 -070023]
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
Ravi Mistrybadc1372016-11-23 08:38:18 -050036UPDATE_SKPS_GITCOOKIES_FILE = 'update_skps.git_cookies'
Ravi Mistry9d3e1622017-07-13 14:27:45 -040037
38UPDATE_SKPS_GITCOOKIES_GS_PATH = (
39 'gs://skia-buildbots/artifacts/server/.gitcookies_update-skps')
40
41
42class DownloadGitCookies(object):
43 """Class to download gitcookies from GS."""
44 def __init__(self, gs_path, local_path, api):
45 self._gs_path = gs_path
46 self._local_path = local_path
47 self._api = api
48
49 def __enter__(self):
50 gsutil_args = ['cp', self._gs_path, self._local_path]
51 self._api.gsutil(gsutil_args, use_retry_wrapper=False)
52
53 def __exit__(self, exc_type, _value, _traceback):
54 if self._api.path.exists(self._local_path):
55 self._api.file.remove('remove %s' % self._local_path, self._local_path)
56
borenet1ed2ae42016-07-26 11:52:17 -070057
58
borenet1ed2ae42016-07-26 11:52:17 -070059def RunSteps(api):
60 # Check out Chrome.
borenet1436a092016-08-03 08:23:10 -070061 api.core.setup()
borenet1ed2ae42016-07-26 11:52:17 -070062
borenet1436a092016-08-03 08:23:10 -070063 src_dir = api.vars.checkout_root.join('src')
borenetb6aafe62016-08-02 07:02:52 -070064 out_dir = src_dir.join('out', 'Release')
borenet1ed2ae42016-07-26 11:52:17 -070065
Robert Iannucci297a7ef2017-05-12 19:09:38 -070066 with api.context(cwd=src_dir):
Eric Borene6b26ad2017-02-21 07:22:20 -050067 # Call GN.
68 platform = 'linux64' # This bot only runs on linux; don't bother checking.
69 gn = src_dir.join('buildtools', platform, 'gn')
Eric Boren53262d02017-03-20 15:40:12 -040070 gn_env = {'CPPFLAGS': '-DSK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS=1',
71 'GYP_GENERATORS': 'ninja'}
Robert Iannucci297a7ef2017-05-12 19:09:38 -070072 with api.context(env=gn_env):
Eric Boren81340c62017-04-17 10:29:04 -040073 api.run(api.step, 'GN', cmd=[gn, 'gen', out_dir])
Eric Borene6b26ad2017-02-21 07:22:20 -050074
75 # Build Chrome.
Eric Boren81340c62017-04-17 10:29:04 -040076 api.run(api.step, 'Build Chrome', cmd=['ninja', '-C', out_dir, 'chrome'])
borenet1ed2ae42016-07-26 11:52:17 -070077
borenet1ed2ae42016-07-26 11:52:17 -070078 # Clean up the output dir.
Ravi Mistry9bcca6a2016-11-21 16:06:19 -050079 output_dir = api.path['start_dir'].join('skp_output')
borenet1ed2ae42016-07-26 11:52:17 -070080 if api.path.exists(output_dir):
Eric Boren3e2ffd72017-06-16 13:10:22 -040081 api.run.rmtree(output_dir)
Robert Iannucci8cd50412017-07-07 14:36:58 -070082 api.file.ensure_directory('makedirs skp_output', output_dir)
borenet1ed2ae42016-07-26 11:52:17 -070083
84 # Capture the SKPs.
borenet1436a092016-08-03 08:23:10 -070085 asset_dir = api.vars.infrabots_dir.join('assets', 'skp')
borenet1ed2ae42016-07-26 11:52:17 -070086 cmd = ['python', asset_dir.join('create.py'),
87 '--chrome_src_path', src_dir,
88 '--browser_executable', src_dir.join('out', 'Release', 'chrome'),
89 '--target_dir', output_dir]
Ravi Mistry50cd9e92017-07-13 20:46:21 +000090 # TODO(rmistry): Uncomment the below after skbug.com/6797 is fixed.
91 # if 'Canary' not in api.properties['buildername']:
92 # cmd.append('--upload_to_partner_bucket')
Robert Iannucci297a7ef2017-05-12 19:09:38 -070093 with api.context(cwd=api.vars.skia_dir):
Eric Boren81340c62017-04-17 10:29:04 -040094 api.run(api.step, 'Recreate SKPs', cmd=cmd)
borenet1ed2ae42016-07-26 11:52:17 -070095
96 # Upload the SKPs.
97 if 'Canary' not in api.properties['buildername']:
borenet09732a62016-10-24 06:36:30 -070098 api.infra.update_go_deps()
Ravi Mistry9d3e1622017-07-13 14:27:45 -040099 update_skps_gitcookies = api.path['start_dir'].join(
100 UPDATE_SKPS_GITCOOKIES_FILE)
borenet1ed2ae42016-07-26 11:52:17 -0700101 cmd = ['python',
borenet1436a092016-08-03 08:23:10 -0700102 api.vars.skia_dir.join('infra', 'bots', 'upload_skps.py'),
Ravi Mistrybadc1372016-11-23 08:38:18 -0500103 '--target_dir', output_dir,
104 '--gitcookies', str(update_skps_gitcookies)]
Ravi Mistry9d3e1622017-07-13 14:27:45 -0400105 with DownloadGitCookies(
106 UPDATE_SKPS_GITCOOKIES_GS_PATH, update_skps_gitcookies, api):
Robert Iannucci297a7ef2017-05-12 19:09:38 -0700107 with api.context(cwd=api.vars.skia_dir, env=api.infra.go_env):
Eric Boren81340c62017-04-17 10:29:04 -0400108 api.run(api.step, 'Upload SKPs', cmd=cmd)
borenet1ed2ae42016-07-26 11:52:17 -0700109
110
111def GenTests(api):
borenetb2cf2662016-10-24 08:40:26 -0700112 builder = 'Housekeeper-Nightly-RecreateSKPs_Canary'
113 yield (
114 api.test(builder) +
115 api.properties(buildername=builder,
Eric Borenad29aee2017-01-17 14:35:06 -0500116 repository='https://skia.googlesource.com/skia.git',
borenetb2cf2662016-10-24 08:40:26 -0700117 revision='abc123',
borenetb2cf2662016-10-24 08:40:26 -0700118 path_config='kitchen',
119 swarm_out_dir='[SWARM_OUT_DIR]') +
Ravi Mistry9bcca6a2016-11-21 16:06:19 -0500120 api.path.exists(api.path['start_dir'].join('skp_output'))
borenetb2cf2662016-10-24 08:40:26 -0700121 )
122
123 builder = 'Housekeeper-Weekly-RecreateSKPs'
124 yield (
125 api.test(builder) +
126 api.properties(buildername=builder,
Eric Borenad29aee2017-01-17 14:35:06 -0500127 repository='https://skia.googlesource.com/skia.git',
borenetb2cf2662016-10-24 08:40:26 -0700128 revision='abc123',
borenetb2cf2662016-10-24 08:40:26 -0700129 path_config='kitchen',
130 swarm_out_dir='[SWARM_OUT_DIR]') +
Ravi Mistry9d3e1622017-07-13 14:27:45 -0400131 api.path.exists(api.path['start_dir'].join('skp_output')) +
132 api.path.exists(api.path['start_dir'].join(UPDATE_SKPS_GITCOOKIES_FILE))
borenetb2cf2662016-10-24 08:40:26 -0700133 )
134
135 yield (
136 api.test('failed_upload') +
137 api.properties(buildername=builder,
Eric Borenad29aee2017-01-17 14:35:06 -0500138 repository='https://skia.googlesource.com/skia.git',
borenetb2cf2662016-10-24 08:40:26 -0700139 revision='abc123',
borenetb2cf2662016-10-24 08:40:26 -0700140 path_config='kitchen',
141 swarm_out_dir='[SWARM_OUT_DIR]') +
Ravi Mistry9bcca6a2016-11-21 16:06:19 -0500142 api.path.exists(api.path['start_dir'].join('skp_output')) +
borenetb2cf2662016-10-24 08:40:26 -0700143 api.step_data('Upload SKPs', retcode=1)
144 )