Skip to content

Commit a12a595

Browse files
committed
Auto merge of rust-lang#133912 - MarcoIeni:test-codebuild-runner, r=<try>
[experiment] test code build runner try-job: x86_64-fuchsia try-job: x86_64-gnu try-job: dist-arm-linux try-job: dist-powerpc64le-linux try-job: dist-x86_64-linux try-job: dist-x86_64-linux-alt
2 parents aa6f5ab + eb5018a commit a12a595

File tree

13 files changed

+148
-24
lines changed

13 files changed

+148
-24
lines changed

.github/workflows/ci.yml

+22
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ jobs:
112112
run: src/ci/scripts/free-disk-space.sh
113113
if: matrix.free_disk
114114

115+
- name: free up more disk space
116+
if: matrix.free_disk
117+
run: |
118+
sudo apt purge -y --autoremove \
119+
'^java-*' \
120+
'groff' \
121+
'groff-base' \
122+
'^libllvm.*' \
123+
'^llvm.*' \
124+
'gcc' \
125+
'gcc-11' \
126+
'libicu-dev' \
127+
'^vim.*' \
128+
'python3-breezy' \
129+
&& sudo rm -rf /var/lib/apt/lists/*
130+
df -h /
131+
132+
- name: Show installed packages ordered by size
133+
run: dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr
134+
115135
# Rust Log Analyzer can't currently detect the PR number of a GitHub
116136
# Actions build on its own, so a hint in the log message is needed to
117137
# point it in the right direction.
@@ -174,6 +194,8 @@ jobs:
174194

175195
- name: enable ipv6 on Docker
176196
run: src/ci/scripts/enable-docker-ipv6.sh
197+
# Don't run on codebuild because systemctl is not available
198+
if: ${{ !contains(matrix.os, 'codebuild-ubuntu') }}
177199

178200
# Disable automatic line ending conversion (again). On Windows, when we're
179201
# installing dependencies, something switches the git configuration directory or

src/bootstrap/bootstrap.py

+5
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,14 @@ def build_bootstrap(self):
10021002
env = os.environ.copy()
10031003
if "GITHUB_ACTIONS" in env:
10041004
print("::group::Building bootstrap")
1005+
print("Current home directory:", os.path.expanduser("~"))
1006+
print("Current working directory:", os.getcwd())
1007+
print("Current HOME:", env["HOME"])
10051008
else:
10061009
eprint("Building bootstrap")
10071010

10081011
args = self.build_bootstrap_cmd(env)
1012+
print("Running", args, "in", self.rust_root)
10091013
# Run this from the source directory so cargo finds .cargo/config
10101014
run(args, env=env, verbose=self.verbose, cwd=self.rust_root)
10111015

@@ -1015,6 +1019,7 @@ def build_bootstrap(self):
10151019
def build_bootstrap_cmd(self, env):
10161020
"""For tests."""
10171021
build_dir = os.path.join(self.build_dir, "bootstrap")
1022+
print("Building bootstrap in", build_dir)
10181023
if self.clean and os.path.exists(build_dir):
10191024
shutil.rmtree(build_dir)
10201025
# `CARGO_BUILD_TARGET` breaks bootstrap build.

src/ci/docker/host-x86_64/dist-arm-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ghcr.io/marcoieni/ubuntu:22.04
22

33
COPY scripts/cross-apt-packages.sh /scripts/
44
RUN sh /scripts/cross-apt-packages.sh

src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ghcr.io/marcoieni/ubuntu:22.04
22

33
COPY scripts/cross-apt-packages.sh /scripts/
44
RUN sh /scripts/cross-apt-packages.sh

src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# CentOS 7 has headers for kernel 3.10, but that's fine as long as we don't
33
# actually use newer APIs in rustc or std without a fallback. It's more
44
# important that we match glibc for ELF symbol versioning.
5-
FROM centos:7
5+
FROM ghcr.io/marcoieni/centos:7
66

77
WORKDIR /build
88

src/ci/docker/host-x86_64/x86_64-fuchsia/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Fuchsia as an integration test of the toolchain. See the build-fuchsia.sh
33
# script in this directory for more details.
44

5-
FROM ubuntu:22.04
5+
FROM ghcr.io/marcoieni/ubuntu:22.04
66

77
ARG DEBIAN_FRONTEND=noninteractive
88
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -75,5 +75,7 @@ ENV RUST_CONFIGURE_ARGS \
7575
--set target.x86_64-unknown-fuchsia.linker=/usr/local/bin/ld.lld
7676

7777
ENV SCRIPT \
78+
echo "x install" && df -h / && \
7879
python3 ../x.py install --target $TARGETS compiler/rustc library/std clippy && \
80+
echo "build fuchsia" && df -h / && \
7981
bash ../src/ci/docker/host-x86_64/x86_64-fuchsia/build-fuchsia.sh

src/ci/docker/host-x86_64/x86_64-fuchsia/build-fuchsia.sh

+21-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jiri=.jiri_root/bin/jiri
4343
set -x
4444

4545
if [ -z "$KEEP_CHECKOUT" ]; then
46+
echo "downloading jiri" && df -h /
4647
# This script will:
4748
# - create a directory named "fuchsia" if it does not exist
4849
# - download "jiri" to "fuchsia/.jiri_root/bin"
@@ -52,11 +53,13 @@ if [ -z "$KEEP_CHECKOUT" ]; then
5253

5354
cd $checkout
5455

56+
echo "running jiri init" && df -h /
5557
$jiri init \
5658
-partial=true \
5759
-analytics-opt=false \
5860
.
5961

62+
echo "running jiri import" && df -h /
6063
$jiri import \
6164
-name=integration \
6265
-revision=$INTEGRATION_SHA \
@@ -65,24 +68,41 @@ if [ -z "$KEEP_CHECKOUT" ]; then
6568
"https://fuchsia.googlesource.com/integration"
6669

6770
if [ -d ".git" ]; then
71+
echo "Wipe out any local changes" && df -h /
6872
# Wipe out any local changes if we're reusing a checkout.
6973
git checkout --force JIRI_HEAD
7074
fi
7175

76+
echo "running jiri update" && df -h /
7277
$jiri update -autoupdate=false
7378

7479
echo integration commit = $(git -C integration rev-parse HEAD)
7580

7681
for git_ref in "${PICK_REFS[@]}"; do
82+
echo "running git fetch" && df -h /
7783
git fetch https://fuchsia.googlesource.com/fuchsia $git_ref
84+
echo "running git cherry-pick" && df -h /
7885
git cherry-pick --no-commit FETCH_HEAD
7986
done
8087
else
81-
echo Reusing existing Fuchsia checkout
88+
echo Reusing existing Fuchsia checkout && df -h /
8289
cd $checkout
8390
fi
8491

8592
# Run the script inside the Fuchsia checkout responsible for building Fuchsia.
8693
# You can change arguments to the build by setting KEEP_CHECKOUT=1 above and
8794
# modifying them in build_fuchsia_from_rust_ci.sh.
95+
echo "running build_fuchsia_from_rust_ci.sh" && df -h /
96+
97+
# Start background monitoring of disk space
98+
(
99+
while true; do
100+
df -h /
101+
sleep 20
102+
done
103+
) &
104+
MONITOR_PID=$!
105+
88106
bash scripts/rust/build_fuchsia_from_rust_ci.sh
107+
108+
kill $MONITOR_PID

src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ghcr.io/marcoieni/ubuntu:22.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
44
RUN apt-get update && apt-get install -y --no-install-recommends \

src/ci/docker/run.sh

+25-10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ root_dir="`dirname $src_dir`"
3939
source "$ci_dir/shared.sh"
4040

4141
if isCI; then
42+
echo "CI detected"
4243
objdir=$root_dir/obj
4344
else
4445
objdir=$root_dir/obj/$image
@@ -53,6 +54,7 @@ fi
5354
CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}"
5455

5556
if [ -f "$docker_dir/$image/Dockerfile" ]; then
57+
echo "Dockerfile found for $image"
5658
hash_key=/tmp/.docker-hash-key.txt
5759
rm -f "${hash_key}"
5860
echo $image >> $hash_key
@@ -153,6 +155,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
153155
--output=type=docker
154156
# On auto/try builds, we can also write to the cache.
155157
else
158+
echo "Logging into the Docker registry"
156159
# Log into the Docker registry, so that we can read/write cache and the final image
157160
echo ${DOCKER_TOKEN} | docker login ${REGISTRY} \
158161
--username ${REGISTRY_USERNAME} \
@@ -163,6 +166,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
163166
docker buildx create --use --driver docker-container \
164167
--driver-opt image=${GHCR_BUILDKIT_IMAGE}
165168

169+
echo "Building Docker image with cache"
166170
# Build the image using registry caching backend
167171
retry docker \
168172
buildx \
@@ -171,11 +175,13 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
171175
--cache-to type=registry,ref=${CACHE_IMAGE_TAG},compression=zstd \
172176
--output=type=docker
173177

178+
echo "Docker image built"
174179
# Print images for debugging purposes
175180
docker images
176181

177182
# Tag the built image and push it to the registry
178183
docker tag rust-ci "${IMAGE_TAG}"
184+
echo "Pushing Docker image to the registry"
179185
docker push "${IMAGE_TAG}"
180186

181187
# Record the container registry tag/url for reuse, e.g. by rustup.rs builds
@@ -227,6 +233,7 @@ else
227233
exit 1
228234
fi
229235

236+
echo "Creating directories"
230237
mkdir -p $HOME/.cargo
231238
mkdir -p $objdir/tmp
232239
mkdir -p $objdir/cores
@@ -282,24 +289,32 @@ args="$args --privileged"
282289
# `LOCAL_USER_ID` (recognized in `src/ci/run.sh`) to ensure that files are all
283290
# read/written as the same user as the bare-metal user.
284291
if [ -f /.dockerenv ]; then
285-
docker create -v /checkout --name checkout alpine:3.4 /bin/true
292+
echo "Dockerenv detected. We are in docker-in-docker scenario."
293+
docker create -v /checkout --name checkout ghcr.io/marcoieni/alpine:3.4 /bin/true
286294
docker cp . checkout:/checkout
287295
args="$args --volumes-from checkout"
288296
else
289297
args="$args --volume $root_dir:/checkout$SRC_MOUNT_OPTION"
290298
args="$args --volume $objdir:/checkout/obj"
291299
args="$args --volume $HOME/.cargo:/cargo"
292300
args="$args --volume /tmp/toolstate:/tmp/toolstate"
301+
fi
293302

294-
id=$(id -u)
295-
if [[ "$id" != 0 && "$(docker version)" =~ Podman ]]; then
296-
# Rootless podman creates a separate user namespace, where an inner
297-
# LOCAL_USER_ID will map to a different subuid range on the host.
298-
# The "keep-id" mode maps the current UID directly into the container.
299-
args="$args --env NO_CHANGE_USER=1 --userns=keep-id"
300-
else
301-
args="$args --env LOCAL_USER_ID=$id"
302-
fi
303+
id=$(id -u)
304+
if [[ "$id" != 0 && "$(docker version)" =~ Podman ]]; then
305+
# Rootless podman creates a separate user namespace, where an inner
306+
# LOCAL_USER_ID will map to a different subuid range on the host.
307+
# The "keep-id" mode maps the current UID directly into the container.
308+
echo "Running in rootless podman"
309+
args="$args --env NO_CHANGE_USER=1 --userns=keep-id"
310+
elif [[ "$id" != 0 ]]; then
311+
echo "Running in docker as non-root"
312+
args="$args --env LOCAL_USER_ID=$id"
313+
else
314+
echo "Running in docker as root. Using id 1001."
315+
# If we're running as root, we don't want to run the container as root,
316+
# so we set id `1001` instead of `0`.
317+
args="$args --env LOCAL_USER_ID=1001"
303318
fi
304319

305320
if [ "$dev" = "1" ]

src/ci/github-actions/ci.py

+14
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,19 @@ def format_run_type(run_type: WorkflowRunType) -> str:
195195
raise AssertionError()
196196

197197

198+
# Add new function before main:
199+
def substitute_github_vars(jobs: list) -> list:
200+
"""Replace GitHub context variables with environment variables in job configs."""
201+
for job in jobs:
202+
if "os" in job:
203+
job["os"] = (
204+
job["os"]
205+
.replace("${{ github.run_id }}", os.environ["GITHUB_RUN_ID"])
206+
.replace("${{ github.run_attempt }}", os.environ["GITHUB_RUN_ATTEMPT"])
207+
)
208+
return jobs
209+
210+
198211
def get_job_image(job: Job) -> str:
199212
"""
200213
By default, the Docker image of a job is based on its name.
@@ -265,6 +278,7 @@ def calculate_job_matrix(job_data: Dict[str, Any]):
265278
if run_type is not None:
266279
jobs = calculate_jobs(run_type, job_data)
267280
jobs = skip_jobs(jobs, channel)
281+
jobs = substitute_github_vars(jobs)
268282

269283
if not jobs:
270284
raise Exception("Scheduled job list is empty, this is an error")

src/ci/github-actions/jobs.yml

+18-8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ runners:
5252
free_disk: true
5353
os: ubuntu-22.04-arm
5454

55+
- &job-linux-8c-codebuild
56+
free_disk: true
57+
os: codebuild-ubuntu-22-8c-${{ github.run_id }}-${{ github.run_attempt }}
58+
<<: *base-job
59+
60+
- &job-linux-36c-codebuild
61+
free_disk: true
62+
os: codebuild-ubuntu-22-36c-${{ github.run_id }}-${{ github.run_attempt }}
63+
<<: *base-job
64+
5565
- &job-aarch64-linux-8c
5666
os: ubuntu-22.04-arm64-8core-32gb
5767
envs:
@@ -152,7 +162,7 @@ auto:
152162
<<: *job-linux-4c
153163

154164
- name: dist-arm-linux
155-
<<: *job-linux-8c
165+
<<: *job-linux-8c-codebuild
156166

157167
- name: dist-armhf-linux
158168
<<: *job-linux-4c
@@ -182,7 +192,7 @@ auto:
182192
<<: *job-linux-4c
183193

184194
- name: dist-powerpc64le-linux
185-
<<: *job-linux-4c-largedisk
195+
<<: *job-linux-8c-codebuild
186196

187197
- name: dist-riscv64-linux
188198
<<: *job-linux-4c
@@ -205,13 +215,13 @@ auto:
205215
- name: dist-x86_64-linux
206216
env:
207217
CODEGEN_BACKENDS: llvm,cranelift
208-
<<: *job-linux-16c
218+
<<: *job-linux-36c-codebuild
209219

210220
- name: dist-x86_64-linux-alt
211221
env:
212222
IMAGE: dist-x86_64-linux
213223
CODEGEN_BACKENDS: llvm,cranelift
214-
<<: *job-linux-16c
224+
<<: *job-linux-36c-codebuild
215225

216226
- name: dist-x86_64-musl
217227
env:
@@ -264,15 +274,15 @@ auto:
264274
# nightly features to compile, and this job would fail if
265275
# executed on beta and stable.
266276
only_on_channel: nightly
267-
<<: *job-linux-8c
277+
<<: *job-linux-36c-codebuild
268278

269279
# Tests integration with Rust for Linux.
270280
# Builds stage 1 compiler and tries to compile a few RfL examples with it.
271281
- name: x86_64-rust-for-linux
272282
<<: *job-linux-4c
273283

274284
- name: x86_64-gnu
275-
<<: *job-linux-4c
285+
<<: *job-linux-8c-codebuild
276286

277287
# This job ensures commits landing on nightly still pass the full
278288
# test suite on the stable channel. There are some UI tests that
@@ -295,10 +305,10 @@ auto:
295305
- name: x86_64-gnu-debug
296306
# This seems to be needed because a full stage 2 build + run-make tests
297307
# overwhelms the storage capacity of the standard 4c runner.
298-
<<: *job-linux-4c-largedisk
308+
<<: *job-linux-8c-codebuild
299309

300310
- name: x86_64-gnu-distcheck
301-
<<: *job-linux-8c
311+
<<: *job-linux-8c-codebuild
302312

303313
# The x86_64-gnu-llvm-19 job is split into multiple jobs to run tests in parallel.
304314
# x86_64-gnu-llvm-19-1 skips tests that run in x86_64-gnu-llvm-19-{2,3}.

0 commit comments

Comments
 (0)