You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/infra/docs/rustc-ci.md
+50-8Lines changed: 50 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,16 @@
1
1
# How the Rust CI works
2
2
3
+
Rust CI ensures that the master branch of rust-lang/rust is always in a valid state.
4
+
5
+
A developer submitting a pull request to rust-lang/rust, experiences the following:
6
+
* A small subset of tests and checks are run on each commit to catch common errors.
7
+
* When the PR is ready and approved, the "bors" tool enqueues a full CI run.
8
+
* The full run is either performed or the PR is "rolled up" with other changes.
9
+
* Eventually a CI run containing the changes from the PR is performed and either passes or fails with an error the developer must address.
10
+
3
11
## Which jobs we run
4
12
5
-
The `rust-lang/rust` repository uses GitHub Actions to test [all the other
13
+
The `rust-lang/rust` repository uses GitHub Actions to test [all the
6
14
platforms][platforms] we support. We currently have two kinds of jobs running
7
15
for each commit we want to merge to master:
8
16
@@ -12,15 +20,14 @@ for each commit we want to merge to master:
12
20
[rustup-toolchain-install-master] tool; The same builds are also used for
13
21
actual releases: our release process basically consists of copying those
14
22
artifacts from `rust-lang-ci2` to the production endpoint and signing them.
15
-
16
23
- Non-dist jobs run our full test suite on the platform, and the test suite of
17
24
all the tools we ship through rustup; The amount of stuff we test depends on
18
25
the platform (for example some tests are run only on Tier 1 platforms), and
19
26
some quicker platforms are grouped together on the same builder to avoid
20
27
wasting CI resources.
21
28
22
29
All the builds except those on macOS and Windows are executed inside that
23
-
platform’s custom Docker container. This has a lot of advantages for us:
30
+
platform’s custom [Docker container]. This has a lot of advantages for us:
24
31
25
32
- The build environment is consistent regardless of the changes of the
26
33
underlying image (switching from the trusty image to xenial was painless for
@@ -31,14 +38,20 @@ platform’s custom Docker container. This has a lot of advantages for us:
31
38
time thanks to Docker image caching.
32
39
- Users can run the same tests in the same environment locally by just running
33
40
`src/ci/docker/run.sh image-name`, which is awesome to debug failures.
41
+
- Forces the use of portable scripts to drive the CI process which keeps the CI fairly platform independent (i.e., we are not overly reliant on GitHub Actions).
42
+
43
+
The docker images prefixed with `dist-` are used for building artifacts while those without that prefix run tests and checks.
34
44
35
45
We also run tests for less common architectures (mainly Tier 2 and Tier 3
36
46
platforms) in CI. Since those platforms are not x86 we either run
37
47
everything inside QEMU or just cross-compile if we don’t want to run the tests
38
48
for that platform.
39
49
50
+
These builders are running on a special pool of builders set up and maintained for us by GitHub.
@@ -63,25 +76,39 @@ Since the merge commit is based on the latest master and only one can be tested
63
76
at the same time, when the results are green master is fast-forwarded to that
64
77
merge commit.
65
78
79
+
The `auto` branch and other branches used by bors live on a fork of the rust-lang/rust: [rust-lang-ci/rust]. This as originally done to some security limitations in GitHub Actions. These limitations have been addressed, but we've not yet done the work of removing the use of a fork.
80
+
66
81
Unfortunately testing a single PR at the time, combined with our long CI (~3
67
-
hours for a full run), means we can’t merge too many PRs in a single day, and a
82
+
hours for a full run)[^1], means we can’t merge too many PRs in a single day, and a
68
83
single failure greatly impacts our throughput for the day. The maximum number
69
84
of PRs we can merge in a day is around 8.
70
85
86
+
The large CI run times and requirement for a large builder pool is worth it because it:
87
+
* allows perf testing even at a later date
88
+
* allows bisection when bugs are discover later
89
+
* ensures release quality since if we're always releasing, we catch problems very early
90
+
91
+
Bors [runs on ecs](https://github.com/rust-lang/simpleinfra/blob/master/terraform/bors/app.tf) and uses a sqlite database running in a volume as storage.
92
+
93
+
[^1]: As of December 2022, the bottleneck are the macOS builders. Hopefully faster macOS builders will be coming soon!
Sometimes we need a working compiler build before approving a PR, usually for
@@ -91,6 +118,8 @@ a separate branch (`try`), and they basically work the same as normal builds,
91
118
without the actual merge at the end. Any number of try builds can happen at the
92
119
same time, even if there is a normal PR in progress.
93
120
121
+
You can see the CI configuration for try builds [here](https://github.com/rust-lang/rust/blob/9d46c7a3e69966782e163877151c1f0cea8b630a/src/ci/github-actions/ci.yml#L728-L741).
122
+
94
123
[perf]: https://perf.rust-lang.org
95
124
[crater]: https://github.com/rust-lang/crater
96
125
@@ -179,8 +208,8 @@ automatically, posting it on the PR.
179
208
The bot is not hardcoded to look for error strings, but was trained with a
180
209
bunch of build failures to recognize which lines are common between builds and
181
210
which are not. While the generated snippets can be weird sometimes, the bot is
182
-
pretty good at identifying the relevant lines even if it’s an error we never
183
-
saw before.
211
+
pretty good at identifying the relevant lines even if it’s an error we've never
@@ -206,5 +235,18 @@ few days before we promote nightly to beta.
206
235
207
236
More information is available in the [toolstate documentation].
208
237
238
+
### GitHub Actions Templating
239
+
240
+
GitHub Actions does not natively support templating which can cause configurations to be large and difficult to change. We use YAML anchors for templating and a custom tool, [`expand-yaml-anchors`], to expand [the template] into the CI configuration that [GitHub uses][ci config].
241
+
242
+
This templating language is fairly straightforward:
0 commit comments