diff options
| author | bors <bors@rust-lang.org> | 2024-05-04 20:46:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-04 20:46:48 +0000 |
| commit | e82c861d7e5ecd766cb0dab0bf622445dec999dc (patch) | |
| tree | ec1874052c44491c598be8bb8cb231932ccc8e1b /src/ci/docker | |
| parent | d568423a7a4ddb4b49323d96078a22f94df55fbd (diff) | |
| parent | e1867404a81524b64147c6e1bb90bb044fd7b9d3 (diff) | |
| download | rust-e82c861d7e5ecd766cb0dab0bf622445dec999dc.tar.gz rust-e82c861d7e5ecd766cb0dab0bf622445dec999dc.zip | |
Auto merge of #124726 - matthiaskrgr:rollup-m6i3day, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #124501 (add support to override lldb binary path for ./x test) - #124573 (add a reference link to the comment of the "cc" and "cmake".) - #124663 (Enable reusing CI Docker cache when running CI images locally) - #124690 (Only consider ambiguous goals when finding best obligation for ambiguities) - #124713 (Update Cargo specific diagnostics in check-cfg) - #124717 (Implement `do_not_recommend` in the new solver) - #124718 (Record impl args in the proof tree) - #124720 (interpret: Drop: always evaluate place) - #124721 (library/std: Fix build for NetBSD targets with 32-bit `c_long`) - #124723 (Use correct Hermit links in The `rustc` Book) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/ci/docker')
| -rwxr-xr-x | src/ci/docker/run.sh | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index fcc507b572c..22dcb808c74 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -50,39 +50,35 @@ fi CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}" if [ -f "$docker_dir/$image/Dockerfile" ]; then - if isCI; then - hash_key=/tmp/.docker-hash-key.txt - rm -f "${hash_key}" - echo $image >> $hash_key - - cat "$docker_dir/$image/Dockerfile" >> $hash_key - # Look for all source files involves in the COPY command - copied_files=/tmp/.docker-copied-files.txt - rm -f "$copied_files" - for i in $(sed -n -e '/^COPY --from=/! s/^COPY \(.*\) .*$/\1/p' \ - "$docker_dir/$image/Dockerfile"); do - # List the file names - find "$script_dir/$i" -type f >> $copied_files - done - # Sort the file names and cat the content into the hash key - sort $copied_files | xargs cat >> $hash_key - - # Include the architecture in the hash key, since our Linux CI does not - # only run in x86_64 machines. - uname -m >> $hash_key - - docker --version >> $hash_key - - # Include cache version. Can be used to manually bust the Docker cache. - echo "2" >> $hash_key - - echo "Image input" - cat $hash_key - - cksum=$(sha512sum $hash_key | \ - awk '{print $1}') - echo "Image input checksum ${cksum}" - fi + hash_key=/tmp/.docker-hash-key.txt + rm -f "${hash_key}" + echo $image >> $hash_key + + cat "$docker_dir/$image/Dockerfile" >> $hash_key + # Look for all source files involves in the COPY command + copied_files=/tmp/.docker-copied-files.txt + rm -f "$copied_files" + for i in $(sed -n -e '/^COPY --from=/! s/^COPY \(.*\) .*$/\1/p' \ + "$docker_dir/$image/Dockerfile"); do + # List the file names + find "$script_dir/$i" -type f >> $copied_files + done + # Sort the file names and cat the content into the hash key + sort $copied_files | xargs cat >> $hash_key + + # Include the architecture in the hash key, since our Linux CI does not + # only run in x86_64 machines. + uname -m >> $hash_key + + # Include cache version. Can be used to manually bust the Docker cache. + echo "2" >> $hash_key + + echo "Image input" + cat $hash_key + + cksum=$(sha512sum $hash_key | \ + awk '{print $1}') + echo "Image input checksum ${cksum}" dockerfile="$docker_dir/$image/Dockerfile" if [ -x /usr/bin/cygpath ]; then @@ -105,10 +101,18 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then # It seems that it cannot be the same as $IMAGE_TAG, otherwise it overwrites the cache CACHE_IMAGE_TAG=${REGISTRY}/${REGISTRY_USERNAME}/rust-ci-cache:${cksum} - # On non-CI jobs, we don't do any caching. + # On non-CI jobs, we try to download a pre-built image from the rust-lang-ci + # ghcr.io registry. If it is not possible, we fall back to building the image + # locally. if ! isCI; then - retry docker build --rm -t rust-ci -f "$dockerfile" "$context" + if docker pull "${IMAGE_TAG}"; then + echo "Downloaded Docker image from CI" + docker tag "${IMAGE_TAG}" rust-ci + else + echo "Building local Docker image" + retry docker build --rm -t rust-ci -f "$dockerfile" "$context" + fi # On PR CI jobs, we don't have permissions to write to the registry cache, # but we can still read from it. elif [[ "$PR_CI_JOB" == "1" ]]; |
