Flutter Engine
The Flutter Engine
build.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright 2013 The Flutter 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.
5
6# A script for re-running prod builds on LUCI
7#
8# Usage:
9# $ build.py --commit [Engine commit hash] --builder [builder name]
10#
11# NOTE: This script requires python3.7 or later.
12#
13
14import argparse
15import os
16import re
17import subprocess
18import sys
19
20
22 curl_command = [
23 'curl',
24 'https://ci.chromium.org/p/flutter/g/engine/builders',
25 ]
26 curl_result = subprocess.run(
27 curl_command,
28 universal_newlines=True,
29 capture_output=True,
30 )
31 if curl_result.returncode != 0:
32 print('Failed to fetch builder list: stderr:\n%s' % curl_result.stderr)
33 return []
34 sed_command = [
35 'sed',
36 '-En',
37 's:.*aria-label="builder buildbucket/luci\\.flutter\\.prod/([^/]+)".*:\\1:p',
38 ]
39 sed_result = subprocess.run(
40 sed_command,
41 input=curl_result.stdout,
42 capture_output=True,
43 universal_newlines=True,
44 )
45 if sed_result.returncode != 0:
46 print('Failed to fetch builder list: stderr:\n%s' % sed_result.stderr)
47 return list(set(sed_result.stdout.splitlines()))
48
49
50def Main():
51 parser = argparse.ArgumentParser(description='Reruns Engine LUCI prod builds')
52 parser.add_argument(
53 '--force-upload',
54 action='store_true',
55 default=False,
56 help='Force artifact upload, overwriting existing artifacts.'
57 )
58 parser.add_argument('--all', action='store_true', default=False, help='Re-run all builds.')
59 parser.add_argument('--builder', type=str, help='The builer to rerun.')
60 parser.add_argument('--commit', type=str, required=True, help='The commit to rerun.')
61 parser.add_argument(
62 '--dry-run', action='store_true', help='Print what would be done, but do nothing.'
63 )
64 args = parser.parse_args()
65
66 if 'help' in vars(args) and args.help:
67 parser.print_help()
68 return 0
69
70 if args.all:
71 builders = GetAllBuilders()
72 elif args.builder == None:
73 print('Either --builder or --all is required.')
74 return 1
75 else:
76 builders = [args.builder]
77
78 auth_command = [
79 'gcloud',
80 'auth',
81 'print-identity-token',
82 ]
83 auth_result = subprocess.run(
84 auth_command,
85 universal_newlines=True,
86 capture_output=True,
87 )
88 if auth_result.returncode != 0:
89 print('Auth failed:\nstdout:\n%s\nstderr:\n%s' % (auth_result.stdout, auth_result.stderr))
90 return 1
91 auth_token = auth_result.stdout.rstrip()
92
93 for builder in builders:
94 if args.force_upload:
95 params = (
96 '{"Commit": "%s", "Builder": "%s", "Repo": "engine", "Properties": {"force_upload":true}}'
97 % (args.commit, builder)
98 )
99 else:
100 params = '{"Commit": "%s", "Builder": "%s", "Repo": "engine"}' % (args.commit, builder)
101 curl_command = [
102 'curl',
103 'http://flutter-dashboard.appspot.com/api/reset-prod-task',
104 "-d %s" % params,
105 '-H',
106 'X-Flutter-IdToken: %s' % auth_token,
107 ]
108 if args.dry_run:
109 print('Running: %s' % ' '.join(curl_command))
110 else:
111 result = subprocess.run(curl_command)
112 if result.returncode != 0:
113 print('Trigger for %s failed. Aborting.' % builder)
114 return 1
115
116 return 0
117
118
119if __name__ == '__main__':
120 sys.exit(Main())
def GetAllBuilders()
Definition: build.py:21
def Main()
Definition: build.py:269
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76
def print(*args, **kwargs)
Definition: run_tests.py:49
Definition: __init__.py:1
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741