-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't depend on cabal sandboxes; add travis
- Loading branch information
1 parent
2031acd
commit 984b955
Showing
6 changed files
with
183 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
language: c | ||
env: | ||
- SMT="z3" GHC="7.8.4" CABAL="1.18" | ||
- SMT="z3" GHC="7.10.1" CABAL="1.22" | ||
- SMT="cvc4" GHC="7.8.4" CABAL="1.18" | ||
- SMT="cvc4" GHC="7.10.1" CABAL="1.22" | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
cache: | ||
apt: true | ||
directories: | ||
- $HOME/.cabal | ||
- $HOME/.ghc | ||
|
||
before_install: | ||
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc | ||
- travis_retry sudo apt-get update | ||
- travis_retry sudo apt-get install cabal-install-$CABAL ghc-$GHC | ||
- export PATH=/opt/ghc/$GHC/bin:/opt/cabal/$CABAL/bin:$PATH | ||
- scripts/travis clean_cache "$SMT" | ||
|
||
install: | ||
- scripts/travis install_cabal_deps | ||
- scripts/travis install_smt "$SMT" | ||
|
||
script: | ||
- scripts/travis do_build && scripts/travis do_test "$SMT" && scripts/travis test_source_pkg | ||
- scripts/travis clean_cache "$SMT" | ||
|
||
after_failure: | ||
- scripts/travis dump_fail_logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
set -o pipefail | ||
|
||
## Helper Functions | ||
|
||
function loud { | ||
echo "$ $@" | ||
$@ | ||
} | ||
|
||
# Source: https://github.com/travis-ci/travis-build/blob/fc4ae8a2ffa1f2b3a2f62533bbc4f8a9be19a8ae/lib/travis/build/script/templates/header.sh#L104-L123 | ||
RED="\033[31;1m" | ||
GREEN="\033[32;1m" | ||
RESET="\033[0m" | ||
function travis_retry { | ||
local result=0 | ||
local count=1 | ||
while [ $count -le 3 ]; do | ||
[ $result -ne 0 ] && { | ||
echo -e "\n${RED}The command \"$@\" failed. Retrying, $count of 3.${RESET}\n" >&2 | ||
} | ||
set +e | ||
"$@" | ||
result=$? | ||
set -e | ||
[ $result -eq 0 ] && break | ||
count=$(($count + 1)) | ||
sleep 1 | ||
done | ||
|
||
[ $count -eq 4 ] && { | ||
echo "\n${RED}The command \"$@\" failed 3 times.${RESET}\n" >&2 | ||
} | ||
|
||
return $result | ||
} | ||
|
||
function prevent_timeout { | ||
local cmd="$@" | ||
|
||
$cmd & | ||
local cmd_pid=$! | ||
|
||
poke_stdout & | ||
local poke_pid=$! | ||
|
||
wait $cmd_pid | ||
exit_code=$? | ||
|
||
kill $poke_pid | ||
(wait $poke_pid 2>/dev/null) || true | ||
|
||
return $exit_code | ||
} | ||
|
||
function poke_stdout { | ||
# Print an invisible character every minute | ||
while true; do | ||
echo -ne "\xE2\x80\x8B" | ||
sleep 60 | ||
done | ||
} | ||
|
||
function pastebin { | ||
curl -s -F 'clbin=<-' https://clbin.com | ||
} | ||
|
||
## Testing Stages | ||
|
||
function clean_cache { | ||
local smt="$1" | ||
|
||
loud ghc-pkg unregister liquid-fixpoint --force || true | ||
loud rm "$HOME/.cabal/bin/$smt" || true | ||
} | ||
|
||
function install_smt { | ||
local smt="$1" | ||
|
||
mkdir -p "$HOME/.cabal/bin" | ||
loud curl "http://goto.ucsd.edu/~gridaphobe/$smt" -o "$HOME/.cabal/bin/$smt" | ||
loud chmod a+x "$HOME/.cabal/bin/$smt" | ||
} | ||
|
||
function install_cabal_deps { | ||
if ! _install_cabal_deps; then | ||
echo " ==> Cabal install failed. Clearing dependency cache and retrying." | ||
loud rm -rf "$HOME/.cabal" | ||
loud rm -rf "$HOME/.ghc" | ||
_install_cabal_deps | ||
fi | ||
} | ||
|
||
function _install_cabal_deps { | ||
loud travis_retry cabal update || return 1 | ||
loud travis_retry cabal install --reorder-goals --only-dependencies --upgrade-dependencies --enable-tests || return 1 | ||
} | ||
|
||
function do_build { | ||
loud cabal configure -fbuild-external --enable-tests -v2 | ||
loud prevent_timeout cabal build -j2 | ||
} | ||
|
||
function do_test { | ||
local tests="$1" | ||
local smt="$2" | ||
|
||
loud prevent_timeout ./dist/build/test/test --smtsolver "$smt" -j2 +RTS -N2 -RTS | ||
} | ||
|
||
function dump_fail_logs { | ||
find . -type f -wholename '*/.liquid/*' -name '*.log.fail' -print0 | while IFS= read -r -d $'\0' file; do | ||
echo "${file}:" | ||
echo " $(pastebin < "${file}")" | ||
done | ||
} | ||
|
||
function test_source_pkg { | ||
loud cabal sdist | ||
|
||
local src_tgz="dist/$(cabal info . | awk '{print $2 ".tar.gz";exit}')" | ||
|
||
if [ -f "$src_tgz" ]; then | ||
loud prevent_timeout cabal install -j4 "$src_tgz" | ||
else | ||
echo "expected '$src_tgz' not found" | ||
return 1 | ||
fi | ||
} | ||
|
||
## Run Test Stage | ||
|
||
stage="$1" | ||
shift | ||
|
||
$stage "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters