• Home
Name Date Size #Lines LOC

..--

cipd/06-Sep-2024-11466

config/06-Sep-2024-1,2751,180

recipe_modules/crosvm/06-Sep-2024-3,2293,118

recipes/06-Sep-2024-1,002887

.gitignoreD06-Sep-202413 21

README.mdD06-Sep-20244.5 KiB13289

README.recipes.mdD06-Sep-202412.8 KiB193114

recipes.pyD06-Sep-20249 KiB276177

README.md

1# Luci Infrastructure
2
3This directory contains the configuration and build recipes run by our luci infrastructure for CI
4and presubmit testing.
5
6Note: Luci applies config and recipes changes asynchronously. Do not submit changes to this
7directory in the same commit as changes to other crosvm source.
8
9## Recipes
10
11### Recipe Documentation
12
13A few links to relevant documentation needed to write recipes:
14
15- [Recipe Engine](https://chromium.googlesource.com/infra/luci/recipes-py.git/+/HEAD/README.recipes.md)
16- [Depot Tools Recipes](https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/HEAD/recipes/README.recipes.md))
17- [ChromiumOS Recipes](https://chromium.googlesource.com/chromiumos/infra/recipes.git/+/HEAD/README.recipes.md)
18
19Luci also provides a
20[User Guide](https://chromium.googlesource.com/infra/luci/recipes-py/+/master/doc/user_guide.md) and
21[Walkthrough](https://chromium.googlesource.com/infra/luci/recipes-py/+/refs/heads/main/doc/walkthrough.md)
22for getting started with recipes.
23
24For writing tests, documentation can be found in the
25[Recipe test API](https://chromium.googlesource.com/infra/luci/recipes-py/+/HEAD/recipe_engine/recipe_test_api.py)
26and
27[Post Process API](https://chromium.googlesource.com/infra/luci/recipes-py/+/HEAD/recipe_engine/post_process.py)
28
29### Running recipe tests
30
31Recipes must have 100% code coverage to have tests pass. Tests can be run with:
32
33```
34cd infra && ./recipes.py test run
35```
36
37Most tests execute a few example invocations, record the commands that would be executed and compare
38them to the json files in `*.expected`. This allows developers to catch unwanted side-effects of
39their changes.
40
41To regenerate the expectation files, run:
42
43```
44cd infra && ./recipes.py test train
45```
46
47Then verify the `git diff` to make sure all changes to outcomes are intentional.
48
49### Testing recipes locally
50
51We try to build our recipes to work well locally, so for example build_linux.py can be invoked in
52the recipe engine via:
53
54```
55cd infra && ./recipes.py run build_linux
56```
57
58When run locally, recipes that check out crosvm, will run against the current HEAD of the main
59branch.
60
61The recipe will run in the local `infra/.recipe_deps/recipe_engine/workdir` directory and is
62preserved between runs in the same way data is preserved on bots, so incremental builds or the use
63of cached files can be tested.
64
65### Testing recipes on a bot (Googlers only)
66
67Note: See internal [crosvm/infra](http://go/crosvm/infra) documentation on access control.
68
69Some things cannot be tested locally and need to be run on one of our build bots. This can be done
70with the [led](http://go/luci-how-to-led) tool.
71
72Commonly used led commands are:
73
74- `led get-builder $NAME` will download and output the job template for that builder.
75- `led get-build $BBID` will download the job definition of a previous build.
76- `led edit-recipe-bundle` will update the job to use your local version recipes
77- `led edit-cr-cl` will update the job to run on a gerrit change
78- `led launch` launches a new job using the input job definition.
79
80Important: Changes to recipes are applied separately from changes to crosvm code.
81
82#### Testing recipe changes on post-submit builders
83
84To test a local recipe change, you can launch a post-submit build using `led`. First `git commit`
85your recipe changes locally, then combine the led commands to:
86
87```
88led get-builder luci.crosvm.ci:linux_x86_64
89 | led-edit-recipe-bundle
90 | led launch
91```
92
93This will run the `linux_x86_64` builder on the current `main` revision of crosvm using the local
94version of recipes.
95
96Important: Changes to crosvm source outside of recipes will not be part of the build.
97
98#### Testing recipe and source changes on pre-submit builders
99
100If we want to test a combination of both recipe and source changes, we can test those on a
101pre-submit builder, which patch in a gerrit change to test.
102
103We can specify that gerrit change via `led edit-cr-cl`.
104
105So to test, first `git commit` and `./tools/cl upload` your local changes. Then build a job
106definition to run:
107
108```
109led get-builder luci.crosvm.try:linux_x86_64
110 | led-edit-recipe-bundle
111 | led-edit-cr-cl $GERRIT_URL
112 | led launch
113```
114
115This will launch a presubmit builder using the local version of recipes, and runs it on the gerrit
116change at $GERRIT_URL.
117
118#### Testing a new recipe
119
120This is a little tricker, but you can change the recipe name that is launched by `led`. So you can:
121
122```
123led get-builder luci.crosvm.ci:linux_x86_64 > job.json
124```
125
126Then edit the `job.json` file to use the newly added recipe, and launch the job using the local
127version of recipes.
128
129```
130cat job.json | led-edit-recipe-bundle | led launch
131```
132

README.recipes.md

1<!--- AUTOGENERATED BY `./recipes.py test train` -->
2# Repo documentation for [crosvm](https://chromium.googlesource.com/crosvm/crosvm.git)
3## Table of Contents
4
5**[Recipe Modules](#Recipe-Modules)**
6  * [crosvm](#recipe_modules-crosvm)
7
8**[Recipes](#Recipes)**
9  * [build_chromeos_hatch](#recipes-build_chromeos_hatch)
10  * [build_docs](#recipes-build_docs)
11  * [build_linux](#recipes-build_linux)
12  * [build_windows](#recipes-build_windows)
13  * [crosvm:examples/container_build_context](#recipes-crosvm_examples_container_build_context)
14  * [crosvm:examples/cros_container_build_context](#recipes-crosvm_examples_cros_container_build_context)
15  * [crosvm:examples/host_build_context](#recipes-crosvm_examples_host_build_context)
16  * [crosvm:examples/source_context](#recipes-crosvm_examples_source_context)
17  * [health_check](#recipes-health_check)
18  * [push_to_github](#recipes-push_to_github)
19  * [update_chromeos_merges](#recipes-update_chromeos_merges)
20## Recipe Modules
21
22### *recipe_modules* / [crosvm](/infra/recipe_modules/crosvm)
23
24[DEPS](/infra/recipe_modules/crosvm/__init__.py#7): [depot\_tools/bot\_update][depot_tools/recipe_modules/bot_update], [depot\_tools/gclient][depot_tools/recipe_modules/gclient], [depot\_tools/git][depot_tools/recipe_modules/git], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
25
26
27#### **class [CrosvmApi](/infra/recipe_modules/crosvm/api.py#11)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
28
29Crosvm specific functionality shared between recipes.
30
31&emsp; **@property**<br>&mdash; **def [builder\_cache](/infra/recipe_modules/crosvm/api.py#43)(self):**
32
33Dedicated cache directory for each builder.
34
35Luci will try to run each builder on the same bot as previously to keep this cache present.
36
37&emsp; **@property**<br>&mdash; **def [cargo\_home](/infra/recipe_modules/crosvm/api.py#24)(self):**
38
39CARGO_HOME is cached between runs.
40
41&emsp; **@property**<br>&mdash; **def [cargo\_target\_dir](/infra/recipe_modules/crosvm/api.py#29)(self):**
42
43CARGO_TARGET_DIR is cleaned up between runs
44
45&mdash; **def [container\_build\_context](/infra/recipe_modules/crosvm/api.py#62)(self):**
46
47Prepares source and system to build crosvm via dev container.
48
49Usage:
50    with api.crosvm.container_build_context():
51        api.crosvm.step_in_container("build crosvm", ["cargo build"])
52
53&mdash; **def [cros\_container\_build\_context](/infra/recipe_modules/crosvm/api.py#79)(self):**
54
55Prepares source and system to build crosvm via cros container.
56
57Usage:
58    with api.crosvm.cros_container_build_context():
59        api.crosvm.step_in_container("build crosvm", ["cargo build"], cros=True)
60
61&emsp; **@property**<br>&mdash; **def [dev\_container\_cache](/infra/recipe_modules/crosvm/api.py#39)(self):**
62
63&mdash; **def [get\_git\_sha](/infra/recipe_modules/crosvm/api.py#186)(self):**
64
65&mdash; **def [host\_build\_context](/infra/recipe_modules/crosvm/api.py#113)(self):**
66
67Prepares source and system to build crosvm directly on the host.
68
69This will install the required rust version via rustup. However no further dependencies
70are installed.
71
72Usage:
73    with api.crosvm.host_build_context():
74        api.step("build crosvm", ["cargo build"])
75
76&emsp; **@property**<br>&mdash; **def [local\_bin](/infra/recipe_modules/crosvm/api.py#34)(self):**
77
78Directory used to install local tools required by the build.
79
80&mdash; **def [prepare\_git](/infra/recipe_modules/crosvm/api.py#161)(self):**
81
82&emsp; **@property**<br>&mdash; **def [rustup\_home](/infra/recipe_modules/crosvm/api.py#19)(self):**
83
84RUSTUP_HOME is cached between runs.
85
86&mdash; **def [source\_context](/infra/recipe_modules/crosvm/api.py#52)(self):**
87
88Updates the source to the revision to be tested and drops into the source directory.
89
90Use when no build commands are needed.
91
92&emsp; **@property**<br>&mdash; **def [source\_dir](/infra/recipe_modules/crosvm/api.py#14)(self):**
93
94Where the crosvm source will be checked out.
95
96&mdash; **def [step\_in\_container](/infra/recipe_modules/crosvm/api.py#144)(self, step_name, command, cros=False, \*\*kwargs):**
97
98Runs a luci step inside the crosvm dev container.
99
100&mdash; **def [upload\_coverage](/infra/recipe_modules/crosvm/api.py#194)(self, filename):**
101## Recipes
102
103### *recipes* / [build\_chromeos\_hatch](/infra/recipes/build_chromeos_hatch.py)
104
105[DEPS](/infra/recipes/build_chromeos_hatch.py#7): [crosvm](#recipe_modules-crosvm), [depot\_tools/depot\_tools][depot_tools/recipe_modules/depot_tools], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step]
106
107
108&mdash; **def [RunSteps](/infra/recipes/build_chromeos_hatch.py#17)(api):**
109### *recipes* / [build\_docs](/infra/recipes/build_docs.py)
110
111[DEPS](/infra/recipes/build_docs.py#7): [crosvm](#recipe_modules-crosvm), [depot\_tools/gsutil][depot_tools/recipe_modules/gsutil], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/step][recipe_engine/recipe_modules/step]
112
113
114&mdash; **def [RunSteps](/infra/recipes/build_docs.py#20)(api):**
115
116Builds crosvm mdbook and api docs, then uploads them to GCS.
117
118This recipe requires ambient luci authentication. To test locally run:
119   $ luci-auth context ./infra/recipes.py run build_docs
120### *recipes* / [build\_linux](/infra/recipes/build_linux.py)
121
122[DEPS](/infra/recipes/build_linux.py#11): [crosvm](#recipe_modules-crosvm), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
123
124
125&mdash; **def [RunSteps](/infra/recipes/build_linux.py#74)(api, properties):**
126
127&mdash; **def [collect\_binary\_sizes](/infra/recipes/build_linux.py#24)(api, properties):**
128### *recipes* / [build\_windows](/infra/recipes/build_windows.py)
129
130[DEPS](/infra/recipes/build_windows.py#7): [crosvm](#recipe_modules-crosvm), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step]
131
132
133&mdash; **def [RunSteps](/infra/recipes/build_windows.py#16)(api):**
134### *recipes* / [crosvm:examples/container\_build\_context](/infra/recipe_modules/crosvm/examples/container_build_context.py)
135
136[DEPS](/infra/recipe_modules/crosvm/examples/container_build_context.py#7): [crosvm](#recipe_modules-crosvm)
137
138
139&mdash; **def [RunSteps](/infra/recipe_modules/crosvm/examples/container_build_context.py#12)(api):**
140### *recipes* / [crosvm:examples/cros\_container\_build\_context](/infra/recipe_modules/crosvm/examples/cros_container_build_context.py)
141
142[DEPS](/infra/recipe_modules/crosvm/examples/cros_container_build_context.py#7): [crosvm](#recipe_modules-crosvm)
143
144
145&mdash; **def [RunSteps](/infra/recipe_modules/crosvm/examples/cros_container_build_context.py#12)(api):**
146### *recipes* / [crosvm:examples/host\_build\_context](/infra/recipe_modules/crosvm/examples/host_build_context.py)
147
148[DEPS](/infra/recipe_modules/crosvm/examples/host_build_context.py#7): [crosvm](#recipe_modules-crosvm), [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/step][recipe_engine/recipe_modules/step]
149
150
151&mdash; **def [RunSteps](/infra/recipe_modules/crosvm/examples/host_build_context.py#14)(api):**
152### *recipes* / [crosvm:examples/source\_context](/infra/recipe_modules/crosvm/examples/source_context.py)
153
154[DEPS](/infra/recipe_modules/crosvm/examples/source_context.py#7): [crosvm](#recipe_modules-crosvm), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket]
155
156
157&mdash; **def [RunSteps](/infra/recipe_modules/crosvm/examples/source_context.py#13)(api):**
158### *recipes* / [health\_check](/infra/recipes/health_check.py)
159
160[DEPS](/infra/recipes/health_check.py#7): [crosvm](#recipe_modules-crosvm), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
161
162
163&mdash; **def [RunSteps](/infra/recipes/health_check.py#17)(api):**
164### *recipes* / [push\_to\_github](/infra/recipes/push_to_github.py)
165
166[DEPS](/infra/recipes/push_to_github.py#7): [crosvm](#recipe_modules-crosvm), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/file][recipe_engine/recipe_modules/file], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
167
168
169&mdash; **def [RunSteps](/infra/recipes/push_to_github.py#18)(api):**
170### *recipes* / [update\_chromeos\_merges](/infra/recipes/update_chromeos_merges.py)
171
172[DEPS](/infra/recipes/update_chromeos_merges.py#7): [crosvm](#recipe_modules-crosvm), [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/step][recipe_engine/recipe_modules/step]
173
174
175&mdash; **def [RunSteps](/infra/recipes/update_chromeos_merges.py#14)(api):**
176
177[depot_tools/recipe_modules/bot_update]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/5a584405cae6e1fd08a6054ce9ba61b645b4d591/recipes/README.recipes.md#recipe_modules-bot_update
178[depot_tools/recipe_modules/depot_tools]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/5a584405cae6e1fd08a6054ce9ba61b645b4d591/recipes/README.recipes.md#recipe_modules-depot_tools
179[depot_tools/recipe_modules/gclient]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/5a584405cae6e1fd08a6054ce9ba61b645b4d591/recipes/README.recipes.md#recipe_modules-gclient
180[depot_tools/recipe_modules/git]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/5a584405cae6e1fd08a6054ce9ba61b645b4d591/recipes/README.recipes.md#recipe_modules-git
181[depot_tools/recipe_modules/gsutil]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/5a584405cae6e1fd08a6054ce9ba61b645b4d591/recipes/README.recipes.md#recipe_modules-gsutil
182[recipe_engine/recipe_modules/buildbucket]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-buildbucket
183[recipe_engine/recipe_modules/cipd]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-cipd
184[recipe_engine/recipe_modules/context]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-context
185[recipe_engine/recipe_modules/file]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-file
186[recipe_engine/recipe_modules/json]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-json
187[recipe_engine/recipe_modules/path]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-path
188[recipe_engine/recipe_modules/platform]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-platform
189[recipe_engine/recipe_modules/properties]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-properties
190[recipe_engine/recipe_modules/raw_io]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-raw_io
191[recipe_engine/recipe_modules/step]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/README.recipes.md#recipe_modules-step
192[recipe_engine/wkt/RecipeApi]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/f967fa68fd4bd3e76140de7ffa449fa3a45a72f4/recipe_engine/recipe_api.py#471
193