skia2/infra/bots/assets/skp/create_and_upload.py
Ravi Mistry d0e23588e5 Update versions of non-generated SKPs in RecreateSKPs bot
Cq-Include-Trybots: luci.skia.skia.primary:Housekeeper-Nightly-RecreateSKPs_DryRun
Bug: skia:12623
Change-Id: I71e142cccdfbc016ed6d06bb5aaedb7a265fdb0d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/467297
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Ravi Mistry <rmistry@google.com>
2021-11-08 18:08:19 +00:00

67 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python
#
# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Create the asset and upload it."""
import argparse
import os
import subprocess
import sys
import tempfile
import create
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
ASSET = os.path.basename(FILE_DIR)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--chrome_src_path', '-c', required=True)
parser.add_argument('--browser_executable', '-e', required=True)
parser.add_argument('--dm_path', '-d', required=True)
parser.add_argument('--upload_to_partner_bucket', action='store_true')
parser.add_argument('--dry_run', action='store_true')
parser.add_argument('--local', action='store_true')
args = parser.parse_args()
# Pass the flags to the creation script via environment variables, since
# we're calling the script via `sk` and not directly.
os.environ[create.BROWSER_EXECUTABLE_ENV_VAR] = args.browser_executable
os.environ[create.CHROME_SRC_PATH_ENV_VAR] = args.chrome_src_path
os.environ[create.UPLOAD_TO_PARTNER_BUCKET_ENV_VAR] = (
'1' if args.upload_to_partner_bucket else '0')
os.environ[create.DM_PATH_ENV_VAR] = args.dm_path
sk = os.path.realpath(os.path.join(
FILE_DIR, os.pardir, os.pardir, os.pardir, os.pardir, 'bin', 'sk'))
if os.name == 'nt':
sk += '.exe'
if not os.path.isfile(sk):
raise Exception('`sk` not found at %s; maybe you need to run bin/fetch-sk?')
# Find the Chromium revision and supply it as a tag.
chromium_revision = subprocess.check_output(
['git', 'rev-parse', 'HEAD'], cwd=args.chrome_src_path).decode().rstrip()
# Upload the asset.
cmd = [
sk, 'asset', 'upload',
'--tags', 'chromium_revision:%s' % chromium_revision,
]
if args.dry_run:
cmd.append('--dry-run')
if not args.local:
cmd.append('--ci')
cmd.append('skp')
subprocess.check_call(cmd, cwd=FILE_DIR)
if __name__ == '__main__':
main()