2016-07-26 18:52:17 +00:00
|
|
|
# Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
"""Recipe for the Skia RecreateSKPs Bot."""
|
|
|
|
|
|
|
|
|
|
|
|
DEPS = [
|
|
|
|
'build/file',
|
|
|
|
'depot_tools/gclient',
|
|
|
|
'recipe_engine/path',
|
|
|
|
'recipe_engine/properties',
|
|
|
|
'recipe_engine/python',
|
|
|
|
'recipe_engine/raw_io',
|
|
|
|
'recipe_engine/step',
|
2017-02-02 14:02:37 +00:00
|
|
|
'core',
|
|
|
|
'infra',
|
|
|
|
'vars',
|
2016-07-26 18:52:17 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
TEST_BUILDERS = {
|
|
|
|
'client.skia.compile': {
|
|
|
|
'skiabot-linux-swarm-000': [
|
|
|
|
'Housekeeper-Nightly-RecreateSKPs_Canary',
|
|
|
|
'Housekeeper-Weekly-RecreateSKPs',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-23 13:38:18 +00:00
|
|
|
UPDATE_SKPS_GITCOOKIES_FILE = 'update_skps.git_cookies'
|
|
|
|
UPDATE_SKPS_KEY = 'update_skps_git_cookies'
|
2016-07-26 18:52:17 +00:00
|
|
|
|
|
|
|
|
2016-11-23 13:38:18 +00:00
|
|
|
class gitcookies_auth(object):
|
|
|
|
"""Download update-skps@skia.org's .gitcookies."""
|
2016-07-26 18:52:17 +00:00
|
|
|
def __init__(self, api, metadata_key):
|
|
|
|
self.m = api
|
|
|
|
self._key = metadata_key
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
return self.m.python.inline(
|
2016-11-23 13:38:18 +00:00
|
|
|
'download update-skps.gitcookies',
|
2016-07-26 18:52:17 +00:00
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import urllib2
|
|
|
|
|
|
|
|
TOKEN_FILE = '%s'
|
|
|
|
TOKEN_URL = 'http://metadata/computeMetadata/v1/project/attributes/%s'
|
|
|
|
|
|
|
|
req = urllib2.Request(TOKEN_URL, headers={'Metadata-Flavor': 'Google'})
|
|
|
|
contents = urllib2.urlopen(req).read()
|
|
|
|
|
|
|
|
home = os.path.expanduser('~')
|
|
|
|
token_file = os.path.join(home, TOKEN_FILE)
|
|
|
|
|
|
|
|
with open(token_file, 'w') as f:
|
|
|
|
f.write(contents)
|
2016-11-23 13:38:18 +00:00
|
|
|
""" % (UPDATE_SKPS_GITCOOKIES_FILE,
|
2016-07-26 18:52:17 +00:00
|
|
|
self._key),
|
|
|
|
)
|
|
|
|
|
|
|
|
def __exit__(self, t, v, tb):
|
2016-10-24 15:40:26 +00:00
|
|
|
self.m.python.inline(
|
2016-11-23 13:38:18 +00:00
|
|
|
'cleanup update-skps.gitcookies',
|
2016-07-26 18:52:17 +00:00
|
|
|
"""
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
TOKEN_FILE = '%s'
|
|
|
|
|
|
|
|
|
|
|
|
home = os.path.expanduser('~')
|
|
|
|
token_file = os.path.join(home, TOKEN_FILE)
|
|
|
|
if os.path.isfile(token_file):
|
|
|
|
os.remove(token_file)
|
2016-11-23 13:38:18 +00:00
|
|
|
""" % (UPDATE_SKPS_GITCOOKIES_FILE),
|
2016-07-26 18:52:17 +00:00
|
|
|
)
|
2016-10-24 15:40:26 +00:00
|
|
|
return v is None
|
2016-07-26 18:52:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
def RunSteps(api):
|
|
|
|
# Check out Chrome.
|
2016-08-03 15:23:10 +00:00
|
|
|
api.core.setup()
|
2016-07-26 18:52:17 +00:00
|
|
|
|
2016-08-03 15:23:10 +00:00
|
|
|
src_dir = api.vars.checkout_root.join('src')
|
2016-08-02 14:02:52 +00:00
|
|
|
out_dir = src_dir.join('out', 'Release')
|
2016-07-26 18:52:17 +00:00
|
|
|
|
2016-08-02 14:02:52 +00:00
|
|
|
# Call GN.
|
|
|
|
platform = 'linux64' # This bot only runs on linux; don't bother checking.
|
|
|
|
gn = src_dir.join('buildtools', platform, 'gn')
|
|
|
|
api.step('GN',
|
|
|
|
[gn, 'gen', out_dir],
|
2016-07-26 18:52:17 +00:00
|
|
|
env={'CPPFLAGS': '-DSK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS=1',
|
|
|
|
'GYP_GENERATORS': 'ninja'},
|
|
|
|
cwd=src_dir)
|
|
|
|
# Build Chrome.
|
|
|
|
api.step('Build Chrome',
|
2016-08-02 14:02:52 +00:00
|
|
|
['ninja', '-C', out_dir, 'chrome'],
|
2016-07-26 18:52:17 +00:00
|
|
|
cwd=src_dir)
|
|
|
|
|
|
|
|
# Clean up the output dir.
|
2016-11-21 21:06:19 +00:00
|
|
|
output_dir = api.path['start_dir'].join('skp_output')
|
2016-07-26 18:52:17 +00:00
|
|
|
if api.path.exists(output_dir):
|
|
|
|
api.file.rmtree('skp_output', output_dir)
|
|
|
|
api.file.makedirs('skp_output', output_dir)
|
|
|
|
|
|
|
|
# Capture the SKPs.
|
|
|
|
path_var= api.path.pathsep.join([str(api.path['depot_tools']), '%(PATH)s'])
|
|
|
|
env = {
|
|
|
|
'CHROME_HEADLESS': '1',
|
|
|
|
'PATH': path_var,
|
|
|
|
}
|
2016-08-03 15:23:10 +00:00
|
|
|
asset_dir = api.vars.infrabots_dir.join('assets', 'skp')
|
2016-07-26 18:52:17 +00:00
|
|
|
cmd = ['python', asset_dir.join('create.py'),
|
|
|
|
'--chrome_src_path', src_dir,
|
|
|
|
'--browser_executable', src_dir.join('out', 'Release', 'chrome'),
|
|
|
|
'--target_dir', output_dir]
|
|
|
|
if 'Canary' not in api.properties['buildername']:
|
|
|
|
cmd.append('--upload_to_partner_bucket')
|
|
|
|
api.step('Recreate SKPs',
|
|
|
|
cmd=cmd,
|
2016-08-03 15:23:10 +00:00
|
|
|
cwd=api.vars.skia_dir,
|
2016-10-10 17:37:30 +00:00
|
|
|
env=env)
|
2016-07-26 18:52:17 +00:00
|
|
|
|
|
|
|
# Upload the SKPs.
|
|
|
|
if 'Canary' not in api.properties['buildername']:
|
2016-10-24 13:36:30 +00:00
|
|
|
api.infra.update_go_deps()
|
2016-11-23 13:38:18 +00:00
|
|
|
update_skps_gitcookies = api.path.join(api.path.expanduser('~'),
|
|
|
|
UPDATE_SKPS_GITCOOKIES_FILE)
|
2016-07-26 18:52:17 +00:00
|
|
|
cmd = ['python',
|
2016-08-03 15:23:10 +00:00
|
|
|
api.vars.skia_dir.join('infra', 'bots', 'upload_skps.py'),
|
2016-11-23 13:38:18 +00:00
|
|
|
'--target_dir', output_dir,
|
|
|
|
'--gitcookies', str(update_skps_gitcookies)]
|
2016-10-24 13:36:30 +00:00
|
|
|
env.update(api.infra.go_env)
|
2016-11-23 13:38:18 +00:00
|
|
|
with gitcookies_auth(api, UPDATE_SKPS_KEY):
|
2016-07-26 18:52:17 +00:00
|
|
|
api.step('Upload SKPs',
|
|
|
|
cmd=cmd,
|
2016-08-03 15:23:10 +00:00
|
|
|
cwd=api.vars.skia_dir,
|
2016-07-26 18:52:17 +00:00
|
|
|
env=env)
|
|
|
|
|
|
|
|
|
|
|
|
def GenTests(api):
|
2016-10-24 15:40:26 +00:00
|
|
|
mastername = 'client.skia.compile'
|
|
|
|
slavename = 'skiabot-linux-swarm-000'
|
|
|
|
builder = 'Housekeeper-Nightly-RecreateSKPs_Canary'
|
|
|
|
yield (
|
|
|
|
api.test(builder) +
|
|
|
|
api.properties(buildername=builder,
|
|
|
|
mastername=mastername,
|
|
|
|
slavename=slavename,
|
2017-01-17 19:35:06 +00:00
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
2016-10-24 15:40:26 +00:00
|
|
|
revision='abc123',
|
|
|
|
buildnumber=2,
|
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]') +
|
2016-11-21 21:06:19 +00:00
|
|
|
api.path.exists(api.path['start_dir'].join('skp_output'))
|
2016-10-24 15:40:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
builder = 'Housekeeper-Weekly-RecreateSKPs'
|
|
|
|
yield (
|
|
|
|
api.test(builder) +
|
|
|
|
api.properties(buildername=builder,
|
|
|
|
mastername=mastername,
|
|
|
|
slavename=slavename,
|
2017-01-17 19:35:06 +00:00
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
2016-10-24 15:40:26 +00:00
|
|
|
revision='abc123',
|
|
|
|
buildnumber=2,
|
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]') +
|
2016-11-21 21:06:19 +00:00
|
|
|
api.path.exists(api.path['start_dir'].join('skp_output'))
|
2016-10-24 15:40:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
yield (
|
|
|
|
api.test('failed_upload') +
|
|
|
|
api.properties(buildername=builder,
|
|
|
|
mastername=mastername,
|
|
|
|
slavename=slavename,
|
2017-01-17 19:35:06 +00:00
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
2016-10-24 15:40:26 +00:00
|
|
|
revision='abc123',
|
|
|
|
buildnumber=2,
|
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]') +
|
2016-11-21 21:06:19 +00:00
|
|
|
api.path.exists(api.path['start_dir'].join('skp_output')) +
|
2016-10-24 15:40:26 +00:00
|
|
|
api.step_data('Upload SKPs', retcode=1)
|
|
|
|
)
|