Eric Seidel | ab8e38d | 2016-02-11 12:43:05 -0800 | [diff] [blame] | 1 | # Flutter's Build Infrastructure |
Eric Seidel | 0d8aa28 | 2016-01-15 16:06:51 -0800 | [diff] [blame] | 2 | |
Eric Seidel | ab8e38d | 2016-02-11 12:43:05 -0800 | [diff] [blame] | 3 | This directory exists to support building Flutter on our build infrastructure. |
Eric Seidel | 0d8aa28 | 2016-01-15 16:06:51 -0800 | [diff] [blame] | 4 | |
Casey Hillers | afd1d92 | 2021-02-11 14:23:11 -0800 | [diff] [blame] | 5 | Flutter build results are available at: |
| 6 | * https://flutter-dashboard.appspot.com/#/build |
Shi-Hao Hong | 7a88eb9 | 2021-03-23 09:23:43 +0800 | [diff] [blame] | 7 | - Aggregate dashboard of the separate CI systems used by Flutter. |
Greg Spencer | e60087a | 2018-08-07 13:41:33 -0700 | [diff] [blame] | 8 | * https://cirrus-ci.com/github/flutter/flutter/master |
Yazeed Al-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 9 | - Testing is done on PRs and submitted changes on GitHub. |
Eric Seidel | 0d8aa28 | 2016-01-15 16:06:51 -0800 | [diff] [blame] | 10 | |
Casey Hillers | afd1d92 | 2021-02-11 14:23:11 -0800 | [diff] [blame] | 11 | Flutter 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 |
| 14 | request permission. |
Eric Seidel | ab8e38d | 2016-02-11 12:43:05 -0800 | [diff] [blame] | 15 | |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 16 | The [Cirrus](https://cirrus-ci.org)-based bots run the [`test.dart`](test.dart) |
| 17 | script for each PR and submission. This does testing for the tools, for the |
| 18 | framework, and (for submitted changes only) rebuilds and updates the master |
| 19 | branch API docs [staging site](https://master-docs.flutter.dev/). |
| 20 | For tagged dev and beta builds, it also builds and deploys the gallery app to |
| 21 | the app stores. It is configured by the [.cirrus.yml](/.cirrus.yml). |
Greg Spencer | e60087a | 2018-08-07 13:41:33 -0700 | [diff] [blame] | 22 | |
Casey Hillers | 97e018d | 2022-10-19 10:36:02 -0700 | [diff] [blame] | 23 | The build dashboard includes post-commit testing run on physical devices. See |
| 24 | [//dev/devicelab](../devicelab/README.md) for more information. |
Ian Hickson | 942ccc5 | 2016-05-18 11:38:45 -0700 | [diff] [blame] | 25 | |
Chris Bracken | 4d99232 | 2019-05-24 19:12:45 -0700 | [diff] [blame] | 26 | ## LUCI (Layered Universal Continuous Integration) |
Ian Hickson | cf2fba7 | 2018-11-06 13:41:09 -0800 | [diff] [blame] | 27 | |
Casey Hillers | 97e018d | 2022-10-19 10:36:02 -0700 | [diff] [blame] | 28 | A [set of infra scripts](https://flutter.googlesource.com/recipes/) |
| 29 | run on Windows, Linux, and Mac machines. The configuration for how many |
Casey Hillers | afd1d92 | 2021-02-11 14:23:11 -0800 | [diff] [blame] | 30 | machines and what kind are managed internally by Google. File an |
| 31 | [infra ticket](https://github.com/flutter/flutter/wiki/Infra-Ticket-Queue) |
Casey Hillers | 97e018d | 2022-10-19 10:36:02 -0700 | [diff] [blame] | 32 | to request new machine types to be added. Both of these technologies are highly |
Casey Hillers | afd1d92 | 2021-02-11 14:23:11 -0800 | [diff] [blame] | 33 | specific to the [LUCI](https://github.com/luci) project, which is the successor |
| 34 | to Chromium's infra and the foundation to Flutter's infrastructure. |
Eric Seidel | ab8e38d | 2016-02-11 12:43:05 -0800 | [diff] [blame] | 35 | |
Ian Hickson | cf2fba7 | 2018-11-06 13:41:09 -0800 | [diff] [blame] | 36 | ### Prerequisites |
| 37 | |
| 38 | To work on this infrastructure you will need: |
yjbanov | 40c7adf | 2016-02-22 16:59:03 -0800 | [diff] [blame] | 39 | |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 40 | - [depot_tools](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up) |
yjbanov | 40c7adf | 2016-02-22 16:59:03 -0800 | [diff] [blame] | 41 | - 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-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 44 | To run `prepare_package.dart` locally: |
xster | 37108c4 | 2019-02-04 23:50:08 -0800 | [diff] [blame] | 45 | |
Yazeed Al-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 46 | - 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 Bracken | 497eb13 | 2021-08-06 14:42:08 -0700 | [diff] [blame] | 48 | - Run `gsutil.py config` (or `python3 %DEPOT_TOOLS%\gsutil.py` on Windows) to |
Dan Field | c704d42 | 2019-03-01 14:43:57 -0800 | [diff] [blame] | 49 | authenticate with your auth token. |
xster | 37108c4 | 2019-02-04 23:50:08 -0800 | [diff] [blame] | 50 | - 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-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 54 | - If you're running into `gsutil` permission issues, check with @Hixie to make sure |
xster | 37108c4 | 2019-02-04 23:50:08 -0800 | [diff] [blame] | 55 | you have the right push permissions. |
| 56 | |
Ian Hickson | cf2fba7 | 2018-11-06 13:41:09 -0800 | [diff] [blame] | 57 | ### Editing a recipe |
Eric Seidel | ab8e38d | 2016-02-11 12:43:05 -0800 | [diff] [blame] | 58 | |
Casey Hillers | afd1d92 | 2021-02-11 14:23:11 -0800 | [diff] [blame] | 59 | Flutter has several recipes depending on the test. The recipes share common |
Ian Hickson | 08f698b | 2021-06-30 17:06:06 -0700 | [diff] [blame] | 60 | actions through `recipe_modules`. Searching the builder config in [infra](https://flutter.googlesource.com/infra/+/refs/heads/main) |
Casey Hillers | afd1d92 | 2021-02-11 14:23:11 -0800 | [diff] [blame] | 61 | will indicate the recipe used for a test. |
Eric Seidel | ab8e38d | 2016-02-11 12:43:05 -0800 | [diff] [blame] | 62 | |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 63 | Recipes are just Python with some limitations on what can be imported. They are |
Eric Seidel | ab8e38d | 2016-02-11 12:43:05 -0800 | [diff] [blame] | 64 | [documented](https://github.com/luci/recipes-py/blob/master/doc/user_guide.md) |
Yazeed Al-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 65 | by the [luci/recipes-py GitHub project](https://github.com/luci/recipes-py). |
Eric Seidel | ab8e38d | 2016-02-11 12:43:05 -0800 | [diff] [blame] | 66 | |
yjbanov | 40c7adf | 2016-02-22 16:59:03 -0800 | [diff] [blame] | 67 | The typical cycle for editing a recipe is: |
Eric Seidel | 7440851 | 2016-02-13 05:59:41 -0800 | [diff] [blame] | 68 | |
Yazeed Al-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 69 | 1. Check out the recipes project using `git clone https://flutter.googlesource.com/recipes`. |
godofredoc | 248d746 | 2020-06-15 14:46:09 -0700 | [diff] [blame] | 70 | 2. Make your edits (probably to files in |
| 71 | `//recipes/recipes`). |
| 72 | 3. Update the tests. Run `recipes.py test train` to update |
Yazeed Al-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 73 | the existing expected output to match the new output. Verify completely new test |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 74 | cases by altering the `GenTests` method of the recipe. The recipe is required |
| 75 | to have 100% test coverage. |
keyonghan | f028f97 | 2023-02-28 17:21:56 -0800 | [diff] [blame] | 76 | 4. 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. |
stuartmorgan | 22c63a1 | 2022-01-24 16:15:22 -0500 | [diff] [blame] | 78 | * If `led` fails, ensure that your `depot_tools` checkout is up to date. |
godofredoc | 248d746 | 2020-06-15 14:46:09 -0700 | [diff] [blame] | 79 | 5. To submit a CL, you need a local branch first (`git checkout -b [some branch name]`). |
Casey Hillers | afd1d92 | 2021-02-11 14:23:11 -0800 | [diff] [blame] | 80 | 6. Upload the patch (`git commit`, `git cl upload`), and open the outputted URL to the CL. |
| 81 | 7. Use "Find owners" to get reviewers for the CL |
| 82 | |
Ian Hickson | cf2fba7 | 2018-11-06 13:41:09 -0800 | [diff] [blame] | 83 | ### Android Tools |
Michael Goderbauer | 3addac5 | 2017-02-06 16:06:35 -0800 | [diff] [blame] | 84 | |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 85 | The Android SDK and NDK used by Flutter's Chrome infra bots are stored in Google |
Yazeed Al-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 86 | Cloud. During the build, a bot runs the `download_android_tools.py` script that |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 87 | downloads the required version of the Android SDK into `dev/bots/android_tools`. |
Yegor | 107c812 | 2018-01-05 12:40:17 -0800 | [diff] [blame] | 88 | |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 89 | To check which components are currently installed, download the current SDK |
| 90 | stored 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 |
Yegor | 107c812 | 2018-01-05 12:40:17 -0800 | [diff] [blame] | 92 | components need to be updated or installed, follow the steps below: |
Michael Goderbauer | 3addac5 | 2017-02-06 16:06:35 -0800 | [diff] [blame] | 93 | |
Ian Hickson | cf2fba7 | 2018-11-06 13:41:09 -0800 | [diff] [blame] | 94 | #### How to update Android SDK on Google Cloud Storage |
Michael Goderbauer | 3addac5 | 2017-02-06 16:06:35 -0800 | [diff] [blame] | 95 | |
| 96 | 1. Run Android SDK Manager and update packages |
| 97 | `$ dev/bots/android_tools/sdk/tools/android update sdk` |
| 98 | Use `android.bat` on Windows. |
| 99 | |
Yegor | 107c812 | 2018-01-05 12:40:17 -0800 | [diff] [blame] | 100 | 2. Use the UI to choose the packages you want to install and/or update. |
Michael Goderbauer | 3addac5 | 2017-02-06 16:06:35 -0800 | [diff] [blame] | 101 | |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 102 | 3. 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`. |
Yegor | 107c812 | 2018-01-05 12:40:17 -0800 | [diff] [blame] | 109 | |
Dan Field | 4be4830 | 2019-03-08 09:25:13 -0800 | [diff] [blame] | 110 | 4. 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 |
Yegor | 107c812 | 2018-01-05 12:40:17 -0800 | [diff] [blame] | 113 | accepted". |
| 114 | |
| 115 | 5. Run upload_android_tools.py -t sdk |
Michael Goderbauer | 3addac5 | 2017-02-06 16:06:35 -0800 | [diff] [blame] | 116 | `$ dev/bots/upload_android_tools.py -t sdk` |
| 117 | |
Ian Hickson | cf2fba7 | 2018-11-06 13:41:09 -0800 | [diff] [blame] | 118 | #### How to update Android NDK on Google Cloud Storage |
Michael Goderbauer | 3addac5 | 2017-02-06 16:06:35 -0800 | [diff] [blame] | 119 | |
| 120 | 1. Download a new NDK binary (e.g. android-ndk-r10e-linux-x86_64.bin) |
| 121 | 2. cd dev/bots/android_tools |
| 122 | `$ cd dev/bots/android_tools` |
| 123 | |
| 124 | 3. Remove the old ndk directory |
| 125 | `$ rm -rf ndk` |
| 126 | |
| 127 | 4. Run the new NDK binary file |
| 128 | `$ ./android-ndk-r10e-linux-x86_64.bin` |
| 129 | |
| 130 | 5. Rename the extracted directory to ndk |
| 131 | `$ mv android-ndk-r10e ndk` |
| 132 | |
| 133 | 6. Run upload_android_tools.py -t ndk |
| 134 | `$ cd ../..` |
| 135 | `$ dev/bots/upload_android_tools.py -t ndk` |
TL Lee | e2167b9 | 2018-09-06 17:16:22 -0400 | [diff] [blame] | 136 | |
Ian Hickson | cf2fba7 | 2018-11-06 13:41:09 -0800 | [diff] [blame] | 137 | |
TL Lee | e2167b9 | 2018-09-06 17:16:22 -0400 | [diff] [blame] | 138 | ## Flutter codelabs build test |
| 139 | |
Ian Hickson | 989cf18 | 2018-09-22 02:02:56 -0700 | [diff] [blame] | 140 | The Flutter codelabs exercise Material Components in the form of a |
| 141 | demo application. The code for the codelabs is similar to, but |
| 142 | distinct from, the code for the Shrine demo app in Flutter Gallery. |
| 143 | |
| 144 | The Flutter codelabs build test ensures that the final version of the |
| 145 | [Material Components for Flutter |
| 146 | Codelabs](https://github.com/material-components/material-components-flutter-codelabs) |
| 147 | can be built. This test serves as a smoke test for the Flutter |
Ian Hickson | cf2fba7 | 2018-11-06 13:41:09 -0800 | [diff] [blame] | 148 | framework and should not fail. If it does, please address any issues |
| 149 | in your PR and rerun the test. If you feel that the test failing is |
| 150 | not a direct result of changes made in your PR or that breaking this |
| 151 | test is absolutely necessary, escalate this issue by [submitting an |
Ian Hickson | 989cf18 | 2018-09-22 02:02:56 -0700 | [diff] [blame] | 152 | issue](https://github.com/material-components/material-components-flutter-codelabs/issues/new?title=%5BURGENT%5D%20Flutter%20Framework%20breaking%20PR) |
TL Lee | e2167b9 | 2018-09-06 17:16:22 -0400 | [diff] [blame] | 153 | to the MDC-Flutter Team. |
Greg Spencer | c99ed8f | 2019-05-24 08:56:52 -0700 | [diff] [blame] | 154 | |
| 155 | ## Unpublishing published archives |
| 156 | |
| 157 | Flutter downloadable archives are built for each release by our continuous |
| 158 | integration systems using the [`prepare_package.dart`](prepare_package.dart) |
| 159 | script, but if something goes very wrong, and a release is published that wasn't |
| 160 | intended to be published, the [`unpublish_package.dart`](unpublish_package.dart) |
| 161 | script may be used to remove the package or packages from the channels in which |
| 162 | they were published. |
| 163 | |
| 164 | For example To remove a published package corresponding to the git hash |
| 165 | `d444a455de87a2e40b7f576dc12ffd9ab82fd491`, first do a dry run of the script to |
| 166 | see what it will do: |
| 167 | |
| 168 | ``` |
James Lin | 6f7630a | 2019-08-09 15:26:03 -0700 | [diff] [blame] | 169 | $ dart ./unpublish_package.dart --temp_dir=/tmp/foo --revision d444a455de87a2e40b7f576dc12ffd9ab82fd491 |
Greg Spencer | c99ed8f | 2019-05-24 08:56:52 -0700 | [diff] [blame] | 170 | ``` |
| 171 | |
| 172 | And once you've verified the output of the dry run to be sure it is what you |
| 173 | want to do, run: |
| 174 | |
| 175 | ``` |
James Lin | 6f7630a | 2019-08-09 15:26:03 -0700 | [diff] [blame] | 176 | $ dart ./unpublish_package.dart --confirm --temp_dir=/tmp/foo --revision d444a455de87a2e40b7f576dc12ffd9ab82fd491 |
Greg Spencer | c99ed8f | 2019-05-24 08:56:52 -0700 | [diff] [blame] | 177 | ``` |
| 178 | |
Yazeed Al-Khalaf | d41b1fb | 2020-07-23 04:23:47 +0300 | [diff] [blame] | 179 | and it will perform the actions. You will of course need to have access |
| 180 | to the cloud storage server and have `gsutil` installed to perform this |
Greg Spencer | c99ed8f | 2019-05-24 08:56:52 -0700 | [diff] [blame] | 181 | operation. Only runs on Linux or macOS systems. |
| 182 | |
James Lin | 6f7630a | 2019-08-09 15:26:03 -0700 | [diff] [blame] | 183 | See `dart ./unpublish_package.dart --help` for more details. |
Greg Spencer | c99ed8f | 2019-05-24 08:56:52 -0700 | [diff] [blame] | 184 | |
| 185 | Once the package is unpublished, it will not be available from the website for |
| 186 | download, and will not be rebuilt (even though there is a tagged revision in the |
| 187 | repo still) unless someone forces the packaging build to run again at that |
| 188 | revision to rebuild the package. |