|
1 | 1 | # This file defines our primary CI workflow that runs on pull requests |
2 | 2 | # and also on pushes to special branches (auto, try). |
3 | 3 | # |
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 |
| 4 | +# The actual definition of the executed jobs is calculated by the |
| 5 | +# `src/ci/citool` crate, which |
6 | 6 | # uses job definition data from src/ci/github-actions/jobs.yml. |
7 | 7 | # You should primarily modify the `jobs.yml` file if you want to modify |
8 | 8 | # what jobs are executed in CI. |
@@ -56,46 +56,32 @@ jobs: |
56 | 56 | - name: Calculate the CI job matrix |
57 | 57 | env: |
58 | 58 | COMMIT_MESSAGE: ${{ github.event.head_commit.message }} |
59 | | - run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT |
| 59 | + run: | |
| 60 | + cd src/ci/citool |
| 61 | + CARGO_INCREMENTAL=0 cargo test |
| 62 | + CARGO_INCREMENTAL=0 cargo run calculate-job-matrix >> $GITHUB_OUTPUT |
60 | 63 | id: jobs |
61 | 64 | job: |
62 | | - name: ${{ matrix.name }} |
| 65 | + name: ${{ matrix.full_name }} |
63 | 66 | needs: [ calculate_matrix ] |
64 | 67 | runs-on: "${{ matrix.os }}" |
65 | | - defaults: |
66 | | - run: |
67 | | - shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }} |
68 | 68 | timeout-minutes: 360 |
69 | 69 | env: |
70 | | - CI_JOB_NAME: ${{ matrix.image }} |
| 70 | + CI_JOB_NAME: ${{ matrix.name }} |
| 71 | + CI_JOB_DOC_URL: ${{ matrix.doc_url }} |
71 | 72 | CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse |
72 | 73 | # commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs. |
73 | 74 | HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} |
74 | 75 | DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
75 | 76 | SCCACHE_BUCKET: rust-lang-ci-sccache2 |
| 77 | + SCCACHE_REGION: us-west-1 |
76 | 78 | CACHE_DOMAIN: ci-caches.rust-lang.org |
77 | 79 | continue-on-error: ${{ matrix.continue_on_error || false }} |
78 | 80 | strategy: |
79 | 81 | matrix: |
80 | 82 | # Check the `calculate_matrix` job to see how is the matrix defined. |
81 | 83 | include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }} |
82 | 84 | steps: |
83 | | - - if: contains(matrix.os, 'windows') |
84 | | - uses: msys2/setup-msys2@v2.22.0 |
85 | | - with: |
86 | | - # i686 jobs use mingw32. x86_64 and cross-compile jobs use mingw64. |
87 | | - msystem: ${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }} |
88 | | - # don't try to download updates for already installed packages |
89 | | - update: false |
90 | | - # don't try to use the msys that comes built-in to the github runner, |
91 | | - # so we can control what is installed (i.e. not python) |
92 | | - release: true |
93 | | - # Inherit the full path from the Windows environment, with MSYS2's */bin/ |
94 | | - # dirs placed in front. This lets us run Windows-native Python etc. |
95 | | - path-type: inherit |
96 | | - install: > |
97 | | - make |
98 | | -
|
99 | 85 | - name: disable git crlf conversion |
100 | 86 | run: git config --global core.autocrlf false |
101 | 87 |
|
|
109 | 95 | # intensive jobs to run on free runners, which however also have |
110 | 96 | # less disk space. |
111 | 97 | - name: free up disk space |
112 | | - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be |
| 98 | + run: src/ci/scripts/free-disk-space.sh |
113 | 99 | if: matrix.free_disk |
114 | 100 |
|
115 | 101 | # Rust Log Analyzer can't currently detect the PR number of a GitHub |
@@ -192,9 +178,33 @@ jobs: |
192 | 178 | - name: ensure the stable version number is correct |
193 | 179 | run: src/ci/scripts/verify-stable-version-number.sh |
194 | 180 |
|
| 181 | + # Show the environment just before we run the build |
| 182 | + # This makes it easier to diagnose problems with the above install scripts. |
| 183 | + - name: show the current environment |
| 184 | + run: src/ci/scripts/dump-environment.sh |
| 185 | + |
| 186 | + # Pre-build citool before the following step uninstalls rustup |
| 187 | + # Build it into the build directory, to avoid modifying sources |
| 188 | + - name: build citool |
| 189 | + run: | |
| 190 | + cd src/ci/citool |
| 191 | + CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=../../../build/citool cargo build |
| 192 | +
|
195 | 193 | - name: run the build |
196 | | - # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs. |
197 | | - run: src/ci/scripts/run-build-from-ci.sh 2>&1 |
| 194 | + run: | |
| 195 | + set +e |
| 196 | + # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs. |
| 197 | + src/ci/scripts/run-build-from-ci.sh 2>&1 |
| 198 | + STATUS=$? |
| 199 | + set -e |
| 200 | +
|
| 201 | + if [[ "$STATUS" -ne 0 && -n "$CI_JOB_DOC_URL" ]]; then |
| 202 | + echo "****************************************************************************" |
| 203 | + echo "To find more information about this job, visit the following URL:" |
| 204 | + echo "$CI_JOB_DOC_URL" |
| 205 | + echo "****************************************************************************" |
| 206 | + fi |
| 207 | + exit ${STATUS} |
198 | 208 | env: |
199 | 209 | AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }} |
200 | 210 | AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }} |
@@ -228,16 +238,37 @@ jobs: |
228 | 238 | # erroring about invalid credentials instead. |
229 | 239 | if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1' |
230 | 240 |
|
| 241 | + - name: postprocess metrics into the summary |
| 242 | + # This step is not critical, and if some I/O problem happens, we don't want |
| 243 | + # to cancel the build. |
| 244 | + continue-on-error: true |
| 245 | + run: | |
| 246 | + if [ -f build/metrics.json ]; then |
| 247 | + METRICS=build/metrics.json |
| 248 | + elif [ -f obj/build/metrics.json ]; then |
| 249 | + METRICS=obj/build/metrics.json |
| 250 | + else |
| 251 | + echo "No metrics.json found" |
| 252 | + exit 0 |
| 253 | + fi |
| 254 | +
|
| 255 | + # Get closest bors merge commit |
| 256 | + PARENT_COMMIT=`git rev-list --author='bors <bors@rust-lang.org>' -n1 --first-parent HEAD^1` |
| 257 | +
|
| 258 | + ./build/citool/debug/citool postprocess-metrics \ |
| 259 | + --job-name ${CI_JOB_NAME} \ |
| 260 | + --parent ${PARENT_COMMIT} \ |
| 261 | + ${METRICS} >> ${GITHUB_STEP_SUMMARY} |
| 262 | +
|
231 | 263 | - name: upload job metrics to DataDog |
| 264 | + # This step is not critical, and if some I/O problem happens, we don't want |
| 265 | + # to cancel the build. |
| 266 | + continue-on-error: true |
232 | 267 | if: needs.calculate_matrix.outputs.run_type != 'pr' |
233 | 268 | env: |
234 | | - DATADOG_SITE: datadoghq.com |
235 | 269 | DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} |
236 | | - DD_GITHUB_JOB_NAME: ${{ matrix.name }} |
237 | | - run: | |
238 | | - cd src/ci |
239 | | - npm ci |
240 | | - python3 scripts/upload-build-metrics.py ../../build/cpu-usage.csv |
| 270 | + DD_GITHUB_JOB_NAME: ${{ matrix.full_name }} |
| 271 | + run: ./build/citool/debug/citool upload-build-metrics build/cpu-usage.csv |
241 | 272 |
|
242 | 273 | # This job isused to tell bors the final status of the build, as there is no practical way to detect |
243 | 274 | # when a workflow is successful listening to webhooks only in our current bors implementation (homu). |
|
0 commit comments