Travis CI: a separate script to run test tasks

this script is intended only for use in Travis CI and contains
configuration of the test run requested:

    * it can run linter step separately by specifying TASK_TO_RUN="lint"
      environment variable in .travis.yml. In this case it also runs
      pep8 checker on the commits in PR.
    * other steps are run in developer mode in order to skip pylint run
      and speed up the task
    * in all cases the CI result log is populated and can be displayed
      if the job fails

Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
This commit is contained in:
Martin Babinsky 2016-12-20 15:55:55 +01:00
parent aff4e684e1
commit 1267e3e723

34
.travis_run_task.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# NOTE: this script is intended to run in Travis CI only
set -ev
test_set=""
developer_mode_opt="--developer-mode"
if [[ "$TASK_TO_RUN" == "lint" ]]
then
if [[ "$TRAVIS_EVENT_TYPE" == "pull_request" ]]
then
git diff origin/$TRAVIS_BRANCH -U0 | pep8 --diff &> $PEP8_ERROR_LOG ||:
fi
# disable developer mode for lint task, otherwise we get an error
developer_mode_opt=""
fi
if [[ -n "$TESTS_TO_RUN" ]]
then
pushd ipatests
test_set=`ls -d -1 $TESTS_TO_RUN 2> /dev/null | tr '\n' ' '`
popd
fi
docker pull $TEST_RUNNER_IMAGE
ipa-docker-test-runner -l $CI_RESULTS_LOG \
-c $TEST_RUNNER_CONFIG \
$developer_mode_opt \
--container-image $TEST_RUNNER_IMAGE \
--git-repo $TRAVIS_BUILD_DIR \
$TASK_TO_RUN $test_set