Skip to content

Commit b2cbaa0

Browse files
szedergitster
authored andcommitted
travis-ci: don't repeat the path of the cache directory
Some of our 'ci/*' scripts repeat the name or full path of the Travis CI cache directory, and the following patches will add new places using that path. Use a variable to refer to the path of the cache directory instead, so it's hard-coded only in a single place. Pay extra attention to the 32 bit Linux build: it runs in a Docker container, so pass the path of the cache directory from the host to the container in an environment variable. Note that an environment variable passed this way is exported inside the container, therefore its value is directly available in the 'su' snippet even though that snippet is single quoted. Furthermore, use the variable in the container only if it's been assigned a non-empty value, to prevent errors when someone is running or debugging the Docker build locally, because in that case the variable won't be set as there won't be any Travis CI cache. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 04d47e9 commit b2cbaa0

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

ci/lib-travisci.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ skip_branch_tip_with_tag () {
2121
fi
2222
}
2323

24-
good_trees_file="$HOME/travis-cache/good-trees"
25-
2624
# Save some info about the current commit's tree, so we can skip the build
2725
# job if we encounter the same tree again and can provide a useful info
2826
# message.
@@ -83,7 +81,10 @@ check_unignored_build_artifacts ()
8381
# and installing dependencies.
8482
set -ex
8583

86-
mkdir -p "$HOME/travis-cache"
84+
cache_dir="$HOME/travis-cache"
85+
good_trees_file="$cache_dir/good-trees"
86+
87+
mkdir -p "$cache_dir"
8788

8889
skip_branch_tip_with_tag
8990
skip_good_tree

ci/run-linux32-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test -z $HOST_UID || (CI_USER="ci" && useradd -u $HOST_UID $CI_USER)
2828
linux32 --32bit i386 su -m -l $CI_USER -c '
2929
set -ex
3030
cd /usr/src/git
31-
ln -s /tmp/travis-cache/.prove t/.prove
31+
test -n "$cache_dir" && ln -s "$cache_dir/.prove" t/.prove
3232
make --jobs=2
3333
make --quiet test
3434
'

ci/run-linux32-docker.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ docker pull daald/ubuntu32:xenial
1111
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/bash daald/ubuntu32:xenial
1212
# root@container:/# /usr/src/git/ci/run-linux32-build.sh
1313

14+
container_cache_dir=/tmp/travis-cache
15+
1416
docker run \
1517
--interactive \
1618
--env DEVELOPER \
1719
--env DEFAULT_TEST_TARGET \
1820
--env GIT_PROVE_OPTS \
1921
--env GIT_TEST_OPTS \
2022
--env GIT_TEST_CLONE_2GB \
23+
--env cache_dir="$container_cache_dir" \
2124
--volume "${PWD}:/usr/src/git" \
22-
--volume "${HOME}/travis-cache:/tmp/travis-cache" \
25+
--volume "$cache_dir:$container_cache_dir" \
2326
daald/ubuntu32:xenial \
2427
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)
2528

ci/run-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
. ${0%/*}/lib-travisci.sh
77

8-
ln -s $HOME/travis-cache/.prove t/.prove
8+
ln -s "$cache_dir/.prove" t/.prove
9+
910
make --quiet test
1011

1112
check_unignored_build_artifacts

0 commit comments

Comments
 (0)