Skip to content

Commit 6c6b302

Browse files
committed
Auto merge of rust-lang#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`
2 parents b758149 + 86e939e commit 6c6b302

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

Diff for: src/ci/docker/README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,17 @@ for example:
1414
./src/ci/docker/run.sh x86_64-gnu
1515
```
1616

17-
Images will output artifacts in an `obj` dir at the root of a repository. Note
17+
Images will output artifacts in an `obj/$image_name` dir at the root of a repository. Note
1818
that the script will overwrite the contents of this directory.
1919

2020
To match conditions in rusts CI, also set the environment variable `DEPLOY=1`, e.g.:
2121
```
2222
DEPLOY=1 ./src/ci/docker/run.sh x86_64-gnu
2323
```
2424

25-
**NOTE**: Re-using the same `obj` dir with different docker images with
26-
the same target triple (e.g. `dist-x86_64-linux` and `dist-various-1`)
27-
may result in strange linker errors, due shared library versions differing between platforms.
28-
29-
If you encounter any issues when using multiple Docker images, try deleting your `obj` directory
30-
before running your command.
25+
**NOTE**: In CI, the script outputs the artifacts to the `obj` directory,
26+
while locally, to the `obj/$image_name` directory. This is primarily to prevent
27+
strange linker errors when using multiple Docker images.
3128

3229
## Filesystem layout
3330

Diff for: src/ci/docker/run.sh

+13-7
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,24 @@ ci_dir="`dirname $script_dir`"
3333
src_dir="`dirname $ci_dir`"
3434
root_dir="`dirname $src_dir`"
3535

36-
objdir=$root_dir/obj
36+
source "$ci_dir/shared.sh"
37+
38+
if isCI; then
39+
objdir=$root_dir/obj
40+
else
41+
objdir=$root_dir/obj/$image
42+
fi
3743
dist=$objdir/build/dist
3844

3945

4046
if [ -d "$root_dir/.git" ]; then
4147
IS_GIT_SOURCE=1
4248
fi
4349

44-
source "$ci_dir/shared.sh"
45-
4650
CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}"
4751

4852
if [ -f "$docker_dir/$image/Dockerfile" ]; then
49-
if [ "$CI" != "" ]; then
53+
if isCI; then
5054
hash_key=/tmp/.docker-hash-key.txt
5155
rm -f "${hash_key}"
5256
echo $image >> $hash_key
@@ -102,7 +106,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
102106
CACHE_IMAGE_TAG=${REGISTRY}/${REGISTRY_USERNAME}/rust-ci-cache:${cksum}
103107

104108
# On non-CI jobs, we don't do any caching.
105-
if [[ "$CI" == "" ]];
109+
if ! isCI;
106110
then
107111
retry docker build --rm -t rust-ci -f "$dockerfile" "$context"
108112
# On PR CI jobs, we don't have permissions to write to the registry cache,
@@ -289,7 +293,7 @@ else
289293
command=(/checkout/src/ci/run.sh)
290294
fi
291295

292-
if [ "$CI" != "" ]; then
296+
if isCI; then
293297
# Get some needed information for $BASE_COMMIT
294298
#
295299
# This command gets the last merge commit which we'll use as base to list
@@ -339,7 +343,9 @@ docker \
339343
rust-ci \
340344
"${command[@]}"
341345

342-
cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"
346+
if isCI; then
347+
cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"
348+
fi
343349

344350
if [ -f /.dockerenv ]; then
345351
rm -rf $objdir

0 commit comments

Comments
 (0)