Skip to content

Commit 2004e09

Browse files
authored
Rollup merge of rust-lang#65274 - pietroalbini:ci-upload-toolstate, r=alexcrichton
Upload toolstates.json to rust-lang-ci2 This PR does two things: * Following up with rust-lang#65202, it migrates deploying artifacts to CI in a script. Both uploading release artifacts and CPU stats were merged into the same script, designing it to be easily extended. * Uploads the toolstate JSON to `rust-lang-ci2` along with the release artifacts, both for Linux and Windows. This is needed because @RalfJung wants to stop shipping MIRI when its tests are failing, and the toolstate repo doesn't have entries for each commit. Having the toolstate data (just for that specific commit) on `rust-lang-ci2` will simplify the code a lot. r? @alexcrichton cc @RalfJung
2 parents e9022da + bdfcde4 commit 2004e09

File tree

4 files changed

+61
-30
lines changed

4 files changed

+61
-30
lines changed

src/ci/azure-pipelines/auto.yml

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ jobs:
140140
IMAGE: x86_64-gnu-aux
141141
x86_64-gnu-tools:
142142
IMAGE: x86_64-gnu-tools
143+
DEPLOY_TOOLSTATES_JSON: toolstates-linux.json
143144
x86_64-gnu-debug:
144145
IMAGE: x86_64-gnu-debug
145146
x86_64-gnu-nopt:
@@ -264,6 +265,7 @@ jobs:
264265
MSYS_BITS: 64
265266
SCRIPT: src/ci/docker/x86_64-gnu-tools/checktools.sh x.py /tmp/toolstates.json windows
266267
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --save-toolstates=/tmp/toolstates.json
268+
DEPLOY_TOOLSTATES_JSON: toolstates-windows.json
267269

268270
# 32/64-bit MinGW builds.
269271
#

src/ci/azure-pipelines/steps/run.yml

+14-30
Original file line numberDiff line numberDiff line change
@@ -183,37 +183,21 @@ steps:
183183
condition: and(succeeded(), not(variables.SKIP_JOB))
184184
displayName: Run build
185185

186-
# If we're a deploy builder, use the `aws` command to publish everything to our
187-
# bucket.
188-
- bash: |
189-
set -e
190-
source src/ci/shared.sh
191-
if [ "$AGENT_OS" = "Linux" ]; then
192-
rm -rf obj/build/dist/doc
193-
upload_dir=obj/build/dist
194-
else
195-
rm -rf build/dist/doc
196-
upload_dir=build/dist
197-
fi
198-
ls -la $upload_dir
199-
deploy_dir=rustc-builds
200-
if [ "$DEPLOY_ALT" == "1" ]; then
201-
deploy_dir=rustc-builds-alt
202-
fi
203-
retry aws s3 cp --no-progress --recursive --acl public-read ./$upload_dir s3://$DEPLOY_BUCKET/$deploy_dir/$BUILD_SOURCEVERSION
186+
- bash: src/ci/scripts/upload-artifacts.sh
204187
env:
205188
AWS_ACCESS_KEY_ID: $(UPLOAD_AWS_ACCESS_KEY_ID)
206189
AWS_SECRET_ACCESS_KEY: $(UPLOAD_AWS_SECRET_ACCESS_KEY)
207-
condition: and(succeeded(), not(variables.SKIP_JOB), or(eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1')))
208190
displayName: Upload artifacts
209-
210-
# Upload CPU usage statistics that we've been gathering this whole time. Always
211-
# execute this step in case we want to inspect failed builds, but don't let
212-
# errors here ever fail the build since this is just informational.
213-
- bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$CI_JOB_NAME.csv
214-
env:
215-
AWS_ACCESS_KEY_ID: $(UPLOAD_AWS_ACCESS_KEY_ID)
216-
AWS_SECRET_ACCESS_KEY: $(UPLOAD_AWS_SECRET_ACCESS_KEY)
217-
condition: variables['UPLOAD_AWS_SECRET_ACCESS_KEY']
218-
continueOnError: true
219-
displayName: Upload CPU usage statistics
191+
# Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
192+
# builders *should* have the AWS credentials available. Still, explicitly
193+
# adding the condition is helpful as this way CI will not silently skip
194+
# deploying artifacts from a dist builder if the variables are misconfigured,
195+
# erroring about invalid credentials instead.
196+
condition: |
197+
and(
198+
succeeded(), not(variables.SKIP_JOB),
199+
or(
200+
variables.UPLOAD_AWS_SECRET_ACCESS_KEY,
201+
eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1')
202+
)
203+
)

src/ci/scripts/upload-artifacts.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Upload all the artifacts to our S3 bucket. All the files inside ${upload_dir}
3+
# will be uploaded to the deploy bucket and eventually signed and released in
4+
# static.rust-lang.org.
5+
6+
set -euo pipefail
7+
IFS=$'\n\t'
8+
9+
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
10+
11+
upload_dir="$(mktemp -d)"
12+
13+
# Release tarballs produced by a dist builder.
14+
if [[ "${DEPLOY-0}" -eq "1" ]] || [[ "${DEPLOY_ALT-0}" -eq "1" ]]; then
15+
dist_dir=build/dist
16+
if isLinux; then
17+
dist_dir=obj/build/dist
18+
fi
19+
rm -rf "${dist_dir}/doc"
20+
cp -r "${dist_dir}"/* "${upload_dir}"
21+
fi
22+
23+
# CPU usage statistics.
24+
cp cpu-usage.csv "${upload_dir}/cpu-${CI_JOB_NAME}.csv"
25+
26+
# Toolstate data.
27+
if [[ -n "${DEPLOY_TOOLSTATES_JSON+x}" ]]; then
28+
cp /tmp/toolstates.json "${upload_dir}/${DEPLOY_TOOLSTATES_JSON}"
29+
fi
30+
31+
echo "Files that will be uploaded:"
32+
ls -lah "${upload_dir}"
33+
echo
34+
35+
deploy_dir="rustc-builds"
36+
if [[ "${DEPLOY_ALT-0}" -eq "1" ]]; then
37+
deploy_dir="rustc-builds-alt"
38+
fi
39+
deploy_url="s3://${DEPLOY_BUCKET}/${deploy_dir}/$(ciCommit)"
40+
41+
retry aws s3 cp --no-progress --recursive --acl public-read "${upload_dir}" "${deploy_url}"

src/ci/shared.sh

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ function getCIBranch {
4646
echo "$BUILD_SOURCEBRANCHNAME"
4747
}
4848

49+
function ciCommit {
50+
echo "${BUILD_SOURCEVERSION}"
51+
}
52+
4953
function ciCommandAddPath {
5054
if [[ $# -ne 1 ]]; then
5155
echo "usage: $0 <path>"

0 commit comments

Comments
 (0)