Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Don't use Travis caches for docker images #49284

Merged
merged 1 commit into from
Mar 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ matrix:
if: branch = master AND type = push
before_install: []
install: []
cache: false
sudo: false
script:
MESSAGE_FILE=$(mktemp -t msg.XXXXXX);
Expand All @@ -201,7 +200,12 @@ env:
- secure: "cFh8thThqEJLC98XKI5pfqflUzOlxsYPRW20AWRaYOOgYHPTiGWypTXiPbGSKaeAXTZoOA+DpQtEmefc0U6lt9dHc7a/MIaK6isFurjlnKYiLOeTruzyu1z7PWCeZ/jKXsU2RK/88DBtlNwfMdaMIeuKj14IVfpepPPL71ETbuk="

before_install:
- zcat $HOME/docker/rust-ci.tar.gz | docker load || true
# We'll use the AWS cli to download/upload cached docker layers, so install
# that here.
- if [ "$TRAVIS_OS_NAME" = linux ]; then
pip install --user awscli;
export PATH=$PATH:$HOME/.local/bin;
fi
- mkdir -p $HOME/rustsrc
# FIXME(#46924): these two commands are required to enable IPv6,
# they shouldn't exist, please revert once more official solutions appeared.
Expand Down Expand Up @@ -286,23 +290,9 @@ after_failure:
# it happened
- dmesg | grep -i kill

# Save tagged docker images we created and load them if they're available
# Travis saves caches whether the build failed or not, nuke rustsrc if
# the failure was while updating it (as it may be in a bad state)
# https://github.com/travis-ci/travis-ci/issues/4472
before_cache:
- docker history -q rust-ci |
grep -v missing |
xargs docker save |
gzip > $HOME/docker/rust-ci.tar.gz

notifications:
email: false

cache:
directories:
- $HOME/docker

before_deploy:
- mkdir -p deploy/$TRAVIS_COMMIT
- >
Expand Down
32 changes: 32 additions & 0 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ travis_fold start build_docker
travis_time_start

if [ -f "$docker_dir/$image/Dockerfile" ]; then
if [ "$CI" != "" ]; then
cksum=$(find $docker_dir/$image $docker_dir/scripts -type f | \
sort | \
xargs cat | \
sha512sum | \
awk '{print $1}')
s3url="s3://$SCCACHE_BUCKET/docker/$cksum"
url="https://s3-us-west-1.amazonaws.com/$SCCACHE_BUCKET/docker/$cksum"
echo "Attempting to download $s3url"
set +e
loaded_images=$(curl $url | docker load | sed 's/.* sha/sha/')
set -e
echo "Downloaded containers:\n$loaded_images"
fi

dockerfile="$docker_dir/$image/Dockerfile"
if [ -x /usr/bin/cygpath ]; then
context="`cygpath -w $docker_dir`"
Expand All @@ -40,6 +55,23 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
-t rust-ci \
-f "$dockerfile" \
"$context"

if [ "$s3url" != "" ]; then
digest=$(docker inspect rust-ci --format '{{.Id}}')
echo "Built container $digest"
if ! grep -q "$digest" <(echo "$loaded_images"); then
echo "Uploading finished image to $s3url"
set +e
docker history -q rust-ci | \
grep -v missing | \
xargs docker save | \
gzip | \
aws s3 cp - $s3url
set -e
else
echo "Looks like docker image is the same as before, not uploading"
fi
fi
elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
if [ -n "$TRAVIS_OS_NAME" ]; then
echo Cannot run disabled images on travis!
Expand Down