Skip to content

ci: use codebuild for x86_64-gnu-distcheck job #140383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-distcheck/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04
FROM ghcr.io/rust-lang/ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
22 changes: 13 additions & 9 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,20 @@ else
args="$args --volume $objdir:/checkout/obj"
args="$args --volume $HOME/.cargo:/cargo"
args="$args --volume /tmp/toolstate:/tmp/toolstate"
fi

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

if [ "$dev" = "1" ]
Expand Down
2 changes: 1 addition & 1 deletion src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ auto:
<<: *job-linux-4c

- name: x86_64-gnu-distcheck
<<: *job-linux-8c
<<: *job-linux-36c-codebuild

# The x86_64-gnu-llvm-20 job is split into multiple jobs to run tests in parallel.
# x86_64-gnu-llvm-20-1 skips tests that run in x86_64-gnu-llvm-20-{2,3}.
Expand Down
29 changes: 29 additions & 0 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

set -e

# Change ownership of the given path to the user if the filesystem is writable
change_ownership_if_writable() {
local path=$1
local owner="user:user"
local current_owner
current_owner=$(stat -f "%Su:%Sg" "$path" 2>/dev/null)

local test_file="$path/.write_test"
echo "Testing if $path is writable by $owner"
# Test if filesystem is writable by attempting to touch a temporary file
if touch "$test_file" 2>/dev/null; then
# We wrote the file just for testing. We can remove it now.
rm "$test_file"
if [ "$current_owner" != "$owner" ]; then
echo "Changing ownership of $path to $owner"
chown -R $owner "$path"
fi
else
echo "$path is read-only, skipping ownership change"
fi
echo "Ownership of $path is $current_owner"
}

if [ -n "$CI_JOB_NAME" ]; then
echo "[CI_JOB_NAME=$CI_JOB_NAME]"
fi
Expand All @@ -16,6 +39,12 @@ if [ "$NO_CHANGE_USER" = "" ]; then
export HOME=/home/user
unset LOCAL_USER_ID

# Give ownership of necessary directories to the user
change_ownership_if_writable .
mkdir -p /cargo
change_ownership_if_writable /cargo
change_ownership_if_writable /checkout

# Ensure that runners are able to execute git commands in the worktree,
# overriding the typical git protections. In our docker container we're running
# as root, while the user owning the checkout is not root.
Expand Down
Loading