about summary refs log tree commit diff
path: root/src/ci/docker
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-17 06:47:39 +0000
committerbors <bors@rust-lang.org>2024-04-17 06:47:39 +0000
commit6c6b3027ef62e911142cfc55589baef4e9f38ec8 (patch)
tree76a8b425b3f8000c3db0476424514e0db3b3b76b /src/ci/docker
parentb7581490aaf964d4a34121d75be0fc49a2445911 (diff)
parent86e939e9d545a7cac41c74e6650c9c43e7f101c3 (diff)
Auto merge of #123678 - DianQK:docker-local, r=Kobzol
Improve the experience of running Docker locally

When running locally, the absence of the `GITHUB_STEP_SUMMARY` environment variable will lead to the following error:

```
::endgroup::
./src/ci/docker/run.sh: line 349: : No such file or directory
```

I've also changed the output artifacts directory to `obj/$image_name`, allowing me to easily run all images locally. We always encounter various strange issues when modifying the test cases in the `codegen` directory.

r? Kobzol cc `@saethlin`
Diffstat (limited to 'src/ci/docker')
-rw-r--r--src/ci/docker/README.md11
-rwxr-xr-xsrc/ci/docker/run.sh20
2 files changed, 17 insertions, 14 deletions
diff --git a/src/ci/docker/README.md b/src/ci/docker/README.md
index 2e645683713..9af368ef445 100644
--- a/src/ci/docker/README.md
+++ b/src/ci/docker/README.md
@@ -14,7 +14,7 @@ for example:
 ./src/ci/docker/run.sh x86_64-gnu
 ```
 
-Images will output artifacts in an `obj` dir at the root of a repository. Note
+Images will output artifacts in an `obj/$image_name` dir at the root of a repository. Note
 that the script will overwrite the contents of this directory.
 
 To match conditions in rusts CI, also set the environment variable `DEPLOY=1`, e.g.:
@@ -22,12 +22,9 @@ To match conditions in rusts CI, also set the environment variable `DEPLOY=1`, e
 DEPLOY=1 ./src/ci/docker/run.sh x86_64-gnu
 ```
 
-**NOTE**: Re-using the same `obj` dir with different docker images with
-the same target triple (e.g. `dist-x86_64-linux` and `dist-various-1`)
-may result in strange linker errors, due shared library versions differing between platforms.
-
-If you encounter any issues when using multiple Docker images, try deleting your `obj` directory
-before running your command.
+**NOTE**: In CI, the script outputs the artifacts to the `obj` directory,
+while locally, to the `obj/$image_name` directory. This is primarily to prevent
+strange linker errors when using multiple Docker images.
 
 ## Filesystem layout
 
diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh
index 9d72fd8a55a..fcc507b572c 100755
--- a/src/ci/docker/run.sh
+++ b/src/ci/docker/run.sh
@@ -33,7 +33,13 @@ ci_dir="`dirname $script_dir`"
 src_dir="`dirname $ci_dir`"
 root_dir="`dirname $src_dir`"
 
-objdir=$root_dir/obj
+source "$ci_dir/shared.sh"
+
+if isCI; then
+    objdir=$root_dir/obj
+else
+    objdir=$root_dir/obj/$image
+fi
 dist=$objdir/build/dist
 
 
@@ -41,12 +47,10 @@ if [ -d "$root_dir/.git" ]; then
     IS_GIT_SOURCE=1
 fi
 
-source "$ci_dir/shared.sh"
-
 CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}"
 
 if [ -f "$docker_dir/$image/Dockerfile" ]; then
-    if [ "$CI" != "" ]; then
+    if isCI; then
       hash_key=/tmp/.docker-hash-key.txt
       rm -f "${hash_key}"
       echo $image >> $hash_key
@@ -102,7 +106,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
     CACHE_IMAGE_TAG=${REGISTRY}/${REGISTRY_USERNAME}/rust-ci-cache:${cksum}
 
     # On non-CI jobs, we don't do any caching.
-    if [[ "$CI" == "" ]];
+    if ! isCI;
     then
         retry docker build --rm -t rust-ci -f "$dockerfile" "$context"
     # On PR CI jobs, we don't have permissions to write to the registry cache,
@@ -289,7 +293,7 @@ else
   command=(/checkout/src/ci/run.sh)
 fi
 
-if [ "$CI" != "" ]; then
+if isCI; then
   # Get some needed information for $BASE_COMMIT
   #
   # This command gets the last merge commit which we'll use as base to list
@@ -339,7 +343,9 @@ docker \
   rust-ci \
   "${command[@]}"
 
-cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"
+if isCI; then
+    cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"
+fi
 
 if [ -f /.dockerenv ]; then
   rm -rf $objdir