setup.py + .travis.yml refactor

This commit is contained in:
jab 2019-02-25 05:20:08 +00:00
parent b90821e365
commit d5e44c6cc0
3 changed files with 78 additions and 58 deletions

View File

@ -9,14 +9,13 @@ repos:
# This stopped working so comment out for now (started applying to files that didn't need it):
# - id: fix-encoding-pragma
- id: check-yaml
# Keep in sync with flake8 version in setup.py and .travis.yml --
# Keep in sync with flake8 version in setup.py --
# check https://github.com/pre-commit/pre-commit-hooks/blob/master/setup.py
# for the version of flake8 that is included with this pre-commit repo.
- id: flake8
exclude: docs/conf.py
- repo: https://github.com/chewse/pre-commit-mirrors-pydocstyle
# Keep in sync with pydocstyle version in setup.py and .travis.yml
# Keep in sync with pydocstyle version in setup.py
rev: v2.1.1
hooks:
- id: pydocstyle
@ -38,15 +37,15 @@ repos:
# - --license-filepath=.LICENSE_HEADER
- repo: https://github.com/pre-commit/mirrors-pylint
# Keep in sync with pylint version in setup.py and .travis.yml
# Keep in sync with pylint version in setup.py
rev: v2.2.2
hooks:
- id: pylint
# Needed to avoid ImportErrors when linting tests (keep in sync with versions in setup.py):
additional_dependencies: ["hypothesis<4","pytest<5", "sphinx<2"]
additional_dependencies: ["hypothesis<4","pytest<5", "Sphinx<2"]
args:
# http://pylint.pycqa.org/en/latest/user_guide/run.html#parallel-execution
# > If the provided number is 0, then the total number of CPUs will be used.
# "If the provided number is 0, then the total number of CPUs will be used."
- --jobs=0
- repo: https://github.com/jumanjihouse/pre-commit-hooks

View File

@ -8,6 +8,13 @@ python: '3.7'
dist: 'xenial'
# https://docs.travis-ci.com/user/customizing-the-build/
# "Without the top-level env, no job will be allowed to fail."
env:
global:
- 'INSTALL_EXTRAS=test'
before_install: # Ensure we have the required versions of Python and Pip.
- 'echo "TRAVIS_PULL_REQUEST_SHA: $TRAVIS_PULL_REQUEST_SHA"'
- 'echo "TRAVIS_COMMIT: $TRAVIS_COMMIT"'
@ -43,7 +50,12 @@ before_install: # Ensure we have the required versions of Python and Pip.
install: # Install our test dependencies.
- 'travis_retry pip install -U --upgrade-strategy=eager .[test$([[ "$COVERAGE" ]] && echo ",coverage")]'
- |
[[ "$COVERAGE" ]] && INSTALL_EXTRAS+=",coverage"
install_cmd="pip install -U --upgrade-strategy=eager ."
[[ "$INSTALL_EXTRAS" ]] && install_cmd+="[$INSTALL_EXTRAS]"
echo "install_cmd: $install_cmd"
travis_retry $install_cmd
before_script:
@ -57,10 +69,14 @@ before_script:
script: # Run the test suite.
# See tests/hypothesis/_setup_hypothesis.py
- 'export HYPOTHESIS_PROFILE=$([[ "$TRAVIS_EVENT_TYPE" == cron ]] && echo more-examples)'
- 'export PYTEST_ADDOPTS=$([[ "$COVERAGE" ]] && echo "--cov=bidict --cov-config=.coveragerc")'
- './run_tests.py'
- |
if [[ "$TRAVIS_EVENT_TYPE" == "cron" ]]; then
export HYPOTHESIS_PROFILE="more-examples" # See tests/hypothesis/_setup_hypothesis.py
fi
if [[ "$COVERAGE" ]]; then
export PYTEST_ADDOPTS="--cov=bidict --cov-config=.coveragerc"
fi
./run_tests.py
after_script:
@ -74,13 +90,9 @@ after_script:
fi
# https://docs.travis-ci.com/user/customizing-the-build/
# "Without the top-level env, no job will be allowed to fail."
env:
matrix:
allow_failures:
- env: 'TASK=docs-linkcheck'
- env: 'TASK=docs-linkcheck INSTALL_EXTRAS=docs'
- env: 'TASK=test-linux-cpython-3.8-dev'
- env: 'TASK=deploy-if-tag'
fast_finish: true
@ -116,33 +128,34 @@ matrix:
os: 'osx'
language: 'generic'
## Linting, static analysis, code style.
- env: 'TASK=lint-flake8'
before_install: 'skip'
install: 'travis_retry pip install "flake8<3.8"' # keep in sync with the version in setup.py
script: 'flake8 $LINT_SRC'
- env: 'TASK=lint-pylint'
before_install: 'skip'
install: 'travis_retry pip install "pylint<2.3" "hypothesis<4" "pytest<5" "Sphinx<2"' # keep in sync with the versions in setup.py
script: 'pylint --jobs=0 $LINT_SRC'
- env: 'TASK=lint-pydocstyle'
before_install: 'skip'
install: 'travis_retry pip install "pydocstyle<3.1"' # keep in sync with the version in setup.py
script: 'pydocstyle $LINT_SRC'
## Misc.
- env: 'TASK=docs-build'
before_install: 'skip'
install: 'travis_retry pip install "Sphinx<2"' # keep in sync with the version in setup.py
script: './build-docs.sh'
- env: 'TASK=test-with-optimization-flag' # make sure there are no relied-on side effects in assert statements
## Make sure there are no relied-on side effects in assert statements.
- env: 'TASK=test-with-optimization-flag'
before_install: 'skip'
install: 'skip'
script: 'python -O -m doctest -o IGNORE_EXCEPTION_DETAIL -o ELLIPSIS tests/*.txt'
## Linting, static analysis, code style.
- env: 'TASK=lint-flake8 INSTALL_EXTRAS=flake8'
before_install: 'skip'
script: 'flake8 $LINT_SRC'
- env: 'TASK=lint-pylint INSTALL_EXTRAS=pylint,test'
before_install: 'skip'
script: 'pylint --jobs=0 $LINT_SRC'
- env: 'TASK=lint-pydocstyle INSTALL_EXTRAS=pydocstyle'
before_install: 'skip'
script: 'pydocstyle $LINT_SRC'
## Misc.
- env: 'TASK=docs-build INSTALL_EXTRAS=docs'
before_install: 'skip'
script: './build-docs.sh'
- env: 'TASK=docs-linkcheck INSTALL_EXTRAS=docs'
before_install: 'skip'
script: '(cd docs && travis_retry make linkcheck)'
## Remaining CPython versions on Linux.
- python: '3.6'
env: 'TASK=test-linux-cpython-3.6'
@ -150,12 +163,6 @@ matrix:
- python: '3.5'
env: 'TASK=test-linux-cpython-3.5'
## Misc.
- env: 'TASK=docs-linkcheck'
before_install: 'skip'
install: 'travis_retry pip install "Sphinx<2"' # keep in sync with the version in setup.py
script: '(cd docs && travis_retry make linkcheck)'
- python: '3.8-dev'
env: 'TASK=test-linux-cpython-3.8-dev'

