Skip to content

Commit

Permalink
Refactor use of pip-compile (#1655)
Browse files Browse the repository at this point in the history
* rename test-requirements.txt to constraints.txt to better reflect its
  purpose
* move test dependencies into test extra so custom rule authors can
  easily install them
  • Loading branch information
ssbarnea committed Aug 20, 2021
1 parent 95aeb4f commit 200e69c
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 71 deletions.
57 changes: 30 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,6 @@ repos:
language: system
files: >-
^setup\.py$
- id: pip-compile
name: pip-compile
entry: pip-compile -q --no-annotate --output-file=test-requirements.txt setup.cfg test-requirements.in
language: system
files: ^(test-requirements\.(txt|in)|setup\.cfg)$
pass_filenames: false
- id: pip-compile-docs
name: pip-compile-docs
entry: pip-compile -q --no-annotate --output-file=docs/requirements.txt docs/requirements.in setup.cfg
language: system
files: ^(docs\/requirements\.(txt|in)|setup\.cfg)$
pass_filenames: false
- id: pip-compile-upgrade
name: pip-compile-upgrade
entry: pip-compile -q --upgrade --no-annotate --output-file=test-requirements.txt setup.cfg test-requirements.in
language: system
files: ^(test-requirements\.(txt|in)|setup\.cfg)$
pass_filenames: false
stages: [manual]
- id: pip-compile-docs-upgrade
name: pip-compile-docs-upgrade
entry: pip-compile -q --upgrade --no-annotate --output-file=docs/requirements.txt docs/requirements.in setup.cfg
language: system
files: ^(docs\/requirements\.(txt|in)|setup\.cfg)$
pass_filenames: false
stages: [manual]
- repo: https://github.com/pre-commit/pre-commit-hooks.git
rev: v4.0.1
hooks:
Expand All @@ -69,7 +43,7 @@ repos:
hooks:
- id: doc8
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.26.1
rev: v1.26.2
hooks:
- id: yamllint
exclude: >
Expand Down Expand Up @@ -145,3 +119,32 @@ repos:
- tenacity
- typing_extensions
- wcmatch
- # keep at bottom as these are slower
repo: local
hooks:
- id: pip-compile
name: pip-compile
entry: pip-compile -q --no-annotate --output-file=constraints.txt setup.py setup.cfg --extra test --extra yamllint
language: system
files: ^(setup\.cfg|=constraints\.txt)$
pass_filenames: false
- id: pip-compile-docs
name: pip-compile-docs
entry: pip-compile -q --no-annotate --output-file=docs/requirements.txt --extra yamllint docs/requirements.in setup.cfg
language: system
files: ^(docs\/requirements\.(txt|in)|)$
pass_filenames: false
- id: pip-compile-upgrade
name: pip-compile-upgrade
entry: pip-compile -q --upgrade --no-annotate --output-file=constraints.txt setup.py setup.cfg --extra test --extra yamllint
language: system
files: ^(setup\.cfg|=constraints\.txt)$
pass_filenames: false
stages: [manual]
- id: pip-compile-docs-upgrade
name: pip-compile-docs-upgrade
entry: pip-compile -q --upgrade --no-annotate --extra yamllint --output-file=docs/requirements.txt docs/requirements.in setup.cfg
language: system
files: ^(docs\/requirements\.(txt|in)|)$
pass_filenames: false
stages: [manual]
13 changes: 6 additions & 7 deletions test-requirements.txt → constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --no-annotate --output-file=test-requirements.txt setup.cfg test-requirements.in
# pip-compile --extra=test --extra=yamllint --no-annotate --output-file=constraints.txt setup.cfg setup.py
#
attrs==21.2.0
bracex==2.1.1
Expand All @@ -14,22 +14,21 @@ execnet==1.9.0
flaky==3.7.0
iniconfig==1.1.1
packaging==21.0
pathspec==0.9.0
pluggy==0.13.1
psutil==5.8.0
py==1.10.0
pygments==2.9.0
pygments==2.10.0
pyparsing==2.4.7
pytest==6.2.4
pytest-cov==2.12.1
pytest-forked==1.3.0
pytest-xdist==2.3.0
pyyaml==5.4.1
rich==10.6.0
ruamel.yaml==0.17.10 ; python_version >= "3.7"
rich==10.7.0
ruamel.yaml==0.17.11 ; python_version >= "3.7"
ruamel.yaml.clib==0.2.6
tenacity==8.0.1
toml==0.10.2
wcmatch==8.2

# The following packages are considered to be unsafe in a requirements file:
# setuptools
yamllint==1.26.2
40 changes: 20 additions & 20 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --no-annotate --output-file=docs/requirements.txt docs/requirements.in setup.cfg
# pip-compile --extra=yamllint --no-annotate --output-file=docs/requirements.txt docs/requirements.in setup.cfg
#
alabaster==0.7.12
ansible-base==2.10.10
ansible-base==2.10.13
ansible-pygments==0.1.0
attrs==21.2.0
babel==2.9.1
bracex==2.1.1
certifi==2021.5.30
cffi==1.14.5
chardet==4.0.0
cffi==1.14.6
charset-normalizer==2.0.4
colorama==0.4.4
commonmark==0.9.1
cryptography==3.4.7
docutils==0.16
enrich==1.2.6
idna==2.10
idna==3.2
imagesize==1.2.0
iniconfig==1.1.1
jinja2==3.0.1
markdown-it-py==1.1.0
markupsafe==2.0.1
mdit-py-plugins==0.2.8
myst-parser==0.14.0
packaging==20.9
pathspec==0.8.1
myst-parser==0.15.1
packaging==21.0
pathspec==0.9.0
pbr==5.6.0
pipdeptree==2.0.0
pipdeptree==2.1.0
pluggy==0.13.1
py==1.10.0
pycparser==2.20
pygments==2.9.0
pygments==2.10.0
pyparsing==2.4.7
pytest==6.2.4
pytz==2021.1
pyyaml==5.4.1
requests==2.25.1
rich==10.2.2
ruamel.yaml==0.17.7 ; python_version >= "3.7"
ruamel.yaml.clib==0.2.2
six==1.16.0
requests==2.26.0
rich==10.7.0
ruamel.yaml==0.17.11 ; python_version >= "3.7"
ruamel.yaml.clib==0.2.6
snowballstemmer==2.1.0
sphinx==3.5.4
sphinx-ansible-theme==0.5.0
sphinx==4.1.2
sphinx-ansible-theme==0.8.0
sphinx-rtd-theme==0.5.2
sphinxcontrib-apidoc==0.3.0
sphinxcontrib-applehelp==1.0.2
Expand All @@ -54,11 +54,11 @@ sphinxcontrib-jsmath==1.0.1
sphinxcontrib-programoutput2==2.0a1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tenacity==7.0.0
tenacity==8.0.1
toml==0.10.2
urllib3==1.26.5
urllib3==1.26.6
wcmatch==8.2
yamllint==1.26.1
yamllint==1.26.2

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ core =
# yamllint must remain optional
yamllint =
yamllint >= 1.25.0 # GPLv3
test =
flaky >= 3.7.0
pytest >= 6.0.1
pytest-cov >= 2.10.1
pytest-xdist >= 2.1.0
psutil # soft-dep of pytest-xdist

[options.packages.find]
where = src
Expand Down
11 changes: 0 additions & 11 deletions test-requirements.in

This file was deleted.

20 changes: 14 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ description =
extras =
yamllint
core: core
; devel: devel
test
deps =
ansible29: ansible>=2.9,<2.10
py: ansible-core>=2.11
devel: ansible-core @ git+https://github.com/ansible/ansible.git # GPLv3+
-r test-requirements.in
-c test-requirements.txt
commands =
# safety measure to assure we do not accidentally run tests with broken dependencies
{envpython} -m pip check
Expand Down Expand Up @@ -59,6 +57,7 @@ passenv =
# recreate = True
setenv =
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
PIP_CONSTRAINT = {toxinidir}/constraints.txt
PIP_DISABLE_PIP_VERSION_CHECK = 1
PRE_COMMIT_COLOR = always
FORCE_COLOR = 1
Expand All @@ -67,7 +66,9 @@ whitelist_externals =

[testenv:lint]
description = Run all linters
basepython = python3
# pip compile includes python version in output constraints, so we want to
# be sure that version does not change randomly.
basepython = python3.9
deps =
pre-commit>=2.6.0
pip-tools>=6.2.0
Expand All @@ -84,7 +85,11 @@ description = Bump all test depeendencies
# we reuse the lint environment
envdir = {toxworkdir}/lint
skip_install = true
deps = {[testenv:lint]deps}
deps =
pre-commit>=2.14.0
setenv =
# without his upgrade would likely not do anything
PIP_CONSTRAINT = /dev/null
commands =
# manual hook calls the optional pip-compile-upgrade hook
{[testenv:lint]commands} --hook-stage manual pip-compile-upgrade
Expand All @@ -95,7 +100,8 @@ description = Builds docs
basepython = python3
deps =
-r{toxinidir}/docs/requirements.in
-c{toxinidir}/docs/requirements.txt
setenv =
PIP_CONSTRAINT = {toxinidir}/docs/requirements.txt
commands =
# Build the html docs with Sphinx:
{envpython} -m sphinx \
Expand All @@ -119,6 +125,8 @@ changedir = {toxinidir}/docs
description = Linkcheck The Docs
basepython = {[testenv:docs]basepython}
deps = {[testenv:docs]deps}
setenv =
{[testenv:docs]setenv}
commands =
{envpython} -m sphinx \
-j auto \
Expand Down

0 comments on commit 200e69c

Please sign in to comment.