xref: /aosp_15_r20/external/perfetto/infra/ci/config.py (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1#!/usr/bin/env python3
2# Copyright (C) 2019 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15'''Project-wide configuration
16
17This file is either imported from other python scripts or executed to generate
18makefile dumps of the variables. This is so all vars can live in one place.
19'''
20
21import os
22import sys
23
24# Gerrit config
25GERRIT_HOST = 'android-review.googlesource.com'
26GERRIT_PROJECT = 'platform/external/perfetto'
27GERRIT_REVIEW_URL = ('https://android-review.googlesource.com/c/' +
28                     GERRIT_PROJECT)
29REPO_URL = 'https://android.googlesource.com/' + GERRIT_PROJECT
30GERRIT_VOTING_ENABLED = True
31LOGLEVEL = 'info'
32
33# Cloud config (GCE = Google Compute Engine, GAE = Google App Engine)
34PROJECT = 'perfetto-ci'
35
36GAE_VERSION = 'prod'
37DB_ROOT = 'https://%s.firebaseio.com' % PROJECT
38DB = DB_ROOT + '/ci'
39SANDBOX_IMG = 'us-docker.pkg.dev/%s/containers/sandbox' % PROJECT
40WORKER_IMG = 'us-docker.pkg.dev/%s/containers/worker' % PROJECT
41CI_SITE = 'https://ci.perfetto.dev'
42GCS_ARTIFACTS = 'perfetto-ci-artifacts'
43
44JOB_TIMEOUT_SEC = 45 * 60  # 45 min
45CL_TIMEOUT_SEC = 60 * 60 * 3  # 3 hours
46LOGS_TTL_DAYS = 15
47TRUSTED_EMAILS = '^.*@google.com$'
48
49GCE_REGIONS = 'us-west1'
50GCE_VM_NAME = 'ci-worker'
51GCE_VM_TYPE = 'c2d-standard-32'
52GCE_TEMPLATE = 'ci-worker-template'
53GCE_GROUP_NAME = 'ci'
54MAX_VMS_PER_REGION = 8
55NUM_WORKERS_PER_VM = 4
56
57GCE_SCOPES = [
58    'https://www.googleapis.com/auth/cloud-platform',
59    'https://www.googleapis.com/auth/devstorage.read_write',
60    'https://www.googleapis.com/auth/firebase.database',
61    'https://www.googleapis.com/auth/logging.write',
62    'https://www.googleapis.com/auth/monitoring.write',
63    'https://www.googleapis.com/auth/trace.append',
64    'https://www.googleapis.com/auth/userinfo.email',
65]
66
67# Only variables starting with PERFETTO_ are propagated into the sandbox.
68JOB_CONFIGS = {
69    'linux-clang-x86_64-debug': {
70        'PERFETTO_TEST_GN_ARGS': 'is_debug=true is_hermetic_clang=false '
71                                 'non_hermetic_clang_stdlib="libc++" '
72                                 'enable_perfetto_merged_protos_check=true',
73        'PERFETTO_TEST_SCRIPT': 'test/ci/linux_tests.sh',
74        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '',
75    },
76    'linux-clang-x86_64-tsan': {
77        'PERFETTO_TEST_GN_ARGS': 'is_debug=false is_tsan=true',
78        'PERFETTO_TEST_SCRIPT': 'test/ci/linux_tests.sh',
79        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '',
80    },
81    'linux-clang-x86_64-msan': {
82        'PERFETTO_TEST_GN_ARGS': 'is_debug=false is_msan=true',
83        'PERFETTO_TEST_SCRIPT': 'test/ci/linux_tests.sh',
84        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '',
85    },
86    'linux-clang-x86_64-asan_lsan': {
87        'PERFETTO_TEST_GN_ARGS': 'is_debug=false is_asan=true is_lsan=true',
88        'PERFETTO_TEST_SCRIPT': 'test/ci/linux_tests.sh',
89        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '',
90    },
91    'linux-clang-x86-release': {
92        'PERFETTO_TEST_GN_ARGS': 'is_debug=false target_cpu="x86"',
93        'PERFETTO_TEST_SCRIPT': 'test/ci/linux_tests.sh',
94        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '',
95    },
96    'linux-gcc8-x86_64-release': {
97        'PERFETTO_TEST_GN_ARGS':
98            'is_debug=false is_clang=false enable_perfetto_grpc=true '
99            'cc="gcc-8" cxx="g++-8"',
100        'PERFETTO_TEST_SCRIPT': 'test/ci/linux_tests.sh',
101        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '--grpc',
102    },
103    'android-clang-arm-release': {
104        'PERFETTO_TEST_GN_ARGS':
105            'is_debug=false target_os="android" target_cpu="arm"',
106        'PERFETTO_TEST_SCRIPT':
107            'test/ci/android_tests.sh',
108        'PERFETTO_INSTALL_BUILD_DEPS_ARGS':
109            '--android',
110    },
111    'linux-clang-x86_64-libfuzzer': {
112        'PERFETTO_TEST_GN_ARGS': 'is_debug=false is_fuzzer=true is_asan=true',
113        'PERFETTO_TEST_SCRIPT': 'test/ci/fuzzer_tests.sh',
114        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '',
115    },
116    'linux-clang-x86_64-bazel': {
117        'PERFETTO_TEST_GN_ARGS': '',
118        'PERFETTO_TEST_SCRIPT': 'test/ci/bazel_tests.sh',
119        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '',
120    },
121    'ui-clang-x86_64-release': {
122        'PERFETTO_TEST_GN_ARGS': 'is_debug=false',
123        'PERFETTO_TEST_SCRIPT': 'test/ci/ui_tests.sh',
124        'PERFETTO_INSTALL_BUILD_DEPS_ARGS': '--ui',
125    },
126}
127
128if __name__ == '__main__':
129  import os
130  import json
131  import re
132  import sys
133  vars = dict(kv for kv in locals().items() if re.match('^[A-Z0-9_]+$', kv[0]))
134
135  if len(sys.argv) > 1 and sys.argv[1] == 'makefile':
136    deps_path = os.path.join(os.path.dirname(__file__), '.deps')
137    if not os.path.exists(deps_path):
138      os.mkdir(deps_path)
139    gen_file = os.path.join(deps_path, 'config.mk')
140
141    try:
142      literals = (int, long, basestring)
143    except NameError:
144      literals = (int, str)
145
146    with open(gen_file, 'w') as f:
147      for k, v in vars.items():
148        if isinstance(v, literals):
149          f.write('override %s=%s\n' % (k, v))
150        elif isinstance(v, list):
151          f.write('override %s=%s\n' % (k, ','.join(v)))
152
153    print(gen_file)
154
155  if len(sys.argv) > 1 and sys.argv[1] == 'js':
156    jsn = json.dumps(vars, indent=2)
157    print('// Auto-generated by %s, do not edit.\n' %
158          os.path.basename(__file__))
159    print('\'use strict\';\n')
160    print('const cfg = JSON.parse(`%s`);\n' % jsn.replace(r'\"', r'\\\"'))
161