about summary refs log tree commit diff
path: root/src/ci
diff options
context:
space:
mode:
authorsethp <seth@codecopse.net>2023-07-29 08:24:55 -0700
committerGitHub <noreply@github.com>2023-07-29 08:24:55 -0700
commit912dacb6588b63b385020d5b210fb27eb8095da0 (patch)
tree9eb470a345463d3e915f2f558e55ea1ec5dab029 /src/ci
parentf9f674f2bcf9cb67ef29123dd3a631485cba22c8 (diff)
downloadrust-912dacb6588b63b385020d5b210fb27eb8095da0.tar.gz
rust-912dacb6588b63b385020d5b210fb27eb8095da0.zip
fix(ci): Ensure idempotence of user creation
Previously, re-running `run.sh` in the same container would fail at the useradd step, because the user already exists. Instead, change that step to "create if not exists" semantics to ease interactive debugging of CI failures.

Split out from https://github.com/rust-lang/rust/pull/111891 per request by @jackh726
Diffstat (limited to 'src/ci')
-rwxr-xr-xsrc/ci/run.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/ci/run.sh b/src/ci/run.sh
index da1960fc057..0c0026f484f 100755
--- a/src/ci/run.sh
+++ b/src/ci/run.sh
@@ -8,7 +8,7 @@ fi
 
 if [ "$NO_CHANGE_USER" = "" ]; then
   if [ "$LOCAL_USER_ID" != "" ]; then
-    useradd --shell /bin/bash -u $LOCAL_USER_ID -o -c "" -m user
+    id -u $LOCAL_USER_ID &>/dev/null || useradd --shell /bin/bash -u $LOCAL_USER_ID -o -c "" -m user
     export HOME=/home/user
     unset LOCAL_USER_ID