2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
7 This script runs swarming_xcode_install on the bots. It should be run when we
8 need to upgrade all the swarming testers. It:
9 1) Packages two python files into an isolate.
10 2) Runs the isolate on swarming machines that satisfy certain dimensions.
13 $ ./build/run_swarming_xcode_install.py --luci_path ~/work/luci-py \
14 --swarming-server touch-swarming.appspot.com \
15 --isolate-server touch-isolate.appspot.com
27 parser = argparse.ArgumentParser(
28 description='Run swarming_xcode_install on the bots.')
29 parser.add_argument('--luci_path', required=True, type=os.path.abspath)
30 parser.add_argument('--swarming-server', required=True, type=str)
31 parser.add_argument('--isolate-server', required=True, type=str)
32 parser.add_argument('--batches', type=int, default=25,
33 help="Run xcode install in batches of size |batches|.")
34 parser.add_argument('--dimension', nargs=2, action='append')
35 args = parser.parse_args()
37 args.dimension = args.dimension or []
39 script_dir = os.path.dirname(os.path.abspath(__file__))
40 tmp_dir = tempfile.mkdtemp(prefix='swarming_xcode')
42 print 'Making isolate.'
43 shutil.copyfile(os.path.join(script_dir, 'swarming_xcode_install.py'),
44 os.path.join(tmp_dir, 'swarming_xcode_install.py'))
45 shutil.copyfile(os.path.join(script_dir, 'mac_toolchain.py'),
46 os.path.join(tmp_dir, 'mac_toolchain.py'))
48 luci_client = os.path.join(args.luci_path, 'client')
50 sys.executable, os.path.join(luci_client, 'isolateserver.py'), 'archive',
51 '-I', args.isolate_server, tmp_dir,
53 isolate_hash = subprocess.check_output(cmd).split()[0]
55 print 'Running swarming_xcode_install.'
56 # TODO(crbug.com/765361): The dimensions below should be updated once
57 # swarming for iOS is fleshed out, likely removing xcode_version 9 and
58 # adding different dimensions.
59 luci_tools = os.path.join(luci_client, 'tools')
60 dimensions = [['pool', 'Chrome'], ['xcode_version', '9.0']] + args.dimension
63 dim_args += ['--dimension'] + d
65 sys.executable, os.path.join(luci_tools, 'run_on_bots.py'),
66 '--swarming', args.swarming_server, '--isolate-server',
67 args.isolate_server, '--priority', '20', '--batches', str(args.batches),
68 '--tags', 'name:run_swarming_xcode_install',
69 ] + dim_args + ['--name', 'run_swarming_xcode_install', '--', isolate_hash,
70 'python', 'swarming_xcode_install.py',
72 subprocess.check_call(cmd)
73 print 'All tasks completed.'
76 shutil.rmtree(tmp_dir)
80 if __name__ == '__main__':