blob: 7396eff4e86ed8f62573497653db2fc9d0022cea [file] [log] [blame] [view]
michaeldo8cccf2142017-03-06 22:12:021# Continuous build and test infrastructure for Chromium for iOS
2
3See the [instructions] for how to check out and build Chromium for iOS.
4
5The Chromium projects use buildbot for continuous integration. This doc starts
6with an overview of the system, then gives detailed explanations about each
7part.
8
9[TOC]
10
11## Overview
12
13Commits are made using the [commit queue], which triggers a series of try jobs
14to compile and test the proposed patch against Chromium tip of tree before
15actually making the commit. If the try jobs succeed the patch is committed. A
16newly committed change triggers the builders (or "bots") to compile and test
17the change again.
18
19## Bots
20
21Bots are slaves attached to a buildbot master (or "waterfall"). A buildbot
22master is a server which polls for commits to a repository and triggers workers
23to compile and test new commits whenever they are detected. [chromium.mac] is
24the main waterfall for Mac desktop and iOS. [tryserver.chromium.mac] serves
25as the try server for Mac desktop and iOS.
26
27The bots know how to check out a given revision of Chromium, compile, and test.
28
29### Code location
30
31#### Master configs
32
33The masters are configured in [tools/build], a separate repository which
34contains various infra-related scripts.
35
36#### Pollers
37
38[chromium.mac] uses a `GitilesPoller` which polls the Chromium repository for
39new commits using the [gitiles] interface. When a new commit is detected, the
40bots are triggered.
41
42#### Recipes
43
44The bots run [recipes], which are scripts that specify their sequence of steps
45located in [tools/build]. An iOS-specific [recipe module] contains common
46functionality that the various [iOS recipes] use.
47
48#### Configs
49
50Because the recipes live in another repository, changes to the recipes don't
51go through the Chromium [commit queue] and aren't tested on the [try server].
52In order to allow bot changes to be tested by the commit queue, the recipes
53for iOS are generic instead of bot-specific, and rely on configuration files
54which live in master-specific JSON config files located in [src/ios/build/bots].
55These configs define the `gn_args` to use during compilation as well as the
56tests to run.
57
58#### Scripts
59
60The [test runner] is the script which installs and runs the tests, interprets
61the results, and collects any files emitted by the test ("test data"). It can
62be found in [src/ios/build/bots/scripts], which means changes to the test runner
63can be tested on the [try server].
64
65### Compiling with goma
66
67Goma is the distributed build system used by Chromium. It reduces compilation
68time by avoiding recompilation of objects which have already been compiled
69elsewhere.
70
71### Testing with swarming
72
73Tests run on [swarming], a distributed test system used by Chromium. After
74compilation, configured tests will be zipped up along with their necessary
75dependencies ("isolated") and sent to the [swarming server] for execution. The
76server issues tasks to its attached workers for execution. The bots themselves
77don't run any tests, they trigger tests to be run remotely on the swarming
78server, then wait and display the results. This allows multiple tests to be
79executed in parallel.
80
81## Try bots
82
83Try bots are bots which test proposed patches which are not yet committed.
84
85Request [try job access] in order to trigger try jobs against your patch. The
John Budorick19698582020-02-14 20:37:3886relevant try bots for an iOS patch are `ios-device` and `ios-simulator`. These
87bots can be found on the Mac-specific [try server]. A try job is said to succeed
88when the build passes (i.e. when the bot successfully compiles and tests the
89patch).
michaeldo8cccf2142017-03-06 22:12:0290
John Budorick19698582020-02-14 20:37:3891`ios-device` compiles for the iOS device architecture (ARM) and runs no tests.
92A build is considered successful so long as compilation is successful.
michaeldo8cccf2142017-03-06 22:12:0293
John Budorick19698582020-02-14 20:37:3894`ios-simulator` compiles for the iOS simulator architecture (x86), and runs
95tests in the iOS [simulator]. A build is considered successful when both
96compilation and all configured tests succeed.
michaeldo8cccf2142017-03-06 22:12:0297
98`ios-device` and `ios-simulator` both compile using the version of [clang]
99defined by the `CLANG_REVISION` in the Chromium tree.
100
michaeldo8cccf2142017-03-06 22:12:02101### Scheduling try jobs using buildbucket
102
103Triggering a try job and collecting its results is accomplished using
104[buildbucket]. The service allows for build requests to be put into buckets. A
105request in this context is a set of properties indicating things such as where
106to get the patch. The try bots are set up to poll a particular bucket for build
107requests which they execute and post the results of.
108
109### Compiling with the analyzer
110
111In addition to goma, the try bots use another time-saving mechanism called the
112[analyzer] to determine the subset of compilation targets affected by the patch
113that need to be compiled in order to run the affected tests. If a patch is
114determined not to affect a certain test target, compilation and execution of the
115test target will be skipped.
116
117## Configuring the bots
118
119See the [configs code location](#Configs) for where to find the config files for
120the bots. The config files are JSON which describe how the bot should compile
121and which tests it should run. The config files are located in the configs
122directory. The configs directory contains a named directory for each master. For
123example:
124```shell
125$ ls ios/build/bots
126OWNERS scripts tests chromium.fyi chromium.mac
127```
128In this case, configs are defined for iOS bots on [chromium.fyi] and
129[chromium.mac]. Inside each master-specific directory are JSON config files
130named after each bot. For example:
131```shell
132$ ls ios/build/bots/chromium.mac
133ios-device.json ios-simulator.json
134```
135The `ios-device` bot on [chromium.mac] will read its configuration from
136`chromium.mac/ios-device.json` in the configs directory.
137
138### Example
139
140```json
141{
142 "comments": [
143 "Sample config for a bot."
144 ],
145 "gn_args": [
146 "is_debug=true",
147 "target_cpu=\"x64\""
148 ],
149 "tests": [
150 {
151 "app": "ios_chrome_unittests",
152 "device type": "iPhone 5s",
Sergey Berezin730c59e2017-12-21 04:41:53153 "os": "11.0",
154 "xcode build version": "9A235"
michaeldo8cccf2142017-03-06 22:12:02155 }
156 ]
157}
158```
159The `comments` key is optional and defines a list of strings which can be used
160to annotate the config. You may want to explain why the bot exists and what it's
161doing, particularly if there are extensive and atypical `gn_args`.
162
163The `gn_args` key is a required list of arguments to pass to [GN] to generate
164the build files. Two GN args are required, `is_debug` and `target_cpu`. Use
165`is_debug` to define whether to compile for Debug or Release, and `target_cpu`
166to define whether to compile for x86, x64, arm, or arm64. The iOS bots typically
167perform Debug builds for x86 and x64, and Release builds for arm and arm64. An
168x86/x64 build can only be tested on the [iOS simulator], while an arm/arm64
169build can only be tested on a physical device.
170
171Since Chromium for iOS is shipped as a [universal binary], it's also fairly
172common to set `additional_target_cpus`. For simulator builds, we typically set:
173```json
174"gn_args": [
175 "additional_target_cpus=[\"x86\"]",
176 "is_debug=true",
177 "target_cpu=\"x64\""
178]
179```
180This builds universal binaries which run in 32-bit mode on 32-bit simulators and
18164-bit mode on 64-bit simulators. For device builds we typically set:
182```json
183"gn_args": [
184 "additional_target_cpus=[\"arm\"]",
185 "is_debug=false",
186 "target_cpu=\"arm64\""
187]
188```
189In order to build universal binaries which run in 32-bit mode on 32-bit devices
190and 64-bit mode on 64-bit devices.
191
192The `tests` key is an optional list of dictionaries defining tests to run. There
193are two types of test dictionary, `app` and `include`. An `app` dict defines a
194specific compiled app to run, for example:
195```json
196"tests": [
197 {
198 "app": "ios_chrome_unittests",
199 "device type": "iPhone 5s",
Sergey Berezin730c59e2017-12-21 04:41:53200 "os": "11.0",
201 "xcode build version": "9A235"
michaeldo8cccf2142017-03-06 22:12:02202 }
203]
204```
Sergey Berezin730c59e2017-12-21 04:41:53205
michaeldo8cccf2142017-03-06 22:12:02206This dict says to run `ios_chrome_unittests` on an `iPhone 5s` running iOS
Sergey Berezin730c59e2017-12-21 04:41:53207`11.0` using Xcode build version `9A235`. A test dict may optionally define a
208list of `test args`, which are arguments to pass directly to the test on the
209command line, and it may define a boolean value `xctest` to indicate whether the
210test is an [xctest] \(default if unspecified is `false`\). For example:
211
michaeldo8cccf2142017-03-06 22:12:02212```json
213"tests": [
214 {
215 "app": "ios_chrome_unittests",
216 "device type": "iPhone 5s",
Sergey Berezin730c59e2017-12-21 04:41:53217 "os": "11.0",
michaeldo8cccf2142017-03-06 22:12:02218 "test args": [
219 "--foo",
220 "--bar"
221 ],
Sergey Berezin730c59e2017-12-21 04:41:53222 "xcode build version": "9A235"
michaeldo8cccf2142017-03-06 22:12:02223 },
224 {
225 "app": "ios_chrome_integration_egtests",
226 "device type": "iPhone 5s",
Sergey Berezin730c59e2017-12-21 04:41:53227 "os": "11.0",
228 "xcode build version": "9A235",
michaeldo8cccf2142017-03-06 22:12:02229 "xctest": true
230 }
231]
232```
233This defines two tests to run, first `ios_chrome_unittests` will be run with
234`--foo` and `--bar` passed directly to the test on the command line. Next,
235`ios_chrome_integration_egtests` will be run as an xctest. `"xctest": true`
236must be specified for all xctests, it is an error to try and launch an xctest as
237a regular test.
238
239An `include` dict defines a list of tests to import from the `tests`
240subdirectory in the configs directory. For example:
241```json
242"tests": [
243 {
244 "include": "common_tests.json",
245 "device type": "iPhone 5s",
Sergey Berezin730c59e2017-12-21 04:41:53246 "os": "11.0",
247 "xcode build version": "9A235"
michaeldo8cccf2142017-03-06 22:12:02248 }
249]
250```
251This dict says to import the list of tests from the `tests` subdirectory and run
Sergey Berezin730c59e2017-12-21 04:41:53252each one on an `iPhone 5s` running iOS `11.0` using Xcode `9A235`. Here's what
michaeldo8cccf2142017-03-06 22:12:02253`common_tests.json` might look like:
254```json
255"tests": [
256 {
257 "app": "ios_chrome_unittests"
258 },
259 {
260 "app": "ios_net_unittests"
261 },
262 {
263 "app": "ios_web_unittests"
264 },
265]
266```
267Includes may contain other keys besides `app` which can then be omitted in the
268bot config. For example if `common_tests.json` specifies:
269```json
270"tests": [
271 {
272 "app": "ios_chrome_integration_egtests",
273 "xctest": true,
Sergey Berezin730c59e2017-12-21 04:41:53274 "xcode build version": "9A235"
michaeldo8cccf2142017-03-06 22:12:02275 }
276]
277```
Sergey Berezin730c59e2017-12-21 04:41:53278
279Then the bot config may omit the `xctest` or `xcode build version` keys, for
280example:
281
michaeldo8cccf2142017-03-06 22:12:02282```json
283{
284 "comments": [
285 "Sample config for a bot."
286 ],
287 "gn_args": [
288 "is_debug=true",
289 "target_cpu=\"x64\""
290 ],
291 "tests": [
292 {
293 "include": "common_tests.json",
294 "device type": "iPhone 5s",
Sergey Berezin730c59e2017-12-21 04:41:53295 "os": "11.0"
michaeldo8cccf2142017-03-06 22:12:02296 }
297 ]
298}
299```
300Includes are not recursive, so `common_tests.json` may not itself include any
301`include` dicts.
302
Sergey Berezin730c59e2017-12-21 04:41:53303Some keywords such as `xcode build version` can also be set globally per build:
304
305```json
306{
307 "comments": [
308 "Sample config for a bot."
309 ],
310 "gn_args": [
311 "is_debug=true",
312 "target_cpu=\"x64\""
313 ],
314 "xcode build version": "9A235",
315 "tests": [
316 {
317 "app": "ios_chrome_integration_egtests",
318 "device type": "iPhone 5s",
319 "os": "11.0"
320 }
321 ]
322}
323```
324
michaeldo8cccf2142017-03-06 22:12:02325### Uploading compiled artifacts from a bot
326
327A bot may be configured to upload compiled artifacts. This is defined by the
328`upload` key. For example:
329```json
330{
331 "comments": [
332 "Sample config for a bot which uploads artifacts."
333 ],
334 "gn_args": [
335 "is_debug=true",
336 "target_cpu=\"x64\""
337 ],
338 "upload": [
339 {
340 "artifact": "Chromium.breakpad",
341 "bucket": "my-gcs-bucket",
342 },
343 {
344 "artifact": "Chromium.app",
345 "bucket": "my-gcs-bucket",
346 "compress": true,
347 },
348 {
349 "artifact": "Chromium.breakpad",
smut9ea33c6a2017-08-23 23:20:35350 "symupload": "https://clients2.google.com/cr/symbol",
michaeldo8cccf2142017-03-06 22:12:02351 }
352 ]
353}
354```
355After compilation, the bot will upload three artifacts. First the
356`Chromium.breakpad` symbols will be uploaded to
357`gs://my-gcs-bucket/<buildername>/<buildnumber>/Chromium.breakpad`. Next
358`Chromium.app` will be tarred, gzipped, and uploaded to
359`gs://my-gcs-bucket/<buildername>/<buildnumber>/Chromium.tar.gz`. Finally
360the `Chromium.breakpad` symbols will be uploaded to the [breakpad] crash
361reporting server where they can be used to symbolicate stack traces.
362
363If `artifact` is a directory, you must specify `"compress": true`.
364
365[analyzer]: ../../tools/mb
366[breakpad]: https://chromium.googlesource.com/breakpad/breakpad
367[buildbucket]: https://cr-buildbucket.appspot.com
368[chromium.fyi]: https://build.chromium.org/p/chromium.fyi/waterfall
369[chromium.mac]: https://build.chromium.org/p/chromium.mac
370[clang]: ../../tools/clang
371[commit queue]: https://dev.chromium.org/developers/testing/commit-queue
372[gitiles]: https://gerrit.googlesource.com/gitiles
373[GN]: ../../tools/gn
374[instructions]: ./build_instructions.md
John Palmer046f9872021-05-24 01:24:56375[iOS recipes]: https://chromium.googlesource.com/chromium/tools/build/+/main/scripts/slave/recipes/ios
michaeldo8cccf2142017-03-06 22:12:02376[iOS simulator]: ../../testing/iossim
John Palmer046f9872021-05-24 01:24:56377[recipe module]: https://chromium.googlesource.com/chromium/tools/build/+/main/scripts/slave/recipe_modules/ios
michaeldo8cccf2142017-03-06 22:12:02378[recipes]: https://chromium.googlesource.com/infra/infra/+/HEAD/doc/users/recipes.md
379[simulator]: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/iOS_Simulator_Guide/Introduction/Introduction.html
380[src/ios/build/bots]: ../../ios/build/bots
381[src/ios/build/bots/scripts]: ../../ios/build/bots/scripts
John Palmer046f9872021-05-24 01:24:56382[swarming]: https://chromium.googlesource.com/infra/luci/luci-py/+/main/appengine/swarming/
michaeldo8cccf2142017-03-06 22:12:02383[swarming server]: https://chromium-swarm.appspot.com
384[test runner]: ../../ios/build/bots/scripts/test_runner.py
385[tools/build]: https://chromium.googlesource.com/chromium/tools/build
386[try job access]: https://www.chromium.org/getting-involved/become-a-committer#TOC-Try-job-access
387[try server]: https://build.chromium.org/p/tryserver.chromium.mac/waterfall
388[tryserver.chromium.mac]: https://build.chromium.org/p/tryserver.chromium.mac/waterfall
389[universal binary]: https://en.wikipedia.org/wiki/Universal_binary
390[xctest]: https://developer.apple.com/reference/xctest