Skip to content

Commit

Permalink
.travis.yml: Move unsupported check to a script
Browse files Browse the repository at this point in the history
The unsupported check was previously a hack inside the main
Travis CI `script` block, requiring many workarounds
throughout the .travis.yml.
Travis CI now supports custom `script` blocks for each build
matrix entry, which allows the logic to be moved to an
external and more clear script.
In addition, all of the installation steps have been
removed, making these jobs much faster to complete.

Closes coala#2182
jayvdb committed Dec 21, 2017
1 parent 5c60178 commit bf90ac1
Showing 2 changed files with 47 additions and 23 deletions.
34 changes: 34 additions & 0 deletions .ci/check_unsupported.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Non-zero exit code is what we want to check
set +e

# Enable capturing the non-zero exit status of setup.py instead of tee
set -o pipefail

set -x

# mypy-lang and guess-language-spirit do not install on unsupported versions
sed -i.bak -E '/^(mypy-lang|guess-language-spirit)/d' bear-requirements.txt

python setup.py install | tee setup.log

retval=$?

set +x

# coalib.__init__.py should exit with 4 on unsupported versions of Python
# And setup.py emits something else.
if [[ $retval == 0 ]]; then
echo "Unexpected error code 0"
exit 1
else
echo "setup.py error code $retval ok"
fi

# error when no lines selected by grep
set -e

grep -q 'coala supports only python 3.4 or later' setup.log

echo "Unsupported check completed successfully"
36 changes: 13 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -9,9 +9,19 @@ python:
matrix:
include:
- python: 2.7
env: UNSUPPORTED=true
env: UNSUPPORTED=true PIP_NO_COMPILE=1
addons: false
before_install: true
install: pip install 3to2
before_script: true
script: .ci/check_unsupported.sh
- python: 3.3
env: UNSUPPORTED=true
env: UNSUPPORTED=true PIP_NO_COMPILE=1
addons: false
before_install: true
install: true
before_script: true
script: .ci/check_unsupported.sh

dist: trusty

@@ -93,32 +103,12 @@ before_install:
cat test-requirements.txt docs-requirements.txt
bear-requirements.txt >> requirements.txt
- sed -i '/^-r/d' requirements.txt
# On unsupported versions, coala will be installed in the `script` block
# mypy-lang does not install, and 3to2 must be pre-installed
# https://bitbucket.org/spirit/guess_language/issues/18
- >
if [[ "$UNSUPPORTED" == true ]]; then
pip install 3to2
export PIP_NO_COMPILE=1
sed -i.bak '/^coala/d' requirements.txt
sed -i.bak '/^mypy-lang/d' requirements.txt bear-requirements.txt
fi

before_script:
- mv requirements.orig requirements.txt
- if [[ "$UNSUPPORTED" != true ]]; then bash .ci/deps.coala-bears.sh; fi
- .ci/deps.coala-bears.sh

script:
- >
if [[ "$UNSUPPORTED" == true ]]; then
set -e
python setup.py install --no-compile | tee setup.err
grep -q 'coala supports only python 3.4 or later' setup.err
if grep -q 'Traceback (most recent call last)' setup.err; then
false
fi
fi
- if [[ "$UNSUPPORTED" == true ]]; then exit; fi
- python setup.py bdist_wheel
- pip install $(ls ./dist/*.whl)"[alldeps]"
- bash .ci/tests.sh

0 comments on commit bf90ac1

Please sign in to comment.