From c9d03ac1d4814c1c121fb4b86c6bc0526c7b642c Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sat, 19 Jun 2021 13:47:00 +0100 Subject: [PATCH] Adding the boilerplate --- .github/CODEOWNERS | 1 + .github/CODE_OF_CONDUCT.md | 3 + .github/release-drafter.yml | 51 +++++++ .github/workflows/labels.yml | 21 +++ .github/workflows/release-drafter.yml | 18 +++ .github/workflows/release.yml | 48 ++++++ .github/workflows/tox.yml | 212 ++++++++++++++++++++++++++ .gitignore | 1 + .pre-commit-config.yaml | 90 +++++++++++ .pylintrc | 32 ++++ .yamllint | 9 ++ constraints.txt | 30 ++++ mypy.ini | 24 +++ pyproject.toml | 17 +++ setup.cfg | 82 ++++++++++ setup.py | 13 ++ src/ansiblecompat/__init__.py | 1 + test/test_api.py | 5 + tox.ini | 111 ++++++++++++++ 19 files changed, 769 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/labels.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tox.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .pylintrc create mode 100644 .yamllint create mode 100644 constraints.txt create mode 100644 mypy.ini create mode 100644 pyproject.toml create mode 100644 setup.cfg create mode 100755 setup.py create mode 100644 src/ansiblecompat/__init__.py create mode 100644 test/test_api.py create mode 100644 tox.ini diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..ca0a41e4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @ssbarnea diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..0164155b --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Community Code of Conduct + +Please see the official [Ansible Community Code of Conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html). diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..d9867b53 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,51 @@ +# Format and labels used aim to match those used by Ansible project +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: 'Major Changes' + labels: + - 'major' # c6476b + - title: 'Minor Changes' + labels: + - 'feature' # 006b75 + - 'enhancement' # ededed + - 'refactoring' + - title: 'Bugfixes' + labels: + - 'bug' # fbca04 + - title: 'Deprecations' + labels: + - 'deprecated' # fef2c0 +exclude-labels: + - 'skip-changelog' +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + - 'feature' + - 'enhancement' + - 'refactoring' + patch: + labels: + - 'patch' + - 'bug' + - 'deprecated' + default: patch +autolabeler: + - label: 'skip-changelog' + title: '/chore/i' + - label: 'bug' + title: '/fix/i' + - label: 'enhancement' + title: '/(enhance|improve)/i' + - label: 'feature' + title: '/feature/i' + - label: 'dreprecated' + title: '/deprecat/i' +template: | + $CHANGES + + Kudos goes to: $CONTRIBUTORS diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 00000000..7843bf37 --- /dev/null +++ b/.github/workflows/labels.yml @@ -0,0 +1,21 @@ +# See https://github.com/jesusvasquez333/verify-pr-label-action +name: labels +on: + pull_request_target: + types: [opened, labeled, unlabeled, synchronize] + +jobs: + check_pr_labels: + runs-on: ubuntu-latest + name: verify + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Verify PR label action + uses: jesusvasquez333/verify-pr-label-action@v1.4.0 + with: + github-token: '${{ secrets.GITHUB_TOKEN }}' + valid-labels: 'bug, enhancement, feature, refactoring, major, deprecated, skip-changelog' + invalid-labels: 'help wanted, invalid, feedback-needed, incomplete' + pull-request-number: '${{ github.event.pull_request.number }}' + disable-reviews: true diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..97d09eaf --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,18 @@ +name: release-drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + - 'releases/**' + - 'stable/**' + +jobs: + update_release_draft: + runs-on: ubuntu-20.04 + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..c9bb6372 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: release + +on: + release: + types: [published, created, edited] + +jobs: + pypi: + name: Publish to PyPI registry + environment: release + runs-on: ubuntu-20.04 + + env: + FORCE_COLOR: 1 + PY_COLORS: 1 + TOXENV: packaging + TOX_PARALLEL_NO_SPINNER: 1 + + steps: + - name: Switch to using Python 3.8 by default + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install tox + run: >- + python3 -m + pip install + --user + tox + - name: Check out src from Git + uses: actions/checkout@v2 + with: + fetch-depth: 0 # needed by setuptools-scm + - name: Build dists + run: python -m tox + - name: Publish to test.pypi.org + if: >- # "create" workflows run separately from "push" & "pull_request" + github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.testpypi_password }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish to pypi.org + if: >- # "create" workflows run separately from "push" & "pull_request" + github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml new file mode 100644 index 00000000..583e7e9a --- /dev/null +++ b/.github/workflows/tox.yml @@ -0,0 +1,212 @@ +name: gh + +on: + create: # is used for publishing to PyPI and TestPyPI + tags: # any tag regardless of its name, no branches + - "**" + push: # only publishes pushes to the main branch to TestPyPI + branches: # any integration branch but not tag + - "main" + pull_request: + release: + types: + - published # It seems that you can publish directly without creating + schedule: + - cron: 1 0 * * * # Run daily at 0:01 UTC + # Run every Friday at 18:02 UTC + # https://crontab.guru/#2_18_*_*_5 + # - cron: 2 18 * * 5 + +jobs: + linters: + name: >- + ${{ matrix.env.TOXENV }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: + - 3.8 + os: + - ubuntu-20.04 + env: + - TOXENV: lint + - TOXENV: packaging + env: + TOX_PARALLEL_NO_SPINNER: 1 + FORCE_COLOR: 1 + + steps: + - name: Check out src from Git + uses: actions/checkout@v2 + with: + fetch-depth: 0 # needed by setuptools-scm + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + # - name: set PY_SHA256 + # run: echo "::set-env name=PY_SHA256::$(python -VV | sha256sum | cut -d' ' -f1)" + # - name: Pre-commit cache + # uses: actions/cache@v1 + # with: + # path: ~/.cache/pre-commit + # key: ${{ runner.os }}-pre-commit-${{ env.PY_SHA256 }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pytest.ini') }} + # - name: Pip cache + # uses: actions/cache@v1 + # with: + # path: ~/.cache/pip + # key: ${{ runner.os }}-pip-${{ env.PY_SHA256 }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pytest.ini') }} + # restore-keys: | + # ${{ runner.os }}-pip- + # ${{ runner.os }}- + - name: Install tox + run: | + python3 -m pip install --upgrade tox + - name: Log installed dists + run: >- + python -m pip freeze --all + - name: >- + Initialize tox envs + run: >- + python -m + tox + --parallel auto + --parallel-live + --notest + --skip-missing-interpreters false + -vv + env: ${{ matrix.env }} + - name: Test with tox + run: | + python -m tox --parallel auto --parallel-live + env: ${{ matrix.env }} + - name: Archive logs + uses: actions/upload-artifact@v2 + with: + name: logs.zip + path: .tox/**/log/ + + unit: + name: >- + ${{ matrix.tox_env }}@${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + # fail-fast: false + # max-parallel: 5 + # The matrix testing goal is to cover the *most likely* environments + # which are expected to be used by users in production. Avoid adding a + # combination unless there are good reasons to test it, like having + # proof that we failed to catch a bug by not running it. Using + # distribution should be prefferred instead of custom builds. + matrix: + python-version: + # keep list sorted as it determines UI order too + - 3.6 + - 3.7 + - 3.8 + - 3.9 + # NOTE: Installing ansible under 3.10-dev is currently not + # NOTE: possible because compiling cffi explodes. + os: + # https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners + - ubuntu-20.04 + # - windows-latest + # - windows-2016 + include: + - tox_env: py36 + os: ubuntu-20.04 + python-version: 3.6 + - tox_env: py37 + os: ubuntu-20.04 + python-version: 3.7 + - tox_env: py38 + os: ubuntu-20.04 + python-version: 3.8 + - tox_env: py39 + os: ubuntu-20.04 + python-version: 3.9 + - tox_env: py36 + os: macOS-latest + python-version: 3.6 + - tox_env: py38 + os: macOS-latest + python-version: 3.8 + + env: + TOX_PARALLEL_NO_SPINNER: 1 + FORCE_COLOR: 1 + + steps: + - name: MacOS workaround for https://github.com/actions/virtual-environments/issues/1187 + if: ${{ matrix.os == 'macOS-latest' }} + run: | + sudo sysctl -w net.link.generic.system.hwcksum_tx=0 + sudo sysctl -w net.link.generic.system.hwcksum_rx=0 + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # needed by setuptools-scm + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: >- + Log the currently selected Python + version info (${{ matrix.python-version }}) + run: | + python --version --version + which python + # - name: Pip cache + # uses: actions/cache@v1 + # with: + # path: ~/.cache/pip + # key: ${{ runner.os }}-pip-${{ env.PY_SHA256 }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pytest.ini') }} + # restore-keys: | + # ${{ runner.os }}-pip- + # ${{ runner.os }}- + - name: Install tox + run: | + python3 -m pip install --upgrade tox + - name: Log installed dists + run: >- + python3 -m pip freeze --all + - name: >- + Initialize tox envs + run: >- + python3 -m + tox + --parallel auto + --parallel-live + --notest + --skip-missing-interpreters false + -vv + env: + TOXENV: ${{ matrix.tox_env }}-core,${{ matrix.tox_env }}-ansible29,${{ matrix.tox_env }}-devel + # sequential run improves browsing experience (almost no speed impact) + - name: "Test with tox: ${{ matrix.tox_env }}-core" + run: | + python3 -m tox + env: + TOXENV: ${{ matrix.tox_env }}-core + - name: "Test with tox: ${{ matrix.tox_env }}-ansible29" + run: | + python3 -m tox + env: + TOXENV: ${{ matrix.tox_env }}-ansible29 + - name: "Test with tox: ${{ matrix.tox_env }}-devel" + run: | + python3 -m tox + env: + TOXENV: ${{ matrix.tox_env }}-devel + - name: Archive logs + uses: actions/upload-artifact@v2 + with: + name: logs.zip + path: .tox/**/log/ + # https://github.com/actions/upload-artifact/issues/123 + continue-on-error: true + - name: Report junit failures + uses: shyim/junit-report-annotations-action@3d2e5374f2b13e70f6f3209a21adfdbc42c466ae + with: + path: .tox/junit.*.xml + if: always() diff --git a/.gitignore b/.gitignore index b6e47617..9605d7bd 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,4 @@ dmypy.json # Pyre type checker .pyre/ +.test-results diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..cd77e60f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,90 @@ +--- +repos: +- repo: local + hooks: + - id: immutable-setup-py + name: Verify that setup.py stays immutable + description: >- + This is a sanity check that makes sure that + the `setup.py` file isn't changed. + # Using Python here because using + # shell test does not seem to work in CIs: + entry: >- + sh -c 'git hash-object setup.py + | + python -c raise\ SystemExit\(input\(\)\ !=\ \"f6d1010b609cbe816d3ef652eee452d09d52979f\"\) + ' + pass_filenames: false + language: system + files: >- + ^setup\.py$ +- repo: https://github.com/pre-commit/pre-commit-hooks.git + rev: v4.0.1 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + exclude: > + (?x)^( + examples/playbooks/(with-skip-tag-id|unicode).yml| + examples/playbooks/example.yml + )$ + - id: mixed-line-ending + - id: check-byte-order-marker + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: debug-statements + language_version: python3 +- repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell +- repo: https://github.com/PyCQA/doc8 + rev: 0.9.0a1 + hooks: + - id: doc8 +- repo: https://github.com/adrienverge/yamllint.git + rev: v1.26.1 + hooks: + - id: yamllint + exclude: > + (?x)^( + examples/playbooks/templates/.*| + examples/other/some.j2.yaml + )$ + files: \.(yaml|yml)$ + types: [file, yaml] + entry: yamllint --strict +- repo: https://github.com/pre-commit/mirrors-isort + rev: v5.8.0 + hooks: + - id: isort + args: + # https://github.com/pre-commit/mirrors-isort/issues/9#issuecomment-624404082 + - --filter-files +- repo: https://github.com/python/black.git + rev: 21.6b0 + hooks: + - id: black + language_version: python3 +- repo: https://github.com/pycqa/flake8.git + rev: 3.9.2 + hooks: + - id: flake8 + language_version: python3 + additional_dependencies: + - flake8-2020>=1.6.0 + # - flake8-black>=0.1.1 + - flake8-docstrings>=1.5.0 + - flake8-pytest-style>=1.2.2 +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.902 + hooks: + - id: mypy + # empty args needed in order to match mypy cli behavior + args: ["--strict"] + additional_dependencies: [] +- repo: https://github.com/pre-commit/mirrors-pylint + rev: v3.0.0a3 + hooks: + - id: pylint + additional_dependencies: [] diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 00000000..6b34536c --- /dev/null +++ b/.pylintrc @@ -0,0 +1,32 @@ +[IMPORTS] +preferred-modules = + unittest:pytest, + +[MESSAGES CONTROL] + +disable = + # On purpose disabled as we rely on black + line-too-long, + # TODO(ssbarnea): remove temporary skips adding during initial adoption: + bad-continuation, + broad-except, + dangerous-default-value, + duplicate-code, + fixme, + inconsistent-return-statements, + invalid-name, + missing-class-docstring, + missing-function-docstring, + missing-module-docstring, + no-member, + no-self-use, + not-callable, + protected-access, + raise-missing-from, + redefined-outer-name, + too-few-public-methods, + too-many-branches, + too-many-instance-attributes, + too-many-return-statements, + unused-argument, + unused-variable, diff --git a/.yamllint b/.yamllint new file mode 100644 index 00000000..b87ed695 --- /dev/null +++ b/.yamllint @@ -0,0 +1,9 @@ +rules: + document-start: disable + indentation: + level: error + indent-sequences: consistent +ignore: | + .tox + examples/playbooks/example.yml +# ignore added because this file includes on-purpose errors diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 00000000..3007143a --- /dev/null +++ b/constraints.txt @@ -0,0 +1,30 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile --extra=test --output-file=constraints.txt setup.py +# +attrs==21.2.0 + # via pytest +coverage==5.5 + # via pytest-cov +iniconfig==1.1.1 + # via pytest +packaging==20.9 + # via pytest +pluggy==0.13.1 + # via pytest +py==1.10.0 + # via pytest +pyparsing==2.4.7 + # via packaging +pytest-cov==2.12.1 + # via ansible-compat (setup.py) +pytest==6.2.4 + # via + # ansible-compat (setup.py) + # pytest-cov +toml==0.10.2 + # via + # pytest + # pytest-cov diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 00000000..4c4715eb --- /dev/null +++ b/mypy.ini @@ -0,0 +1,24 @@ +[mypy] +python_version = 3.6 +color_output = True +error_summary = True +disallow_untyped_calls = True +disallow_untyped_defs = True +disallow_any_generics = True +; disallow_any_unimported = True +; warn_redundant_casts = True +; warn_return_any = True +; warn_unused_configs = True +exclude = test/local-content + +[mypy-pytest] +ignore_missing_imports = True + +[mypy-packaging.version] +ignore_missing_imports = True + +[mypy-importlib_metadata] +ignore_missing_imports = True + +[mypy-setuptools] +ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..0292abc5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[build-system] +requires = [ + "setuptools >= 42.0.0", # required by pyproject+setuptools_scm integration + "setuptools_scm[toml] >= 3.5.0", # required for "no-local-version" scheme + "setuptools_scm_git_archive >= 1.0", + "wheel", +] +build-backend = "setuptools.build_meta" + +[tool.black] +skip-string-normalization = true + +[tool.isort] +profile = "black" + +[tool.setuptools_scm] +local_scheme = "no-local-version" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..8590040a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,82 @@ +[aliases] +dists = clean --all sdist bdist_wheel + +[metadata] +name = ansible-compat +url = https://github.com/ansible-community/ansible-compat +project_urls = + Bug Tracker = https://github.com/ansible-community/ansible-compat/issues + CI: GitHub = https://github.com/ansible-community/ansible-compat/actions?query=workflow:gh+branch:master+event:push + Code of Conduct = https://docs.ansible.com/ansible/latest/community/code_of_conduct.html + Source Code = https://github.com/ansible-community/ansible-compat +description = Ansible compatibility goodies +long_description = file: README.rst +long_description_content_type = text/x-rst +author = Sorin Sbarnea +author_email = ssbarnea@redhat.com +maintainer = Sorin Sbarnea +maintainer_email = ssbarnea@redhat.com +license = MIT +license_file = LICENSE +classifiers = + Development Status :: 5 - Production/Stable + + Environment :: Console + + Intended Audience :: Developers + Intended Audience :: Information Technology + Intended Audience :: System Administrators + + Operating System :: OS Independent + + License :: OSI Approved :: MIT License + License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) + + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: Implementation + Programming Language :: Python :: Implementation :: CPython + Programming Language :: Python :: Implementation :: Jython + Programming Language :: Python :: Implementation :: PyPy + + Topic :: Software Development :: Bug Tracking + Topic :: Software Development :: Quality Assurance + Topic :: Software Development :: Testing + + Topic :: Utilities +keywords = + ansible + lint + +[options] +use_scm_version = True +python_requires = >=3.6 +package_dir = + = src +packages = find: +zip_safe = False + +# These are required during `setup.py` run: +setup_requires = + setuptools_scm>=1.15.0 + setuptools_scm_git_archive>=1.0 + +# These are required in actual runtime: +; install_requires = + +[options.extras_require] +test = + pytest + pytest-cov + +[options.packages.find] +where = src + +[options.package_data] +ansiblelint = py.typed + +[codespell] +skip = .tox,.mypy_cache,build,.git,.eggs,pip-wheel-metadata diff --git a/setup.py b/setup.py new file mode 100755 index 00000000..f6d1010b --- /dev/null +++ b/setup.py @@ -0,0 +1,13 @@ +#! /usr/bin/env python3 +"""Ansible-lint distribution package setuptools installer. + +The presence of this file ensures the support +of pip editable mode *with setuptools only*. +""" +import setuptools + +# https://github.com/jazzband/pip-tools/issues/1278 +setuptools.setup( + use_scm_version={"local_scheme": "no-local-version"}, + setup_requires=["setuptools_scm[toml]>=3.5.0"], +) diff --git a/src/ansiblecompat/__init__.py b/src/ansiblecompat/__init__.py new file mode 100644 index 00000000..9c462e26 --- /dev/null +++ b/src/ansiblecompat/__init__.py @@ -0,0 +1 @@ +"""ansiblecompat package.""" diff --git a/test/test_api.py b/test/test_api.py new file mode 100644 index 00000000..232e7b25 --- /dev/null +++ b/test/test_api.py @@ -0,0 +1,5 @@ +"""Tests for ansiblecompat package.""" + + +def test_placeholder() -> None: + """Placeholder test.""" diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..41a876e7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,111 @@ +[tox] +minversion = 3.16.1 +envlist = lint,packaging,py{39,38,37,36}-{core,ansible29,devel} +isolated_build = true +requires = + setuptools >= 41.4.0 + pip >= 19.3.0 +skip_missing_interpreters = True +# `usedevelop = true` overrides `skip_install` instruction, it's unwanted +usedevelop = false + +[testenv] +description = + Run the tests under {basepython} and + devel: ansible devel branch + ansible29: ansible 2.9 + core: ansible-base 2.10 + py: ansible-core 2.11 +extras = + test +deps = + ansible29: ansible>=2.9,<2.10 + py: ansible-core>=2.11 + devel: ansible-core @ git+https://github.com/ansible/ansible.git # GPLv3+ +commands = + # safety measure to assure we do not accidentally run tests with broken dependencies + {envpython} -m pip check + # We add coverage options but not making them mandatory as we do not want to force + # pytest users to run coverage when they just want to run a single test with `pytest -k test` + {envpython} -m pytest \ + --junitxml "{toxworkdir}/junit.{envname}.xml" \ + {posargs:\ + --cov ansiblecompat \ + --cov "{envsitepackagesdir}/ansiblecompat" \ + --cov-report term-missing:skip-covered \ + --cov-report xml:.test-results/pytest/cov.xml \ + --no-cov-on-fail} +passenv = + CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437 + FORCE_COLOR + HOME + NO_COLOR + PYTEST_* # allows developer to define their own preferences + PY_COLORS + REQUESTS_CA_BUNDLE # https proxies + SSL_CERT_FILE # https proxies + LANG + LC_ALL + LC_CTYPE +# recreate = True +setenv = + COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}} + PIP_DISABLE_PIP_VERSION_CHECK = 1 + PIP_CONSTRAINT = {toxinidir}/constraints.txt + PRE_COMMIT_COLOR = always + FORCE_COLOR = 1 +allowlist_externals = + sh + +[testenv:lint] +description = Run all linters +basepython = python3 +deps = + pre-commit>=2.6.0 + pip-tools>=5.4.0 + setuptools>=51.1.1 +skip_install = true +commands = + pip-compile --extra test --output-file=constraints.txt setup.py + {envpython} -m pre_commit run -a +passenv = + {[testenv]passenv} + PRE_COMMIT_HOME + +[testenv:deps] +description = Bump all test depeendencies +basepython = python3 +deps = + pre-commit>=2.6.0 + pip-tools>=5.4.0 + setuptools>=51.1.1 +skip_install = true +commands = + pip-compile --upgrade --extra test --output-file=constraints.txt setup.py + {envpython} -m pre_commit run {posargs:--all-files --hook-stage manual -v} + +[testenv:packaging] +basepython = python3 +description = + Build package, verify metadata, install package and assert behavior when ansible is missing. +deps = + pep517 >= 0.7.0 + twine +skip_install = true +# Ref: https://twitter.com/di_codes/status/1044358639081975813 +commands = + # build wheel and sdist using PEP-517 + {envpython} -c 'import os.path, shutil, sys; \ + dist_dir = os.path.join("{toxinidir}", "dist"); \ + os.path.isdir(dist_dir) or sys.exit(0); \ + print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \ + shutil.rmtree(dist_dir)' + {envpython} -m pep517.build \ + --source \ + --binary \ + --out-dir {toxinidir}/dist/ \ + {toxinidir} + # Validate metadata using twine + twine check {toxinidir}/dist/* + # Install the wheel + sh -c "python3 -m pip install {toxinidir}/dist/*.whl"