Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Dec 4, 2023
1 parent 39067f2 commit 4b2a6b9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ name: CI
- "**"
permissions:
contents: read
packages: write
defaults:
run:
shell: bash
Expand All @@ -42,6 +43,7 @@ jobs:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
DOCKER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
SCCACHE_BUCKET: rust-lang-ci-sccache2
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
CACHE_DOMAIN: ci-caches.rust-lang.org
Expand Down Expand Up @@ -162,6 +164,7 @@ jobs:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
DOCKER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
SCCACHE_BUCKET: rust-lang-ci-sccache2
DEPLOY_BUCKET: rust-lang-ci2
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
Expand Down Expand Up @@ -552,6 +555,7 @@ jobs:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
DOCKER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
SCCACHE_BUCKET: rust-lang-ci-sccache2
DEPLOY_BUCKET: rust-lang-ci2
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
Expand Down
44 changes: 26 additions & 18 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,29 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
cksum=$(sha512sum $hash_key | \
awk '{print $1}')

url="https://$CACHE_DOMAIN/docker/$cksum"
# echo "Looking for ${cksum}"
echo ${DOCKER_TOKEN} | docker login ghcr.io --username kobzol --password-stdin
# docker manifest inspect tensorflow/tensorflow:latestx 2> /dev/null ; echo $?
# docker pull ghcr.io/kobzol/rust-ci:${cksum}

echo "Attempting to download $url"
rm -f /tmp/rustci_docker_cache
set +e
retry curl --max-time 600 -y 30 -Y 10 --connect-timeout 30 -f -L -C - \
-o /tmp/rustci_docker_cache "$url"
# url="https://$CACHE_DOMAIN/docker/$cksum"

docker_archive_hash=$(sha512sum /tmp/rustci_docker_cache | awk '{print $1}')
echo "Downloaded archive hash: ${docker_archive_hash}"
# echo "Attempting to download $url"
# rm -f /tmp/rustci_docker_cache
# set +e
# retry curl --max-time 600 -y 30 -Y 10 --connect-timeout 30 -f -L -C - \
# -o /tmp/rustci_docker_cache "$url"

echo "Loading images into docker"
# docker_archive_hash=$(sha512sum /tmp/rustci_docker_cache | awk '{print $1}')
# echo "Downloaded archive hash: ${docker_archive_hash}"

# echo "Loading images into docker"
# docker load sometimes hangs in the CI, so time out after 10 minutes with TERM,
# KILL after 12 minutes
loaded_images=$(/usr/bin/timeout -k 720 600 docker load -i /tmp/rustci_docker_cache \
| sed 's/.* sha/sha/')
set -e
printf "Downloaded containers:\n$loaded_images\n"
# loaded_images=$(/usr/bin/timeout -k 720 600 docker load -i /tmp/rustci_docker_cache \
# | sed 's/.* sha/sha/')
# set -e
# printf "Downloaded containers:\n$loaded_images\n"
fi

dockerfile="$docker_dir/$image/Dockerfile"
Expand All @@ -100,19 +105,22 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
echo "::group::Building docker image for $image"
echo ${cksum}

export DOCKER_BUILDKIT=0
# export DOCKER_BUILDKIT=0
docker buildx create --use --driver docker-container
retry docker \
buildx \
build \
--rm \
-t rust-ci \
-f "$dockerfile" \
--cache-from type=registry,ref=ghcr.io/kobzol/rust-ci:${cksum} \
--cache-to type=registry,ref=ghcr.io/kobzol/rust-ci:${cksum} \
--output=type=docker \
"$context"
echo "::endgroup::"
docker images
docker tag rust-ci ghcr.io/kobzol/rust-ci:${cksum}

docker login --username kobzol --password ${GITHUB_TOKEN}
docker push ghcr.io/kobzol/rust-ci:${cksum}
# docker tag rust-ci ghcr.io/kobzol/rust-ci:${cksum}
# docker push ghcr.io/kobzol/rust-ci:${cksum}

if [ "$CI" != "" ]; then
# s3url="s3://$SCCACHE_BUCKET/docker/$cksum"
Expand Down
2 changes: 2 additions & 0 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ x--expand-yaml-anchors--remove:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs.
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- &public-variables
SCCACHE_BUCKET: rust-lang-ci-sccache2
Expand Down Expand Up @@ -301,6 +302,7 @@ on:

permissions:
contents: read
packages: write

defaults:
run:
Expand Down

0 comments on commit 4b2a6b9

Please sign in to comment.