View File

@ -70,17 +70,36 @@ COVERAGE_REQS = [
'pytest-cov < 3',
]
DEV_REQ = SETUP_REQS + TEST_REQS + COVERAGE_REQS + DOCS_REQS + [
# The following dependencies have a higher chance of suddenly causing CI to fail after updating
# even between minor versions, so pin to currently-working minor versions. Upgrade to newer
# minor versions manually to have a chance to fix any resulting breakage before it hits CI.
FLAKE8_REQ = 'flake8 < 3.8'
PYDOCSTYLE_REQ = 'pydocstyle < 3.1'
PYLINT_REQ = 'pylint < 2.3'
LINT_REQS = [
FLAKE8_REQ,
PYDOCSTYLE_REQ,
PYLINT_REQ,
]
DEV_REQS = SETUP_REQS + DOCS_REQS + TEST_REQS + COVERAGE_REQS + LINT_REQS + [
'pre-commit < 2',
'tox < 4',
# The following dependencies have a higher chance of suddenly causing CI to fail after updating
# even between minor versions so pin to currently-working minor versions. Upgrade to newer
# minor versions manually to have a chance to fix any resulting breakage before it hits CI.
'flake8 < 3.8',
'pydocstyle < 3.1',
'pylint < 2.3',
]
EXTRAS_REQS = dict(
docs=DOCS_REQS,
test=TEST_REQS,
coverage=COVERAGE_REQS,
lint=LINT_REQS,
dev=DEV_REQS,
sphinx=[SPHINX_REQ],
flake8=[FLAKE8_REQ],
pydocstyle=[PYDOCSTYLE_REQ],
pylint=[PYLINT_REQ],
)
setup(
name='bidict',
use_scm_version={
@ -114,10 +133,5 @@ setup(
setup_requires=SETUP_REQS, # required so pip < 10 install works (no PEP-517/518 support)
# for more details see https://www.python.org/dev/peps/pep-0518/#rationale
tests_require=TEST_REQS,
extras_require=dict(
test=TEST_REQS,
coverage=COVERAGE_REQS,
docs=DOCS_REQS,
dev=DEV_REQ,
),
extras_require=EXTRAS_REQS,
)