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/ci.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.
@@ -53,48 +53,54 @@ jobs:
53
53
steps :
54
54
- name : Checkout the source code
55
55
uses : actions/checkout@v4
56
+ # Cache citool to make its build faster, as it's in the critical path.
57
+ # The rust-cache doesn't bleed into the main `job`, so it should not affect any other
58
+ # Rust compilation.
59
+ - name : Cache citool
60
+ uses : Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
61
+ with :
62
+ workspaces : src/ci/citool
56
63
- name : Calculate the CI job matrix
57
64
env :
58
65
COMMIT_MESSAGE : ${{ github.event.head_commit.message }}
59
- run : python3 src/ci/github-actions/ci.py calculate-job-matrix >> $GITHUB_OUTPUT
66
+ run : |
67
+ cd src/ci/citool
68
+ CARGO_INCREMENTAL=0 cargo test
69
+ CARGO_INCREMENTAL=0 cargo run calculate-job-matrix >> $GITHUB_OUTPUT
60
70
id : jobs
61
71
job :
62
72
name : ${{ matrix.full_name }}
63
73
needs : [ calculate_matrix ]
64
74
runs-on : " ${{ matrix.os }}"
65
- defaults :
66
- run :
67
- shell : ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}
68
75
timeout-minutes : 360
69
76
env :
70
77
CI_JOB_NAME : ${{ matrix.name }}
78
+ CI_JOB_DOC_URL : ${{ matrix.doc_url }}
79
+ GITHUB_WORKFLOW_RUN_ID : ${{ github.run_id }}
80
+ GITHUB_REPOSITORY : ${{ github.repository }}
71
81
CARGO_REGISTRIES_CRATES_IO_PROTOCOL : sparse
72
82
# commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs.
73
83
HEAD_SHA : ${{ github.event.pull_request.head.sha || github.sha }}
74
84
DOCKER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
75
85
SCCACHE_BUCKET : rust-lang-ci-sccache2
86
+ SCCACHE_REGION : us-west-1
76
87
CACHE_DOMAIN : ci-caches.rust-lang.org
77
88
continue-on-error : ${{ matrix.continue_on_error || false }}
78
89
strategy :
79
90
matrix :
80
91
# Check the `calculate_matrix` job to see how is the matrix defined.
81
92
include : ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
82
93
steps :
83
- - if : contains(matrix.os, 'windows')
84
-
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
94
+ - name : Install cargo in AWS CodeBuild
95
+ if : matrix.codebuild
96
+ run : |
97
+ # Check if cargo is installed
98
+ if ! command -v cargo &> /dev/null; then
99
+ echo "Cargo not found, installing Rust..."
100
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
101
+ # Make cargo available in PATH
102
+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
103
+ fi
98
104
99
105
- name : disable git crlf conversion
100
106
run : git config --global core.autocrlf false
@@ -109,7 +115,7 @@ jobs:
109
115
# intensive jobs to run on free runners, which however also have
110
116
# less disk space.
111
117
- name : free up disk space
112
- uses : jlumbroso/ free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
118
+ run : src/ci/scripts/ free-disk-space.sh
113
119
if : matrix.free_disk
114
120
115
121
# Rust Log Analyzer can't currently detect the PR number of a GitHub
@@ -130,9 +136,6 @@ jobs:
130
136
# which then uses log commands to actually set them.
131
137
EXTRA_VARIABLES : ${{ toJson(matrix.env) }}
132
138
133
- - name : setup upstream remote
134
- run : src/ci/scripts/setup-upstream-remote.sh
135
-
136
139
- name : ensure the channel matches the target branch
137
140
run : src/ci/scripts/verify-channel.sh
138
141
@@ -173,6 +176,8 @@ jobs:
173
176
run : src/ci/scripts/install-ninja.sh
174
177
175
178
- name : enable ipv6 on Docker
179
+ # Don't run on codebuild because systemctl is not available
180
+ if : ${{ !matrix.codebuild }}
176
181
run : src/ci/scripts/enable-docker-ipv6.sh
177
182
178
183
# Disable automatic line ending conversion (again). On Windows, when we're
@@ -192,9 +197,33 @@ jobs:
192
197
- name : ensure the stable version number is correct
193
198
run : src/ci/scripts/verify-stable-version-number.sh
194
199
200
+ # Show the environment just before we run the build
201
+ # This makes it easier to diagnose problems with the above install scripts.
202
+ - name : show the current environment
203
+ run : src/ci/scripts/dump-environment.sh
204
+
205
+ # Pre-build citool before the following step uninstalls rustup
206
+ # Build it into the build directory, to avoid modifying sources
207
+ - name : build citool
208
+ run : |
209
+ cd src/ci/citool
210
+ CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=../../../build/citool cargo build
211
+
195
212
- 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
213
+ run : |
214
+ set +e
215
+ # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs.
216
+ src/ci/scripts/run-build-from-ci.sh 2>&1
217
+ STATUS=$?
218
+ set -e
219
+
220
+ if [[ "$STATUS" -ne 0 && -n "$CI_JOB_DOC_URL" ]]; then
221
+ echo "****************************************************************************"
222
+ echo "To find more information about this job, visit the following URL:"
223
+ echo "$CI_JOB_DOC_URL"
224
+ echo "****************************************************************************"
225
+ fi
226
+ exit ${STATUS}
198
227
env :
199
228
AWS_ACCESS_KEY_ID : ${{ env.CACHES_AWS_ACCESS_KEY_ID }}
200
229
AWS_SECRET_ACCESS_KEY : ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}
@@ -228,16 +257,37 @@ jobs:
228
257
# erroring about invalid credentials instead.
229
258
if : github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1'
230
259
260
+ - name : postprocess metrics into the summary
261
+ # This step is not critical, and if some I/O problem happens, we don't want
262
+ # to cancel the build.
263
+ continue-on-error : true
264
+ run : |
265
+ if [ -f build/metrics.json ]; then
266
+ METRICS=build/metrics.json
267
+ elif [ -f obj/build/metrics.json ]; then
268
+ METRICS=obj/build/metrics.json
269
+ else
270
+ echo "No metrics.json found"
271
+ exit 0
272
+ fi
273
+
274
+ # Get closest bors merge commit
275
+ PARENT_COMMIT=`git rev-list --author='bors <[email protected] >' -n1 --first-parent HEAD^1`
276
+
277
+ ./build/citool/debug/citool postprocess-metrics \
278
+ --job-name ${CI_JOB_NAME} \
279
+ --parent ${PARENT_COMMIT} \
280
+ ${METRICS} >> ${GITHUB_STEP_SUMMARY}
281
+
231
282
- name : upload job metrics to DataDog
283
+ # This step is not critical, and if some I/O problem happens, we don't want
284
+ # to cancel the build.
285
+ continue-on-error : true
232
286
if : needs.calculate_matrix.outputs.run_type != 'pr'
233
287
env :
234
- DATADOG_SITE : datadoghq.com
235
288
DATADOG_API_KEY : ${{ secrets.DATADOG_API_KEY }}
236
289
DD_GITHUB_JOB_NAME : ${{ matrix.full_name }}
237
- run : |
238
- cd src/ci
239
- npm ci
240
- python3 scripts/upload-build-metrics.py ../../build/cpu-usage.csv
290
+ run : ./build/citool/debug/citool upload-build-metrics build/cpu-usage.csv
241
291
242
292
# This job isused to tell bors the final status of the build, as there is no practical way to detect
243
293
# when a workflow is successful listening to webhooks only in our current bors implementation (homu).
0 commit comments