blob: bfed67e4efb1c12cfc6d5615adf0a1f0ddc620d3 [file] [log] [blame] [view]
Eric Seidelab8e38d2016-02-11 12:43:05 -08001# Flutter's Build Infrastructure
Eric Seidel0d8aa282016-01-15 16:06:51 -08002
Eric Seidelab8e38d2016-02-11 12:43:05 -08003This directory exists to support building Flutter on our build infrastructure.
Eric Seidel0d8aa282016-01-15 16:06:51 -08004
Casey Hillersafd1d922021-02-11 14:23:11 -08005Flutter build results are available at:
6* https://flutter-dashboard.appspot.com/#/build
Shi-Hao Hong7a88eb92021-03-23 09:23:43 +08007 - Aggregate dashboard of the separate CI systems used by Flutter.
Greg Spencere60087a2018-08-07 13:41:33 -07008* https://cirrus-ci.com/github/flutter/flutter/master
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +03009 - Testing is done on PRs and submitted changes on GitHub.
Eric Seidel0d8aa282016-01-15 16:06:51 -080010
Casey Hillersafd1d922021-02-11 14:23:11 -080011Flutter infra requires special permissions to retrigger builds on the
12[build dashboard](https://flutter-dashboard.appspot.com/#/build). File an
13[infra ticket](https://github.com/flutter/flutter/wiki/Infra-Ticket-Queue) to
14request permission.
Eric Seidelab8e38d2016-02-11 12:43:05 -080015
Dan Field4be48302019-03-08 09:25:13 -080016The [Cirrus](https://cirrus-ci.org)-based bots run the [`test.dart`](test.dart)
17script for each PR and submission. This does testing for the tools, for the
18framework, and (for submitted changes only) rebuilds and updates the master
19branch API docs [staging site](https://master-docs.flutter.dev/).
20For tagged dev and beta builds, it also builds and deploys the gallery app to
21the app stores. It is configured by the [.cirrus.yml](/.cirrus.yml).
Greg Spencere60087a2018-08-07 13:41:33 -070022
Casey Hillers97e018d2022-10-19 10:36:02 -070023The build dashboard includes post-commit testing run on physical devices. See
24[//dev/devicelab](../devicelab/README.md) for more information.
Ian Hickson942ccc52016-05-18 11:38:45 -070025
Chris Bracken4d992322019-05-24 19:12:45 -070026## LUCI (Layered Universal Continuous Integration)
Ian Hicksoncf2fba72018-11-06 13:41:09 -080027
Casey Hillers97e018d2022-10-19 10:36:02 -070028A [set of infra scripts](https://flutter.googlesource.com/recipes/)
29run on Windows, Linux, and Mac machines. The configuration for how many
Casey Hillersafd1d922021-02-11 14:23:11 -080030machines and what kind are managed internally by Google. File an
31[infra ticket](https://github.com/flutter/flutter/wiki/Infra-Ticket-Queue)
Casey Hillers97e018d2022-10-19 10:36:02 -070032to request new machine types to be added. Both of these technologies are highly
Casey Hillersafd1d922021-02-11 14:23:11 -080033specific to the [LUCI](https://github.com/luci) project, which is the successor
34to Chromium's infra and the foundation to Flutter's infrastructure.
Eric Seidelab8e38d2016-02-11 12:43:05 -080035
Ian Hicksoncf2fba72018-11-06 13:41:09 -080036### Prerequisites
37
38To work on this infrastructure you will need:
yjbanov40c7adf2016-02-22 16:59:03 -080039
Dan Field4be48302019-03-08 09:25:13 -080040- [depot_tools](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up)
yjbanov40c7adf2016-02-22 16:59:03 -080041- Python package installer: `sudo apt-get install python-pip`
42- Python coverage package (only needed for `training_simulation`): `sudo pip install coverage`
43
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +030044To run `prepare_package.dart` locally:
xster37108c42019-02-04 23:50:08 -080045
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +030046- Make sure the `depot_tools` is in your `PATH`. If you're on Windows, you also need
47 an environment variable called `DEPOT_TOOLS` with the path to `depot_tools` as value.
Chris Bracken497eb132021-08-06 14:42:08 -070048- Run `gsutil.py config` (or `python3 %DEPOT_TOOLS%\gsutil.py` on Windows) to
Dan Fieldc704d422019-03-01 14:43:57 -080049 authenticate with your auth token.
xster37108c42019-02-04 23:50:08 -080050- Create a local temp directory. `cd` into it.
51- Run `dart [path to your normal Flutter repo]/dev/bots/prepare_package.dart
52 --temp_dir=. --revision=[revision to package] --branch=[branch to deploy to]
53 --publish`.
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +030054- If you're running into `gsutil` permission issues, check with @Hixie to make sure
xster37108c42019-02-04 23:50:08 -080055 you have the right push permissions.
56
Ian Hicksoncf2fba72018-11-06 13:41:09 -080057### Editing a recipe
Eric Seidelab8e38d2016-02-11 12:43:05 -080058
Casey Hillersafd1d922021-02-11 14:23:11 -080059Flutter has several recipes depending on the test. The recipes share common
Ian Hickson08f698b2021-06-30 17:06:06 -070060actions through `recipe_modules`. Searching the builder config in [infra](https://flutter.googlesource.com/infra/+/refs/heads/main)
Casey Hillersafd1d922021-02-11 14:23:11 -080061will indicate the recipe used for a test.
Eric Seidelab8e38d2016-02-11 12:43:05 -080062
Dan Field4be48302019-03-08 09:25:13 -080063Recipes are just Python with some limitations on what can be imported. They are
Eric Seidelab8e38d2016-02-11 12:43:05 -080064[documented](https://github.com/luci/recipes-py/blob/master/doc/user_guide.md)
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +030065by the [luci/recipes-py GitHub project](https://github.com/luci/recipes-py).
Eric Seidelab8e38d2016-02-11 12:43:05 -080066
yjbanov40c7adf2016-02-22 16:59:03 -080067The typical cycle for editing a recipe is:
Eric Seidel74408512016-02-13 05:59:41 -080068
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +0300691. Check out the recipes project using `git clone https://flutter.googlesource.com/recipes`.
godofredoc248d7462020-06-15 14:46:09 -0700702. Make your edits (probably to files in
71 `//recipes/recipes`).
723. Update the tests. Run `recipes.py test train` to update
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +030073 the existing expected output to match the new output. Verify completely new test
Dan Field4be48302019-03-08 09:25:13 -080074 cases by altering the `GenTests` method of the recipe. The recipe is required
75 to have 100% test coverage.
keyonghanf028f972023-02-28 17:21:56 -0800764. Run `led get-builder 'luci.flutter.staging:BUILDER_NAME' | led edit -pa git_ref='refs/pull/<PR number>/head' | led edit -pa git_url='https://github.com/flutter/<repo>' | led edit-recipe-bundle | led launch`, where `BUILDER_NAME` is the builder name (e.g. `Linux Engine`), and
77 `git_ref`/`git_url` is the ref/url of the intended changes to build.
stuartmorgan22c63a12022-01-24 16:15:22 -050078 * If `led` fails, ensure that your `depot_tools` checkout is up to date.
godofredoc248d7462020-06-15 14:46:09 -0700795. To submit a CL, you need a local branch first (`git checkout -b [some branch name]`).
Casey Hillersafd1d922021-02-11 14:23:11 -0800806. Upload the patch (`git commit`, `git cl upload`), and open the outputted URL to the CL.
817. Use "Find owners" to get reviewers for the CL
82
Ian Hicksoncf2fba72018-11-06 13:41:09 -080083### Android Tools
Michael Goderbauer3addac52017-02-06 16:06:35 -080084
Dan Field4be48302019-03-08 09:25:13 -080085The Android SDK and NDK used by Flutter's Chrome infra bots are stored in Google
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +030086Cloud. During the build, a bot runs the `download_android_tools.py` script that
Dan Field4be48302019-03-08 09:25:13 -080087downloads the required version of the Android SDK into `dev/bots/android_tools`.
Yegor107c8122018-01-05 12:40:17 -080088
Dan Field4be48302019-03-08 09:25:13 -080089To check which components are currently installed, download the current SDK
90stored in Google Cloud using the `download_android_tools.py` script, then
91`dev/bots/android_tools/sdk/tools/bin/sdkmanager --list`. If you find that some
Yegor107c8122018-01-05 12:40:17 -080092components need to be updated or installed, follow the steps below:
Michael Goderbauer3addac52017-02-06 16:06:35 -080093
Ian Hicksoncf2fba72018-11-06 13:41:09 -080094#### How to update Android SDK on Google Cloud Storage
Michael Goderbauer3addac52017-02-06 16:06:35 -080095
961. Run Android SDK Manager and update packages
97 `$ dev/bots/android_tools/sdk/tools/android update sdk`
98 Use `android.bat` on Windows.
99
Yegor107c8122018-01-05 12:40:17 -08001002. Use the UI to choose the packages you want to install and/or update.
Michael Goderbauer3addac52017-02-06 16:06:35 -0800101
Dan Field4be48302019-03-08 09:25:13 -08001023. Run `dev/bots/android_tools/sdk/tools/bin/sdkmanager --update`. On Windows,
103 run `sdkmanager.bat` instead. If the process fails with an error saying that
104 it is unable to move files (Windows makes files and directories read-only
105 when another process is holding them open), make a copy of the
106 `dev/bots/android_tools/sdk/tools` directory, run the `sdkmanager.bat` from
107 the copy, and use the `--sdk_root` option pointing at
108 `dev/bots/android_tools/sdk`.
Yegor107c8122018-01-05 12:40:17 -0800109
Dan Field4be48302019-03-08 09:25:13 -08001104. Run `dev/bots/android_tools/sdk/tools/bin/sdkmanager --licenses` and accept
111 the licenses for the newly installed components. It also helps to run this
112 command a second time and make sure that it prints "All SDK package licenses
Yegor107c8122018-01-05 12:40:17 -0800113 accepted".
114
1155. Run upload_android_tools.py -t sdk
Michael Goderbauer3addac52017-02-06 16:06:35 -0800116 `$ dev/bots/upload_android_tools.py -t sdk`
117
Ian Hicksoncf2fba72018-11-06 13:41:09 -0800118#### How to update Android NDK on Google Cloud Storage
Michael Goderbauer3addac52017-02-06 16:06:35 -0800119
1201. Download a new NDK binary (e.g. android-ndk-r10e-linux-x86_64.bin)
1212. cd dev/bots/android_tools
122 `$ cd dev/bots/android_tools`
123
1243. Remove the old ndk directory
125 `$ rm -rf ndk`
126
1274. Run the new NDK binary file
128 `$ ./android-ndk-r10e-linux-x86_64.bin`
129
1305. Rename the extracted directory to ndk
131 `$ mv android-ndk-r10e ndk`
132
1336. Run upload_android_tools.py -t ndk
134 `$ cd ../..`
135 `$ dev/bots/upload_android_tools.py -t ndk`
TL Leee2167b92018-09-06 17:16:22 -0400136
Ian Hicksoncf2fba72018-11-06 13:41:09 -0800137
TL Leee2167b92018-09-06 17:16:22 -0400138## Flutter codelabs build test
139
Ian Hickson989cf182018-09-22 02:02:56 -0700140The Flutter codelabs exercise Material Components in the form of a
141demo application. The code for the codelabs is similar to, but
142distinct from, the code for the Shrine demo app in Flutter Gallery.
143
144The Flutter codelabs build test ensures that the final version of the
145[Material Components for Flutter
146Codelabs](https://github.com/material-components/material-components-flutter-codelabs)
147can be built. This test serves as a smoke test for the Flutter
Ian Hicksoncf2fba72018-11-06 13:41:09 -0800148framework and should not fail. If it does, please address any issues
149in your PR and rerun the test. If you feel that the test failing is
150not a direct result of changes made in your PR or that breaking this
151test is absolutely necessary, escalate this issue by [submitting an
Ian Hickson989cf182018-09-22 02:02:56 -0700152issue](https://github.com/material-components/material-components-flutter-codelabs/issues/new?title=%5BURGENT%5D%20Flutter%20Framework%20breaking%20PR)
TL Leee2167b92018-09-06 17:16:22 -0400153to the MDC-Flutter Team.
Greg Spencerc99ed8f2019-05-24 08:56:52 -0700154
155## Unpublishing published archives
156
157Flutter downloadable archives are built for each release by our continuous
158integration systems using the [`prepare_package.dart`](prepare_package.dart)
159script, but if something goes very wrong, and a release is published that wasn't
160intended to be published, the [`unpublish_package.dart`](unpublish_package.dart)
161script may be used to remove the package or packages from the channels in which
162they were published.
163
164For example To remove a published package corresponding to the git hash
165`d444a455de87a2e40b7f576dc12ffd9ab82fd491`, first do a dry run of the script to
166see what it will do:
167
168```
James Lin6f7630a2019-08-09 15:26:03 -0700169$ dart ./unpublish_package.dart --temp_dir=/tmp/foo --revision d444a455de87a2e40b7f576dc12ffd9ab82fd491
Greg Spencerc99ed8f2019-05-24 08:56:52 -0700170```
171
172And once you've verified the output of the dry run to be sure it is what you
173want to do, run:
174
175```
James Lin6f7630a2019-08-09 15:26:03 -0700176$ dart ./unpublish_package.dart --confirm --temp_dir=/tmp/foo --revision d444a455de87a2e40b7f576dc12ffd9ab82fd491
Greg Spencerc99ed8f2019-05-24 08:56:52 -0700177```
178
Yazeed Al-Khalafd41b1fb2020-07-23 04:23:47 +0300179and it will perform the actions. You will of course need to have access
180to the cloud storage server and have `gsutil` installed to perform this
Greg Spencerc99ed8f2019-05-24 08:56:52 -0700181operation. Only runs on Linux or macOS systems.
182
James Lin6f7630a2019-08-09 15:26:03 -0700183See `dart ./unpublish_package.dart --help` for more details.
Greg Spencerc99ed8f2019-05-24 08:56:52 -0700184
185Once the package is unpublished, it will not be available from the website for
186download, and will not be rebuilt (even though there is a tagged revision in the
187repo still) unless someone forces the packaging build to run again at that
188revision to rebuild the package.