• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  'depot_tools/gsutil',
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
36UPDATE_SKPS_GITCOOKIES_FILE = 'update_skps.git_cookies'
37
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
57
58
59def RunSteps(api):
60  # Check out Chrome.
61  api.core.setup()
62
63  src_dir = api.vars.checkout_root.join('src')
64  out_dir = src_dir.join('out', 'Release')
65
66  with api.context(cwd=src_dir):
67    # Call GN.
68    platform = 'linux64'  # This bot only runs on linux; don't bother checking.
69    gn = src_dir.join('buildtools', platform, 'gn')
70    gn_env = {'CPPFLAGS': '-DSK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS=1',
71              'GYP_GENERATORS': 'ninja'}
72    with api.context(env=gn_env):
73      api.run(api.step, 'GN', cmd=[gn, 'gen', out_dir])
74
75    # Build Chrome.
76    api.run(api.step, 'Build Chrome', cmd=['ninja', '-C', out_dir, 'chrome'])
77
78  # Clean up the output dir.
79  output_dir = api.path['start_dir'].join('skp_output')
80  if api.path.exists(output_dir):
81    api.run.rmtree(output_dir)
82  api.file.ensure_directory('makedirs skp_output', output_dir)
83
84  # Capture the SKPs.
85  asset_dir = api.vars.infrabots_dir.join('assets', 'skp')
86  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]
90  # 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')
93  with api.context(cwd=api.vars.skia_dir):
94    api.run(api.step, 'Recreate SKPs', cmd=cmd)
95
96  # Upload the SKPs.
97  if 'Canary' not in api.properties['buildername']:
98    api.infra.update_go_deps()
99    update_skps_gitcookies = api.path['start_dir'].join(
100        UPDATE_SKPS_GITCOOKIES_FILE)
101    cmd = ['python',
102           api.vars.skia_dir.join('infra', 'bots', 'upload_skps.py'),
103           '--target_dir', output_dir,
104           '--gitcookies', str(update_skps_gitcookies)]
105    with DownloadGitCookies(
106        UPDATE_SKPS_GITCOOKIES_GS_PATH, update_skps_gitcookies, api):
107      with api.context(cwd=api.vars.skia_dir, env=api.infra.go_env):
108        api.run(api.step, 'Upload SKPs', cmd=cmd)
109
110
111def GenTests(api):
112  builder = 'Housekeeper-Nightly-RecreateSKPs_Canary'
113  yield (
114      api.test(builder) +
115      api.properties(buildername=builder,
116                     repository='https://skia.googlesource.com/skia.git',
117                     revision='abc123',
118                     path_config='kitchen',
119                     swarm_out_dir='[SWARM_OUT_DIR]') +
120      api.path.exists(api.path['start_dir'].join('skp_output'))
121  )
122
123  builder = 'Housekeeper-Weekly-RecreateSKPs'
124  yield (
125      api.test(builder) +
126      api.properties(buildername=builder,
127                     repository='https://skia.googlesource.com/skia.git',
128                     revision='abc123',
129                     path_config='kitchen',
130                     swarm_out_dir='[SWARM_OUT_DIR]') +
131      api.path.exists(api.path['start_dir'].join('skp_output')) +
132      api.path.exists(api.path['start_dir'].join(UPDATE_SKPS_GITCOOKIES_FILE))
133  )
134
135  yield (
136      api.test('failed_upload') +
137      api.properties(buildername=builder,
138                     repository='https://skia.googlesource.com/skia.git',
139                     revision='abc123',
140                     path_config='kitchen',
141                     swarm_out_dir='[SWARM_OUT_DIR]') +
142      api.path.exists(api.path['start_dir'].join('skp_output')) +
143      api.step_data('Upload SKPs', retcode=1)
144  )
145