Skip to content

Commit d9fbd1a

Browse files
Merge pull request nodejs#918 from PeterDaveHello/enable-ccache-for-TravisCI-alpine-builds
Enable ccache for Alpine builds on Travis CI
2 parents 71b7279 + 7e5b3f0 commit d9fbd1a

File tree

8 files changed

+127
-0
lines changed

8 files changed

+127
-0
lines changed

.travis.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ services:
3030
echo "Skip build of $Dockerfile as it's not changed."
3131
exit
3232
fi
33+
if [ "alpine" = "$VARIANT" ]; then
34+
mkdir -p ccache
35+
(
36+
cd ccache
37+
ls -l
38+
md5sum *
39+
nc -v -l -p 5678 -q 1 < cache.tgz &
40+
nc -v -l -p 1234 -q 1 > new-cache.tgz &
41+
)
42+
fi
3343
3444
script: ./test-build.sh $NODE_VERSION $VARIANT
3545

@@ -116,6 +126,16 @@ jobs:
116126
- NODE_VERSION: "10"
117127
- VARIANT: "alpine"
118128

129+
before_cache:
130+
- ls -hl ccache/
131+
- ls -l ccache/
132+
- file ccache/*
133+
- md5sum ccache/*
134+
- mv ccache/new-cache.tgz ccache/cache.tgz
135+
cache:
136+
directories:
137+
- ccache/
138+
119139
- stage: Build
120140
before_script: *auto_skip
121141
env:
@@ -134,6 +154,16 @@ jobs:
134154
- NODE_VERSION: "11"
135155
- VARIANT: "alpine"
136156

157+
before_cache:
158+
- ls -hl ccache/
159+
- ls -l ccache/
160+
- file ccache/*
161+
- md5sum ccache/*
162+
- mv ccache/new-cache.tgz ccache/cache.tgz
163+
cache:
164+
directories:
165+
- ccache/
166+
137167
- stage: Build
138168
before_script: *auto_skip
139169
env:
@@ -158,6 +188,16 @@ jobs:
158188
- NODE_VERSION: "6"
159189
- VARIANT: "alpine"
160190

191+
before_cache:
192+
- ls -hl ccache/
193+
- ls -l ccache/
194+
- file ccache/*
195+
- md5sum ccache/*
196+
- mv ccache/new-cache.tgz ccache/cache.tgz
197+
cache:
198+
directories:
199+
- ccache/
200+
161201
- stage: Build
162202
before_script: *auto_skip
163203
env:
@@ -188,6 +228,16 @@ jobs:
188228
- NODE_VERSION: "8"
189229
- VARIANT: "alpine"
190230

231+
before_cache:
232+
- ls -hl ccache/
233+
- ls -l ccache/
234+
- file ccache/*
235+
- md5sum ccache/*
236+
- mv ccache/new-cache.tgz ccache/cache.tgz
237+
cache:
238+
directories:
239+
- ccache/
240+
191241
- stage: Build
192242
before_script: *auto_skip
193243
env:

10/alpine/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
1111
curl \
1212
g++ \
1313
gcc \
14+
ccache \
15+
netcat-openbsd \
1416
gnupg \
1517
libgcc \
1618
linux-headers \
@@ -38,10 +40,19 @@ RUN addgroup -g 1000 node \
3840
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
3941
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
4042
&& cd "node-v$NODE_VERSION" \
43+
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
44+
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
45+
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
46+
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
47+
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
4148
&& ./configure \
4249
&& make -j$(getconf _NPROCESSORS_ONLN) \
4350
&& make install \
51+
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
52+
&& ccache -s 1>&2 \
4453
&& apk del .build-deps \
54+
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
55+
&& rm -rf /root/.ccache/ \
4556
&& cd .. \
4657
&& rm -Rf "node-v$NODE_VERSION" \
4758
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt

11/alpine/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
1111
curl \
1212
g++ \
1313
gcc \
14+
ccache \
15+
netcat-openbsd \
1416
gnupg \
1517
libgcc \
1618
linux-headers \
@@ -38,10 +40,19 @@ RUN addgroup -g 1000 node \
3840
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
3941
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
4042
&& cd "node-v$NODE_VERSION" \
43+
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
44+
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
45+
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
46+
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
47+
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
4148
&& ./configure \
4249
&& make -j$(getconf _NPROCESSORS_ONLN) \
4350
&& make install \
51+
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
52+
&& ccache -s 1>&2 \
4453
&& apk del .build-deps \
54+
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
55+
&& rm -rf /root/.ccache/ \
4556
&& cd .. \
4657
&& rm -Rf "node-v$NODE_VERSION" \
4758
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt

6/alpine/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
1111
curl \
1212
g++ \
1313
gcc \
14+
ccache \
15+
netcat-openbsd \
1416
gnupg \
1517
libgcc \
1618
linux-headers \
@@ -38,10 +40,19 @@ RUN addgroup -g 1000 node \
3840
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
3941
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
4042
&& cd "node-v$NODE_VERSION" \
43+
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
44+
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
45+
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
46+
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
47+
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
4148
&& ./configure \
4249
&& make -j$(getconf _NPROCESSORS_ONLN) \
4350
&& make install \
51+
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
52+
&& ccache -s 1>&2 \
4453
&& apk del .build-deps \
54+
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
55+
&& rm -rf /root/.ccache/ \
4556
&& cd .. \
4657
&& rm -Rf "node-v$NODE_VERSION" \
4758
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt

8/alpine/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
1111
curl \
1212
g++ \
1313
gcc \
14+
ccache \
15+
netcat-openbsd \
1416
gnupg \
1517
libgcc \
1618
linux-headers \
@@ -38,10 +40,19 @@ RUN addgroup -g 1000 node \
3840
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
3941
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
4042
&& cd "node-v$NODE_VERSION" \
43+
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
44+
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
45+
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
46+
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
47+
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
4148
&& ./configure \
4249
&& make -j$(getconf _NPROCESSORS_ONLN) \
4350
&& make install \
51+
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
52+
&& ccache -s 1>&2 \
4453
&& apk del .build-deps \
54+
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
55+
&& rm -rf /root/.ccache/ \
4556
&& cd .. \
4657
&& rm -Rf "node-v$NODE_VERSION" \
4758
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt

Dockerfile-alpine.template

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RUN addgroup -g 1000 node \
1111
curl \
1212
g++ \
1313
gcc \
14+
ccache \
15+
netcat-openbsd \
1416
gnupg \
1517
libgcc \
1618
linux-headers \
@@ -30,10 +32,19 @@ RUN addgroup -g 1000 node \
3032
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
3133
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
3234
&& cd "node-v$NODE_VERSION" \
35+
&& ln -s /usr/bin/ccache /usr/local/bin/cc \
36+
&& ln -s /usr/bin/ccache /usr/local/bin/gcc \
37+
&& ln -s /usr/bin/ccache /usr/local/bin/g++ \
38+
&& HOST_IP="$(ip route | awk '/default/ { print $3 }')" \
39+
&& nc -v "$HOST_IP" 5678 | tar -xz -C / || true \
3340
&& ./configure \
3441
&& make -j$(getconf _NPROCESSORS_ONLN) \
3542
&& make install \
43+
&& rm -f /usr/local/bin/gcc /usr/local/bin/g++ \
44+
&& ccache -s 1>&2 \
3645
&& apk del .build-deps \
46+
&& tar -czf - /root/.ccache/ | nc -v -w 3 "$HOST_IP" 1234 \
47+
&& rm -rf /root/.ccache/ \
3748
&& cd .. \
3849
&& rm -Rf "node-v$NODE_VERSION" \
3950
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt

travis.yml.template

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ services:
2828
echo "Skip build of $Dockerfile as it's not changed."
2929
exit
3030
fi
31+
if [ "alpine" = "$VARIANT" ]; then
32+
mkdir -p ccache
33+
(
34+
cd ccache
35+
ls -l
36+
md5sum *
37+
nc -v -l -p 5678 -q 1 < cache.tgz &
38+
nc -v -l -p 1234 -q 1 > new-cache.tgz &
39+
)
40+
fi
3141

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

update.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ function add_stage() {
192192
env:
193193
- NODE_VERSION: "'"${version}"'"
194194
- VARIANT: "'"${variant}"'"' >> .travis.yml
195+
if [ "alpine" = "${variant}" ]; then
196+
echo '
197+
before_cache:
198+
- ls -hl ccache/
199+
- ls -l ccache/
200+
- file ccache/*
201+
- md5sum ccache/*
202+
- mv ccache/new-cache.tgz ccache/cache.tgz
203+
cache:
204+
directories:
205+
- ccache/' >> .travis.yml
206+
fi
195207
}
196208

197209
echo '# DO NOT MODIFY. THIS FILE IS AUTOGENERATED #

0 commit comments

Comments
 (0)