freeipa/.travis_run_task.sh
Stanislav Levin 3f33ac88bd Make pycodestyle results identical
Currently, pycodestyle is running on:
- make fastlint:
  `$(PYTHON) -m pycodestyle --diff`

  According to docs:
  ```
  The project options are read from the [pycodestyle] section of the
  tox.ini file or the setup.cfg file located in any parent folder of the
  path(s) being processed.
  ```

  So, pycodestyle respects tox.ini:
  ```
  [pycodestyle]
  # E402 module level import not at top of file
  # W504 line break after binary operator
  ignore = E402, W504
  ```

- PR Travis `lint`:
  `pycodestyle --ignore=W504 --diff &> $PEP8_ERROR_LOG ||:`

  According to docs:
  ```
  Please note that if the option –ignore=errors is used, the
  default configuration will be overridden and ignore only the
  check(s) you skip.
  ```

  So, pycodestyle doesn't respect tox.ini.

For now, fastlint ignores E402, W504, while Travis lint ignores only W504.
This issue is exposed by Azure Pipelines, which employs fastlint.

Fixes: https://pagure.io/freeipa/issue/7962
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
2019-05-28 10:01:23 +03:00

66 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
#
# NOTE: this script is intended to run in Travis CI only
test_set=""
env_opt=""
case "$TASK_TO_RUN" in
lint|tox)
# disable developer mode for lint and tox tasks.
developer_mode_opt=""
;;
*)
developer_mode_opt="--developer-mode"
;;
esac
function truncate_log_to_test_failures() {
# chop off everything in the CI_RESULTS_LOG preceding pytest error output
# if there are pytest errors in the log
error_fail_regexp='\(=== ERRORS ===\)\|\(=== FAILURES ===\)'
if grep -e "$error_fail_regexp" $CI_RESULTS_LOG > /dev/null
then
sed -i "/$error_fail_regexp/,\$!d" $CI_RESULTS_LOG
fi
}
if [[ "$TASK_TO_RUN" == "lint" ]]
then
if [[ "$TRAVIS_EVENT_TYPE" == "pull_request" ]]
then
git diff origin/$TRAVIS_BRANCH -U0 | \
pycodestyle --diff &> $PEP8_ERROR_LOG ||:
fi
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-environment "RPMBUILD_OPTS=$env_opt" \
--container-image $TEST_RUNNER_IMAGE \
--git-repo $TRAVIS_BUILD_DIR \
$TASK_TO_RUN $test_set
exit_status="$?"
if [[ "$exit_status" -ne 0 ]]
then
truncate_log_to_test_failures
fi
exit $exit_status