|
1 |
| -############################################################# |
2 |
| -# WARNING: automatically generated file, DO NOT CHANGE! # |
3 |
| -############################################################# |
4 |
| - |
5 |
| -# This file was automatically generated by the expand-yaml-anchors tool. The |
6 |
| -# source file that generated this one is: |
7 |
| -# |
8 |
| -# src/ci/github-actions/ci.yml |
9 |
| -# |
10 |
| -# Once you make changes to that file you need to run: |
11 |
| -# |
12 |
| -# ./x.py run src/tools/expand-yaml-anchors/ |
| 1 | +# This file defines our primary CI workflow that runs on pull requests |
| 2 | +# and also on pushes to special branches (auto, try). |
13 | 3 | #
|
14 |
| -# The CI build will fail if the tool is not run after changes to this file. |
| 4 | +# The actual definition of the executed jobs is calculated by a Python |
| 5 | +# script located at src/ci/github-actions/calculate-job-matrix.py, which |
| 6 | +# uses job definition data from src/ci/github-actions/jobs.yml. |
| 7 | +# You should primarily modify the `jobs.yml` file if you want to modify |
| 8 | +# what jobs are executed in CI. |
15 | 9 |
|
16 |
| ---- |
17 | 10 | name: CI
|
18 |
| -"on": |
| 11 | +on: |
19 | 12 | push:
|
20 | 13 | branches:
|
21 | 14 | - auto
|
22 | 15 | - try
|
23 | 16 | - try-perf
|
24 | 17 | - automation/bors/try
|
25 |
| - - master |
26 | 18 | pull_request:
|
27 | 19 | branches:
|
28 | 20 | - "**"
|
| 21 | + |
29 | 22 | permissions:
|
30 | 23 | contents: read
|
31 | 24 | packages: write
|
| 25 | + |
32 | 26 | defaults:
|
33 | 27 | run:
|
| 28 | + # On Linux, macOS, and Windows, use the system-provided bash as the default |
| 29 | + # shell. (This should only make a difference on Windows, where the default |
| 30 | + # shell is PowerShell.) |
34 | 31 | shell: bash
|
| 32 | + |
35 | 33 | concurrency:
|
36 |
| - group: "${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}" |
| 34 | + # For a given workflow, if we push to the same branch, cancel all previous builds on that branch. |
| 35 | + # We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which |
| 36 | + # are all triggered on the same branch, but which should be able to run concurrently. |
| 37 | + group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }} |
37 | 38 | cancel-in-progress: true
|
| 39 | +env: |
| 40 | + TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate" |
38 | 41 | jobs:
|
| 42 | + # The job matrix for `calculate_matrix` is defined in src/ci/github-actions/jobs.yml. |
| 43 | + # It calculates which jobs should be executed, based on the data of the ${{ github }} context. |
| 44 | + # If you want to modify CI jobs, take a look at src/ci/github-actions/jobs.yml. |
39 | 45 | calculate_matrix:
|
40 | 46 | name: Calculate job matrix
|
41 | 47 | runs-on: ubuntu-latest
|
42 | 48 | outputs:
|
43 |
| - jobs: "${{ steps.jobs.outputs.jobs }}" |
| 49 | + jobs: ${{ steps.jobs.outputs.jobs }} |
| 50 | + run_type: ${{ steps.jobs.outputs.run_type }} |
44 | 51 | steps:
|
45 | 52 | - name: Checkout the source code
|
46 | 53 | uses: actions/checkout@v4
|
47 | 54 | - name: Calculate the CI job matrix
|
48 | 55 | run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT
|
49 | 56 | id: jobs
|
50 | 57 | job:
|
51 |
| - name: "${{ matrix.name }}" |
52 |
| - needs: |
53 |
| - - calculate_matrix |
| 58 | + name: ${{ matrix.name }} |
| 59 | + needs: [ calculate_matrix ] |
| 60 | + runs-on: "${{ matrix.os }}" |
| 61 | + defaults: |
| 62 | + run: |
| 63 | + shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }} |
| 64 | + timeout-minutes: 600 |
54 | 65 | env:
|
55 |
| - CI_JOB_NAME: "${{ matrix.image }}" |
| 66 | + CI_JOB_NAME: ${{ matrix.image }} |
56 | 67 | CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
|
57 |
| - HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}" |
58 |
| - DOCKER_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 68 | + # commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs. |
| 69 | + HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} |
| 70 | + DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
59 | 71 | SCCACHE_BUCKET: rust-lang-ci-sccache2
|
60 |
| - TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate" |
61 | 72 | CACHE_DOMAIN: ci-caches.rust-lang.org
|
62 |
| - continue-on-error: "${{ matrix.continue_on_error || false }}" |
| 73 | + continue-on-error: ${{ matrix.continue_on_error || false }} |
63 | 74 | strategy:
|
64 | 75 | matrix:
|
65 |
| - include: "${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}" |
66 |
| - if: "fromJSON(needs.calculate_matrix.outputs.jobs)[0] != null" |
67 |
| - defaults: |
68 |
| - run: |
69 |
| - shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}" |
70 |
| - timeout-minutes: 600 |
71 |
| - runs-on: "${{ matrix.os }}" |
| 76 | + # Check the `calculate_matrix` job to see how is the matrix defined. |
| 77 | + include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }} |
| 78 | + # GitHub Actions fails the workflow if an empty list of jobs is provided to |
| 79 | + # the workflow, so we need to skip this job if nothing was produced by |
| 80 | + # the Python script. |
| 81 | + # |
| 82 | + # Unfortunately checking whether a list is empty is not possible in a nice |
| 83 | + # way due to GitHub Actions expressions limits. |
| 84 | + # This hack is taken from https://github.com/ferrocene/ferrocene/blob/d43edc6b7697cf1719ec1c17c54904ab94825763/.github/workflows/release.yml#L75-L82 |
| 85 | + if: fromJSON(needs.calculate_matrix.outputs.jobs)[0] != null |
72 | 86 | steps:
|
73 |
| - - if: "contains(matrix.os, 'windows')" |
| 87 | + - if: contains(matrix.os, 'windows') |
74 | 88 |
|
75 | 89 | with:
|
76 |
| - msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}" |
| 90 | + # i686 jobs use mingw32. x86_64 and cross-compile jobs use mingw64. |
| 91 | + msystem: ${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }} |
| 92 | + # don't try to download updates for already installed packages |
77 | 93 | update: false
|
| 94 | + # don't try to use the msys that comes built-in to the github runner, |
| 95 | + # so we can control what is installed (i.e. not python) |
78 | 96 | release: true
|
| 97 | + # Inherit the full path from the Windows environment, with MSYS2's */bin/ |
| 98 | + # dirs placed in front. This lets us run Windows-native Python etc. |
79 | 99 | path-type: inherit
|
80 |
| - install: "make dos2unix diffutils\n" |
| 100 | + install: > |
| 101 | + make |
| 102 | + dos2unix |
| 103 | + diffutils |
| 104 | +
|
81 | 105 | - name: disable git crlf conversion
|
82 | 106 | run: git config --global core.autocrlf false
|
| 107 | + |
83 | 108 | - name: checkout the source code
|
84 | 109 | uses: actions/checkout@v4
|
85 | 110 | with:
|
86 | 111 | fetch-depth: 2
|
| 112 | + |
| 113 | + # Rust Log Analyzer can't currently detect the PR number of a GitHub |
| 114 | + # Actions build on its own, so a hint in the log message is needed to |
| 115 | + # point it in the right direction. |
87 | 116 | - name: configure the PR in which the error message will be posted
|
88 |
| - run: "echo \"[CI_PR_NUMBER=$num]\"" |
| 117 | + run: echo "[CI_PR_NUMBER=$num]" |
89 | 118 | env:
|
90 |
| - num: "${{ github.event.number }}" |
91 |
| - if: "success() && github.event_name == 'pull_request'" |
| 119 | + num: ${{ github.event.number }} |
| 120 | + if: needs.calculate_matrix.outputs.run_type == 'pr' |
| 121 | + |
92 | 122 | - name: add extra environment variables
|
93 | 123 | run: src/ci/scripts/setup-environment.sh
|
94 | 124 | env:
|
95 |
| - EXTRA_VARIABLES: "${{ toJson(matrix.env) }}" |
| 125 | + # Since it's not possible to merge `${{ matrix.env }}` with the other |
| 126 | + # variables in `job.<name>.env`, the variables defined in the matrix |
| 127 | + # are passed to the `setup-environment.sh` script encoded in JSON, |
| 128 | + # which then uses log commands to actually set them. |
| 129 | + EXTRA_VARIABLES: ${{ toJson(matrix.env) }} |
| 130 | + |
96 | 131 | - name: ensure the channel matches the target branch
|
97 | 132 | run: src/ci/scripts/verify-channel.sh
|
| 133 | + |
98 | 134 | - name: collect CPU statistics
|
99 | 135 | run: src/ci/scripts/collect-cpu-stats.sh
|
| 136 | + |
100 | 137 | - name: show the current environment
|
101 | 138 | run: src/ci/scripts/dump-environment.sh
|
| 139 | + |
102 | 140 | - name: install awscli
|
103 | 141 | run: src/ci/scripts/install-awscli.sh
|
| 142 | + |
104 | 143 | - name: install sccache
|
105 | 144 | run: src/ci/scripts/install-sccache.sh
|
| 145 | + |
106 | 146 | - name: select Xcode
|
107 | 147 | run: src/ci/scripts/select-xcode.sh
|
| 148 | + |
108 | 149 | - name: install clang
|
109 | 150 | run: src/ci/scripts/install-clang.sh
|
| 151 | + |
110 | 152 | - name: install tidy
|
111 | 153 | run: src/ci/scripts/install-tidy.sh
|
| 154 | + |
112 | 155 | - name: install WIX
|
113 | 156 | run: src/ci/scripts/install-wix.sh
|
| 157 | + |
114 | 158 | - name: disable git crlf conversion
|
115 | 159 | run: src/ci/scripts/disable-git-crlf-conversion.sh
|
| 160 | + |
116 | 161 | - name: checkout submodules
|
117 | 162 | run: src/ci/scripts/checkout-submodules.sh
|
| 163 | + |
118 | 164 | - name: install MSYS2
|
119 | 165 | run: src/ci/scripts/install-msys2.sh
|
| 166 | + |
120 | 167 | - name: install MinGW
|
121 | 168 | run: src/ci/scripts/install-mingw.sh
|
| 169 | + |
122 | 170 | - name: install ninja
|
123 | 171 | run: src/ci/scripts/install-ninja.sh
|
| 172 | + |
124 | 173 | - name: enable ipv6 on Docker
|
125 | 174 | run: src/ci/scripts/enable-docker-ipv6.sh
|
| 175 | + |
| 176 | + # Disable automatic line ending conversion (again). On Windows, when we're |
| 177 | + # installing dependencies, something switches the git configuration directory or |
| 178 | + # re-enables autocrlf. We've not tracked down the exact cause -- and there may |
| 179 | + # be multiple -- but this should ensure submodules are checked out with the |
| 180 | + # appropriate line endings. |
126 | 181 | - name: disable git crlf conversion
|
127 | 182 | run: src/ci/scripts/disable-git-crlf-conversion.sh
|
| 183 | + |
128 | 184 | - name: ensure line endings are correct
|
129 | 185 | run: src/ci/scripts/verify-line-endings.sh
|
| 186 | + |
130 | 187 | - name: ensure backported commits are in upstream branches
|
131 | 188 | run: src/ci/scripts/verify-backported-commits.sh
|
| 189 | + |
132 | 190 | - name: ensure the stable version number is correct
|
133 | 191 | run: src/ci/scripts/verify-stable-version-number.sh
|
| 192 | + |
134 | 193 | - name: run the build
|
| 194 | + # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs. |
135 | 195 | run: src/ci/scripts/run-build-from-ci.sh 2>&1
|
136 | 196 | env:
|
137 |
| - AWS_ACCESS_KEY_ID: "${{ env.CACHES_AWS_ACCESS_KEY_ID }}" |
138 |
| - AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}" |
139 |
| - TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" |
| 197 | + AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }} |
| 198 | + AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }} |
| 199 | + TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} |
| 200 | + |
140 | 201 | - name: create github artifacts
|
141 | 202 | run: src/ci/scripts/create-doc-artifacts.sh
|
| 203 | + |
142 | 204 | - name: upload artifacts to github
|
143 | 205 | uses: actions/upload-artifact@v4
|
144 | 206 | with:
|
145 |
| - name: "${{ env.DOC_ARTIFACT_NAME }}" |
| 207 | + # name is set in previous step |
| 208 | + name: ${{ env.DOC_ARTIFACT_NAME }} |
146 | 209 | path: obj/artifacts/doc
|
147 | 210 | if-no-files-found: ignore
|
148 | 211 | retention-days: 5
|
| 212 | + |
149 | 213 | - name: upload artifacts to S3
|
150 | 214 | run: src/ci/scripts/upload-artifacts.sh
|
151 | 215 | env:
|
152 |
| - AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" |
153 |
| - AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" |
154 |
| - if: "success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" |
155 |
| - master: |
156 |
| - name: master |
| 216 | + AWS_ACCESS_KEY_ID: ${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }} |
| 217 | + AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }} |
| 218 | + # Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy |
| 219 | + # builders *should* have the AWS credentials available. Still, explicitly |
| 220 | + # adding the condition is helpful as this way CI will not silently skip |
| 221 | + # deploying artifacts from a dist builder if the variables are misconfigured, |
| 222 | + # erroring about invalid credentials instead. |
| 223 | + if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1' |
| 224 | + |
| 225 | + # This job isused to tell bors the final status of the build, as there is no practical way to detect |
| 226 | + # when a workflow is successful listening to webhooks only in our current bors implementation (homu). |
| 227 | + outcome: |
| 228 | + name: bors build finished |
157 | 229 | runs-on: ubuntu-latest
|
158 |
| - env: |
159 |
| - SCCACHE_BUCKET: rust-lang-ci-sccache2 |
160 |
| - DEPLOY_BUCKET: rust-lang-ci2 |
161 |
| - TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate" |
162 |
| - TOOLSTATE_ISSUES_API_URL: "https://api.github.com/repos/rust-lang/rust/issues" |
163 |
| - TOOLSTATE_PUBLISH: 1 |
164 |
| - CACHES_AWS_ACCESS_KEY_ID: AKIA46X5W6CZI5DHEBFL |
165 |
| - ARTIFACTS_AWS_ACCESS_KEY_ID: AKIA46X5W6CZN24CBO55 |
166 |
| - AWS_REGION: us-west-1 |
167 |
| - CACHE_DOMAIN: ci-caches.rust-lang.org |
168 |
| - if: "github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'rust-lang-ci/rust'" |
| 230 | + needs: [ calculate_matrix, job ] |
| 231 | + # !cancelled() executes the job regardless of whether the previous jobs passed or failed |
| 232 | + if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }} |
169 | 233 | steps:
|
170 | 234 | - name: checkout the source code
|
171 | 235 | uses: actions/checkout@v4
|
172 | 236 | with:
|
173 | 237 | fetch-depth: 2
|
| 238 | + # Calculate the exit status of the whole CI workflow. |
| 239 | + # If all dependent jobs were successful, this exits with 0 (and the outcome job continues successfully). |
| 240 | + # If a some dependent job has failed, this exits with 1. |
| 241 | + - name: calculate the correct exit status |
| 242 | + run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}' |
| 243 | + # Publish the toolstate if an auto build succeeds (just before push to master) |
174 | 244 | - name: publish toolstate
|
175 | 245 | run: src/ci/publish_toolstate.sh
|
176 | 246 | shell: bash
|
| 247 | + if: needs.calculate_matrix.outputs.run_type == 'auto' |
177 | 248 | env:
|
178 |
| - TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" |
179 |
| - try-success: |
180 |
| - needs: |
181 |
| - - job |
182 |
| - if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'" |
183 |
| - steps: |
184 |
| - - name: mark the job as a success |
185 |
| - run: exit 0 |
186 |
| - shell: bash |
187 |
| - name: bors build finished |
188 |
| - runs-on: ubuntu-latest |
189 |
| - try-failure: |
190 |
| - needs: |
191 |
| - - job |
192 |
| - if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'" |
193 |
| - steps: |
194 |
| - - name: mark the job as a failure |
195 |
| - run: exit 1 |
196 |
| - shell: bash |
197 |
| - name: bors build finished |
198 |
| - runs-on: ubuntu-latest |
199 |
| - auto-success: |
200 |
| - needs: |
201 |
| - - job |
202 |
| - if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'" |
203 |
| - steps: |
204 |
| - - name: mark the job as a success |
205 |
| - run: exit 0 |
206 |
| - shell: bash |
207 |
| - name: bors build finished |
208 |
| - runs-on: ubuntu-latest |
209 |
| - auto-failure: |
210 |
| - needs: |
211 |
| - - job |
212 |
| - if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'" |
213 |
| - steps: |
214 |
| - - name: mark the job as a failure |
215 |
| - run: exit 1 |
216 |
| - shell: bash |
217 |
| - name: bors build finished |
218 |
| - runs-on: ubuntu-latest |
| 249 | + TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} |
0 commit comments