Skip to content

Commit 4e418c8

Browse files
committed
ci: use codebuild for x86_64-gnu-distcheck job
1 parent 21079f5 commit 4e418c8

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ghcr.io/rust-lang/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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,20 @@ else
296296
args="$args --volume $objdir:/checkout/obj"
297297
args="$args --volume $HOME/.cargo:/cargo"
298298
args="$args --volume /tmp/toolstate:/tmp/toolstate"
299+
fi
299300

300-
id=$(id -u)
301-
if [[ "$id" != 0 && "$(docker version)" =~ Podman ]]; then
302-
# Rootless podman creates a separate user namespace, where an inner
303-
# LOCAL_USER_ID will map to a different subuid range on the host.
304-
# The "keep-id" mode maps the current UID directly into the container.
305-
args="$args --env NO_CHANGE_USER=1 --userns=keep-id"
306-
else
307-
args="$args --env LOCAL_USER_ID=$id"
308-
fi
301+
id=$(id -u)
302+
if [[ "$id" != 0 && "$(docker version)" =~ Podman ]]; then
303+
# Rootless podman creates a separate user namespace, where an inner
304+
# LOCAL_USER_ID will map to a different subuid range on the host.
305+
# The "keep-id" mode maps the current UID directly into the container.
306+
args="$args --env NO_CHANGE_USER=1 --userns=keep-id"
307+
elif [[ "$id" != 0 ]]; then
308+
args="$args --env LOCAL_USER_ID=$id"
309+
else
310+
# We're running as root.
311+
# We set the user id to `1001` instead of `0` to avoid running the container as root.
312+
args="$args --env LOCAL_USER_ID=1001"
309313
fi
310314

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

src/ci/github-actions/jobs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ auto:
309309
<<: *job-linux-4c
310310

311311
- name: x86_64-gnu-distcheck
312-
<<: *job-linux-8c
312+
<<: *job-linux-36c-codebuild
313313

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

src/ci/run.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22

33
set -e
44

5+
# Change ownership of the given path to the user if the filesystem is writable
6+
change_ownership_if_writable() {
7+
local path=$1
8+
local owner="user:user"
9+
local current_owner
10+
current_owner=$(stat -f "%Su:%Sg" "$path" 2>/dev/null)
11+
12+
local test_file="$path/.write_test"
13+
echo "Testing if $path is writable by $owner"
14+
# Test if filesystem is writable by attempting to touch a temporary file
15+
if touch "$test_file" 2>/dev/null; then
16+
# We wrote the file just for testing. We can remove it now.
17+
rm "$test_file"
18+
if [ "$current_owner" != "$owner" ]; then
19+
echo "Changing ownership of $path to $owner"
20+
chown -R $owner "$path"
21+
fi
22+
else
23+
echo "$path is read-only, skipping ownership change"
24+
fi
25+
echo "Ownership of $path is $current_owner"
26+
}
27+
528
if [ -n "$CI_JOB_NAME" ]; then
629
echo "[CI_JOB_NAME=$CI_JOB_NAME]"
730
fi
@@ -16,6 +39,12 @@ if [ "$NO_CHANGE_USER" = "" ]; then
1639
export HOME=/home/user
1740
unset LOCAL_USER_ID
1841

42+
# Give ownership of necessary directories to the user
43+
change_ownership_if_writable .
44+
mkdir -p /cargo
45+
change_ownership_if_writable /cargo
46+
change_ownership_if_writable /checkout
47+
1948
# Ensure that runners are able to execute git commands in the worktree,
2049
# overriding the typical git protections. In our docker container we're running
2150
# as root, while the user owning the checkout is not root.

0 commit comments

Comments
 (0)