Commit dcb766d5 authored by Erik Staab's avatar Erik Staab Committed by Commit Bot

Script to build a CIPD package for weblayer_instrumentation_test_apk.

This builds a CIPD package containing all built dependencies of
weblayer_instrumentation_test_apk using appropriate gn args and from the
branch where the current working directory is.

Bug: 1058968
Change-Id: Ide146f560cdd8e1a7ae95e472efab4813ff70906
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135317
Commit-Queue: Erik Staab <estaab@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756745}
parent c98eec65
#!/usr/bin/env python3
#
# Copyright 2020 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.
#
# Script to build a CIPD package for weblayer_instrumentation_test_apk from
# the current Chromium checkout.
#
# This should be run from the src directory of a release branch. After the
# package is built the user should run two cipd commands (printed at the end
# of script execution) to upload the package to the CIPD server and to update
# the ref for the corresponding milestone. Once the ref is updated, the version
# skew test will pick up the new package in successive runs.
import argparse
import os
import shutil
import subprocess
import sys
import tempfile
import zipfile
# Run mb.py out of the current branch for simplicity.
MB_PATH = './tools/mb/mb.py'
# Get the config specifying the gn args from the location of this script.
MB_CONFIG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'mb_config.pyl')
# CIPD package path.
# https://chrome-infra-packages.appspot.com/p/chromium/testing/weblayer-x86/+/
CIPD_PKG_PATH='chromium/testing/weblayer-x86'
def zip_test_target(zip_filename):
"""Create zip of all deps for weblayer_instrumentation_test_apk.
Args:
zip_filename: destination zip filename.
"""
cmd = [MB_PATH,
'zip',
'--master=dummy.master',
'--builder=dummy.builder',
'--config-file=%s' % MB_CONFIG_PATH,
'out/Release',
'weblayer_instrumentation_test_apk',
zip_filename]
print(' '.join(cmd))
subprocess.check_call(cmd)
def build_cipd_pkg(input_path, cipd_filename):
"""Create a CIPD package file from the given input path.
Args:
input_path: input directory from which to build the package.
cipd_filename: output filename for resulting cipd archive.
"""
cmd = ['cipd',
'pkg-build',
'--in=%s' % input_path,
'--install-mode=copy',
'--name=%s' % CIPD_PKG_PATH,
'--out=%s' % cipd_filename]
print(' '.join(cmd))
subprocess.check_call(cmd)
def main():
parser = argparse.ArgumentParser(
description='Package weblayer instrumentation tests for CIPD.')
parser.add_argument(
'--cipd_out',
required=True,
help="Output filename for resulting .cipd file.")
args = parser.parse_args()
with tempfile.TemporaryDirectory() as tmp_dir:
# Create zip archive of test target.
zip_filename = os.path.join(tmp_dir, 'file.zip')
zip_test_target(zip_filename)
# Extract zip archive.
extracted = os.path.join(tmp_dir, 'extracted')
os.mkdir(extracted)
with zipfile.ZipFile(zip_filename) as zip_file:
zip_file.extractall(path=extracted)
# Create CIPD archive.
tmp_cipd_filename = os.path.join(tmp_dir, 'file.cipd')
build_cipd_pkg(extracted, tmp_cipd_filename)
shutil.move(tmp_cipd_filename, args.cipd_out)
print(('Use "cipd pkg-register %s -verbose -tag \'version:<branch>\'" ' +
'to upload package to the cipd server.') % args.cipd_out)
print('Use "cipd set-ref chromium/testing/weblayer-x86 --version ' +
'<CIPD instance version> -ref m<milestone>" to update the ref.')
print('The CIPD instance version can be found on the "Instance" line ' +
'above after "chromium/testing/weblayer-x86:".')
if __name__ == '__main__':
sys.exit(main())
# Copyright 2020 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.
# This is a .pyl, or "Python Literal", file. You can treat it just like a
# .json file, with the following exceptions:
# * all keys must be quoted (use single quotes, please);
# * comments are allowed, using '#' syntax; and
# * trailing commas are allowed.
# This is a trimmed version of tools/mb/mb_config.pyl with a dummy master and
# builder to be used with mb.py for creating a zip archive of the WebLayer
# instrumentation tests.
{
'masters': {
'dummy.master': {
'dummy.builder': 'android_release_bot_minimal_symbols_x86_webview_google',
},
},
'configs': {
'android_release_bot_minimal_symbols_x86_webview_google': [
'android', 'release_bot', 'minimal_symbols', 'x86',
'strip_debug_info', 'webview_google',
],
},
# This is a dict mapping a given 'mixin' name to a dict of settings that
# mb should use. See //tools/mb/docs/user_guide.md for more information.
'mixins': {
# We build Android with codecs on most bots to ensure maximum test
# coverage, but use 'android_without_codecs' on bots responsible for
# building publicly advertised non-Official Android builds --
# which are not allowed to have proprietary codecs enabled.
'android': {
'mixins': ['android_without_codecs', 'chrome_with_codecs'],
},
'android_without_codecs': {
'gn_args': 'target_os="android"',
},
'chrome_with_codecs': {
'mixins': ['ffmpeg_branding_chrome', 'proprietary_codecs'],
},
'ffmpeg_branding_chrome': {
'gn_args': 'ffmpeg_branding="Chrome"',
},
'goma': {
'gn_args': 'use_goma=true',
},
'minimal_symbols': {
'gn_args': 'symbol_level=1',
},
# Note: This is probably not what you want to use. Instead use one of the
# chrome_with_codecs or chromeos_with_codecs mixins.
'proprietary_codecs': {
'gn_args': 'proprietary_codecs=true',
},
'release': {
'gn_args': 'is_debug=false',
},
'release_bot': {
'mixins': ['release', 'static', 'goma'],
},
'static': {
'gn_args': 'is_component_build=false',
},
'strip_debug_info': {
'gn_args': 'strip_debug_info=true',
},
'webview_google': {
'gn_args': 'system_webview_package_name="com.google.android.webview"',
},
'x86': {
'gn_args': 'target_cpu="x86"',
},
},
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment