Skip to content

Commit 0bd67b7

Browse files
gonewest818bbatsov
authored andcommitted
[#2129] Мake evm and cask setup more reliable in travis (#2139)
Resolves [#2129] with new scripts to setup evm and cask in Travis builds. These scripts improve on the prior process by adding error detection with retries, such that network errors during this setup stage are less likely to abort the build with mysterious errors. In addition to the retry logic, we also cache the installations of evm and cask such that the contents of those directories are restored across successful builds. This eliminates the requirement to install evm and cask from scratch. It is possible to force-delete these caches if needed. The net result of all this is, most incremental builds need only attempt to update evm and cask (essentially a git pull) and update any needed elisp packages via cask update.
1 parent d63a7df commit 0bd67b7

File tree

5 files changed

+88
-6
lines changed

5 files changed

+88
-6
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cache:
2020

2121
env:
2222
global:
23-
- PATH=$HOME/local/bin:$PATH
23+
- PATH=$HOME/local/bin:$HOME/local/evm/bin:$HOME/local/cask/bin:$PATH
2424
matrix:
2525
- EMACS_BINARY=emacs-24.4-travis MAKE_TEST=test
2626
- EMACS_BINARY=emacs-24.4-travis MAKE_TEST=test-bytecomp
@@ -41,11 +41,11 @@ env:
4141
- EMACS_BINARY=emacs-git-snapshot-travis MAKE_TEST=test-checks
4242

4343
before_script:
44-
- sudo sh travis-ci/travis-gnutls.sh
44+
- sh travis-ci/install-gnutls.sh
4545
- gnutls-cli -v
46-
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
46+
- sh travis-ci/install-evm.sh
4747
- evm install $EMACS_BINARY --use --skip
48-
- make elpa
48+
- sh travis-ci/install-cask.sh
4949
script:
5050
- emacs --version
5151
- make $MAKE_TEST

travis-ci/install-cask.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Install cask for Travis CI
4+
# or if already installed, then check for updates
5+
6+
set -x
7+
8+
WORKDIR=${HOME}/local
9+
CASKDIR=$WORKDIR/cask
10+
11+
. travis-ci/retry.sh
12+
13+
cask_upgrade_cask_or_reset() {
14+
cask upgrade-cask || { rm -rf $HOME/.emacs.d/.cask && false; }
15+
}
16+
17+
cask_install_or_reset() {
18+
cask install || { rm -rf .cask && false; }
19+
}
20+
21+
# Bootstrap the cask tool and its dependencies
22+
if [ -d $CASKDIR ]
23+
then
24+
travis_retry cask_upgrade_cask_or_reset
25+
else
26+
git clone https://github.com/cask/cask.git $CASKDIR
27+
travis_retry cask_upgrade_cask_or_reset
28+
fi
29+
30+
# Install dependencies for cider as descriped in ./Cask
31+
# Effect is identical to "make elpa", but here we can retry
32+
# in the event of network failures.
33+
travis_retry cask_install_or_reset && touch elpa-emacs

travis-ci/install-evm.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Install evm for Travis CI
4+
# or if already installed, then check for updates
5+
6+
set -x
7+
8+
WORKDIR=${HOME}/local
9+
EVMDIR=$WORKDIR/evm
10+
11+
. travis-ci/retry.sh
12+
13+
if [ -d $EVMDIR ]
14+
then
15+
cd $EVMDIR
16+
git pull origin master
17+
else
18+
git clone https://github.com/rejeep/evm.git $EVMDIR
19+
evm config path /tmp
20+
travis_retry evm install emacs-24.3-travis --use --skip
21+
fi

travis-ci/travis-gnutls.sh renamed to travis-ci/install-gnutls.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ then
2323
fi
2424

2525
# delete cache and rebuild
26-
rm -rf $WORKDIR
27-
mkdir $WORKDIR
26+
rm -rf $WORKDIR/bin $WORKDIR/lib $WORKDIR/share $WORKDIR/include
27+
rm -rf $WORKDIR/nettle* $WORKDIR/gnutls*
28+
2829
cd $WORKDIR
2930
curl -O https://ftp.gnu.org/gnu/nettle/nettle-${NETTLE_VERSION}.tar.gz \
3031
&& tar xfz nettle-${NETTLE_VERSION}.tar.gz \

travis-ci/retry.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copied retry logic from Travis CI [http://bit.ly/2jPDCtV]
2+
3+
ANSI_RED="\033[31;1m"
4+
ANSI_GREEN="\033[32;1m"
5+
ANSI_RESET="\033[0m"
6+
ANSI_CLEAR="\033[0K"
7+
8+
travis_retry() {
9+
local result=0
10+
local count=1
11+
while [ $count -le 3 ]; do
12+
[ $result -ne 0 ] && {
13+
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
14+
}
15+
"$@"
16+
result=$?
17+
[ $result -eq 0 ] && break
18+
count=$(($count + 1))
19+
sleep 1
20+
done
21+
22+
[ $count -gt 3 ] && {
23+
echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
24+
}
25+
26+
return $result
27+
}

0 commit comments

Comments
 (0)