Skip to content

Commit

Permalink
Start using constraints during testing (#3209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Aug 26, 2021
1 parent 1baf3c7 commit b351ea0
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 20 deletions.
29 changes: 12 additions & 17 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,33 @@ jobs:
matrix:
include:
- tox_env: lint
python-version: 3.9
- tox_env: docs
python-version: 3.9
- tox_env: py36
PREFIX: PYTEST_REQPASS=448
python-version: 3.6
- tox_env: py37
PREFIX: PYTEST_REQPASS=448
python-version: 3.7
- tox_env: py38
PREFIX: PYTEST_REQPASS=448
python-version: 3.8
- tox_env: py39
PREFIX: PYTEST_REQPASS=448
python-version: 3.9
- tox_env: py36-devel
PREFIX: PYTEST_REQPASS=448
python-version: 3.6
- tox_env: py39-devel
PREFIX: PYTEST_REQPASS=448
python-version: 3.9
- tox_env: packaging
python-version: 3.9
- tox_env: eco
python-version: 3.9
- tox_env: dockerfile
python-version: 3.9

steps:
- uses: actions/checkout@v1
Expand All @@ -58,26 +69,10 @@ jobs:
&& virtualenv foo \
&& source foo/bin/activate \
&& ansible --version
- name: Find python version
id: py_ver
shell: python
if: ${{ contains(matrix.tox_env, 'py') }}
run: |
v = '${{ matrix.tox_env }}'.split('-')[0].lstrip('py')
print('::set-output name=version::{0}.{1}'.format(v[0],v[1:]))
# Even our lint and other envs need access to tox
- name: Install a default Python
uses: actions/setup-python@v2
# workaround to avoid getting 3.9 in:
with:
python-version: '3.8'
if: ${{ ! contains(matrix.tox_env, 'py') }}
# Be sure to install the version of python needed by a specific test, if necessary
- name: Set up Python version
uses: actions/setup-python@v2
if: ${{ contains(matrix.tox_env, 'py') }}
with:
python-version: ${{ steps.py_ver.outputs.version }}
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pip
Expand Down
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,19 @@ repos:
- enrich>=1.2.5
- subprocess-tee>=0.2.0
- testinfra
- # keep at bottom as these are slower
repo: local
hooks:
- id: pip-compile
name: pip-compile
entry: pip-compile --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-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]
68 changes: 68 additions & 0 deletions constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --extra=test --extra=yamllint --no-annotate --output-file=constraints.txt setup.cfg setup.py
#
ansi2html==1.6.0
ansible-compat==0.5.0
arrow==1.1.1
attrs==21.2.0
bcrypt==3.2.0
binaryornot==0.4.4
cerberus==1.3.2
certifi==2021.5.30
cffi==1.14.6
chardet==4.0.0
charset-normalizer==2.0.4
click==8.0.1
click-help-colors==0.9.1
colorama==0.4.4
commonmark==0.9.1
cookiecutter==1.7.3
coverage==5.5
cryptography==3.4.8
distro==1.6.0
enrich==1.2.6
execnet==1.9.0
idna==3.2
iniconfig==1.1.1
jinja2==3.0.1
jinja2-time==0.2.0
markupsafe==2.0.1
more-itertools==8.8.0
packaging==21.0
paramiko==2.7.2
pexpect==4.8.0
pluggy==0.13.1
poyo==0.5.0
ptyprocess==0.7.0
py==1.10.0
pycparser==2.20
pygments==2.10.0
pynacl==1.4.0
pyparsing==2.4.7
pytest==6.2.4
pytest-cov==2.12.1
pytest-forked==1.3.0
pytest-html==3.1.1
pytest-metadata==1.11.0
pytest-mock==3.6.1
pytest-plus==0.2
pytest-testinfra==6.4.0
pytest-verbose-parametrize==1.7.0
pytest-xdist==2.3.0
python-dateutil==2.8.2
python-slugify==5.0.2
pyyaml==5.4.1
requests==2.26.0
rich==10.7.0
selinux==0.2.1 ; sys_platform == "linux"
six==1.16.0
subprocess-tee==0.3.2
text-unidecode==1.3
toml==0.10.2
urllib3==1.26.6

# The following packages are considered to be unsafe in a requirements file:
# setuptools
26 changes: 23 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ setenv =
ANSIBLE_NOCOWS=1
ANSIBLE_VERBOSITY=1
MOLECULE_NO_LOG=0
PIP_CONSTRAINT = {toxinidir}/constraints.txt
devel: PIP_CONSTRAINT=/dev/null
PIP_DISABLE_PIP_VERSION_CHECK=1
PYTHONDONTWRITEBYTECODE=1
PYTHONUNBUFFERED=1
_EXTRAS=-l --cov=molecule --no-cov-on-fail --cov-report xml:{envlogdir}/coverage.xml --html={envlogdir}/reports.html --self-contained-html
Expand Down Expand Up @@ -76,16 +79,33 @@ allowlist_externals =

[testenv:lint]
description = Runs all linting tasks
# temporary due to https://github.com/PyCQA/pylint/issues/3876
basepython = python3.8
# python pinned in order to have pip-compile output reproducible
basepython = python3.9
commands =
# to run a single linter you can do "pre-commit run flake8"
python -m pre_commit run {posargs:--all}
deps = pre-commit>=1.18.1
deps =
pre-commit>=2.14.0
pip-tools>=6.2.0
setenv =
{[testenv]setenv}
# without his upgrade would likely not do anything
PIP_CONSTRAINT = /dev/null
extras =
skip_install = true
usedevelop = false

[testenv:deps]
description = Bump all test dependencies
# we reuse the lint environment
envdir = {toxworkdir}/lint
skip_install = true
deps = {[testenv:lint]deps}
setenv = {[testenv:lint]setenv}
commands =
# manual hook calls the optional pip-compile-upgrade hook
{[testenv:lint]commands} --hook-stage manual pip-compile-upgrade

[testenv:docs]
description = Invoke sphinx-build to build the HTML docs
# doc requires py3 due to use of f'' strings and using only python3 as
Expand Down

0 comments on commit b351ea0

Please sign in to comment.