Skip to content

Commit

Permalink
Enable ccache for Alpine builds on Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Feb 14, 2019
1 parent d4d52ac commit 1e7b77e
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ services:
echo "Skip build of $Dockerfile as it's not changed."
exit
fi
if [ "alpine" = "$VARIANT" ]; then
./AlpineCCacheTravisInjection.sh
mkdir -p ccache
(
cd ccache
ls -l
md5sum *
nc -v -l -p 5678 -q 1 < cache.tgz &
nc -v -l -p 1234 -q 1 > new-cache.tgz &
)
fi
script: ./test-build.sh $NODE_VERSION $VARIANT

Expand Down Expand Up @@ -125,6 +136,16 @@ jobs:
- NODE_VERSION="10"
- VARIANT="alpine"

before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/

- stage: Build
before_script: *auto_skip
name: 10 on stretch
Expand All @@ -146,6 +167,16 @@ jobs:
- NODE_VERSION="11"
- VARIANT="alpine"

before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/

- stage: Build
before_script: *auto_skip
name: 11 on stretch
Expand Down Expand Up @@ -181,6 +212,16 @@ jobs:
- NODE_VERSION="6"
- VARIANT="alpine"

before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/

- stage: Build
before_script: *auto_skip
name: 6 on onbuild
Expand Down Expand Up @@ -223,6 +264,16 @@ jobs:
- NODE_VERSION="8"
- VARIANT="alpine"

before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/

- stage: Build
before_script: *auto_skip
name: 8 on onbuild
Expand Down
3 changes: 3 additions & 0 deletions 10/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN addgroup -g 1000 node \
linux-headers \
make \
python \
# Travis CI build deps injection
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
Expand All @@ -40,10 +41,12 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
# Travis CI ccache env setup and cache restore
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& apk del .build-deps \
# Travis CI ccache summary, store and cleanup
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
3 changes: 3 additions & 0 deletions 11/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN addgroup -g 1000 node \
linux-headers \
make \
python \
# Travis CI build deps injection
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
Expand All @@ -40,10 +41,12 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
# Travis CI ccache env setup and cache restore
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& apk del .build-deps \
# Travis CI ccache summary, store and cleanup
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
3 changes: 3 additions & 0 deletions 6/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN addgroup -g 1000 node \
linux-headers \
make \
python \
# Travis CI build deps injection
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
Expand All @@ -40,10 +41,12 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
# Travis CI ccache env setup and cache restore
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& apk del .build-deps \
# Travis CI ccache summary, store and cleanup
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
3 changes: 3 additions & 0 deletions 8/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN addgroup -g 1000 node \
linux-headers \
make \
python \
# Travis CI build deps injection
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
Expand All @@ -40,10 +41,12 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
# Travis CI ccache env setup and cache restore
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& apk del .build-deps \
# Travis CI ccache summary, store and cleanup
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
14 changes: 14 additions & 0 deletions AlpineCCacheTravisInjection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -ue

for dockerfile in **/alpine/Dockerfile; do
# shellcheck disable=SC2016
sed -Ei -e 's/# Travis CI build deps injection/ ccache netcat-openbsd \\/' \
-e "s/# Travis CI ccache env setup and cache restore/&\n \&\& nc -v \"\$HOST_IP\" 5678 | tar -xz -C \/ || true \\\/" \
-e "s/# Travis CI ccache env setup and cache restore/&\n \&\& HOST_IP=\"\$(ip route | awk '\/default\/ { print \$3 \}')\" \\\/" \
-e 's/# Travis CI ccache env setup and cache restore/&\n \&\& ccache --set-config=max_size=150MB \\/' \
-e 's/# Travis CI ccache env setup and cache restore/\&\& export PATH="\/usr\/lib\/ccache\/bin\/:$PATH" \\/' \
-e 's/# Travis CI ccache summary, store and cleanup/&\n \&\& rm -rf \/root\/.ccache\/ \\/' \
-e 's/# Travis CI ccache summary, store and cleanup/&\n \&\& ccache -s 1>\&2 \\/' \
-e 's/# Travis CI ccache summary, store and cleanup/\&\& tar -czf - \/root\/.ccache\/ | nc -v -w 3 "$HOST_IP" 1234 || true \\/' "${dockerfile}"
done
3 changes: 3 additions & 0 deletions Dockerfile-alpine.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN addgroup -g 1000 node \
linux-headers \
make \
python \
# Travis CI build deps injection
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& for key in \
"${NODE_KEYS[@]}"
Expand All @@ -30,10 +31,12 @@ RUN addgroup -g 1000 node \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
# Travis CI ccache env setup and cache restore
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) \
&& make install \
&& apk del .build-deps \
# Travis CI ccache summary, store and cleanup
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt
Expand Down
11 changes: 11 additions & 0 deletions travis.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ services:
echo "Skip build of $Dockerfile as it's not changed."
exit
fi
if [ "alpine" = "$VARIANT" ]; then
./AlpineCCacheTravisInjection.sh
mkdir -p ccache
(
cd ccache
ls -l
md5sum *
nc -v -l -p 5678 -q 1 < cache.tgz &
nc -v -l -p 1234 -q 1 > new-cache.tgz &
)
fi

script: ./test-build.sh $NODE_VERSION $VARIANT

Expand Down
12 changes: 12 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ function add_stage() {
env:
- NODE_VERSION="'"${version}"'"
- VARIANT="'"${variant}"'"' >> .travis.yml
if [ "alpine" = "${variant}" ]; then
echo '
before_cache:
- ls -hl ccache/
- ls -l ccache/
- file ccache/*
- md5sum ccache/*
- mv ccache/new-cache.tgz ccache/cache.tgz
cache:
directories:
- ccache/' >> .travis.yml
fi
}

echo '# DO NOT MODIFY. THIS FILE IS AUTOGENERATED #
Expand Down

0 comments on commit 1e7b77e

Please sign in to comment.