From 1b70615b1a7d8611f80ea3fe072ff77894f5e9b1 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 29 Oct 2020 17:42:19 +0000 Subject: [PATCH] Made driver compatible with molecule 3.2 --- .github/release-drafter.yml | 23 ++-- .github/workflows/release-drafter.yml | 18 +++ .github/workflows/tox.yml | 144 ++++++++++++++++++++++ molecule_gce/test/functional/test_func.py | 20 ++- setup.cfg | 27 ++-- tox.ini | 30 ++--- 6 files changed, 202 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/tox.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index c5a15a7..a444deb 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,15 +1,24 @@ +# Format and labels used aim to match those used by Ansible project categories: - - title: 'Features' + - title: 'Major Changes' labels: - - 'feature' - - 'enhancement' - - title: 'Bug Fixes' + - 'major' # c6476b + - title: 'Minor Changes' + labels: + - 'feature' # 006b75 + - 'enhancement' # ededed + - 'performance' # 555555 + - title: 'Bugfixes' labels: - 'fix' - 'bugfix' - - 'bug' - - title: 'Maintenance' - label: 'chore' + - 'bug' # fbca04 + - 'docs' # 4071a5 + - 'packaging' # 4071a5 + - 'test' # #0e8a16 + - title: 'Deprecations' + labels: + - 'deprecated' # fef2c0 exclude-labels: - 'skip-changelog' template: | diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..7d3004a --- /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-latest + 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/tox.yml b/.github/workflows/tox.yml new file mode 100644 index 0000000..826d4f1 --- /dev/null +++ b/.github/workflows/tox.yml @@ -0,0 +1,144 @@ +name: tox + +on: + create: # is used for publishing to 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 + - "master" + pull_request: + release: + types: + - published # It seems that you can publish directly without creating + schedule: + - cron: 1 0 * * * # Run daily at 0:01 UTC + +jobs: + build: + name: ${{ matrix.tox_env }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - tox_env: lint + # - tox_env: docs + - tox_env: py36 + PREFIX: PYTEST_REQPASS=3 + - tox_env: py36-devel + PREFIX: PYTEST_REQPASS=3 + - tox_env: py37 + PREFIX: PYTEST_REQPASS=3 + - tox_env: py38 + PREFIX: PYTEST_REQPASS=3 + - tox_env: py39 + PREFIX: PYTEST_REQPASS=3 + - tox_env: py39-devel + PREFIX: PYTEST_REQPASS=3 + - tox_env: packaging + + steps: + - uses: actions/checkout@v1 + - name: Install system dependencies + run: | + sudo apt-get update \ + && sudo apt-get install -y ansible \ + && ansible-doc -l | grep gce + - 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 + 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 }} + - name: Install dependencies + run: | + python -m pip install -U pip + pip install tox + - name: Run tox -e ${{ matrix.tox_env }} + run: | + echo "${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }}" + ${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }} + + publish: + name: Publish to PyPI registry + needs: + - build + runs-on: ubuntu-latest + + env: + PY_COLORS: 1 + TOXENV: packaging + + steps: + - name: Switch to using Python 3.6 by default + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Install tox + run: python -m pip install --user tox + - name: Check out src from Git + uses: actions/checkout@v2 + with: + # Get shallow Git history (default) for release events + # but have a complete clone for any other workflows. + # Both options fetch tags but since we're going to remove + # one from HEAD in non-create-tag workflows, we need full + # history for them. + fetch-depth: >- + ${{ + ( + ( + github.event_name == 'create' && + github.event.ref_type == 'tag' + ) || + github.event_name == 'release' + ) && + 1 || 0 + }} + - name: Drop Git tags from HEAD for non-tag-create and non-release events + if: >- + ( + github.event_name != 'create' || + github.event.ref_type != 'tag' + ) && + github.event_name != 'release' + run: >- + git tag --points-at HEAD + | + xargs git tag --delete + - name: Build dists + run: python -m tox + - name: Publish to test.pypi.org + if: >- + ( + github.event_name == 'push' && + github.ref == format( + 'refs/heads/{0}', github.event.repository.default_branch + ) + ) || + ( + github.event_name == 'create' && + github.event.ref_type == 'tag' + ) + 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/molecule_gce/test/functional/test_func.py b/molecule_gce/test/functional/test_func.py index ff26c4a..6a13434 100644 --- a/molecule_gce/test/functional/test_func.py +++ b/molecule_gce/test/functional/test_func.py @@ -21,14 +21,12 @@ import pytest import os -import sh from molecule import logger -from molecule.test.conftest import run_command, change_dir_to +from molecule.util import run_command +from molecule.test.conftest import change_dir_to from molecule.test.functional.conftest import metadata_lint_update -# import change_dir_to, temp_dir - LOG = logger.get_logger(__name__) driver_name = __name__.split(".")[0].split("_")[-1] @@ -37,19 +35,17 @@ def test_command_init_scenario(temp_dir): """Test init scenario with driver.""" role_directory = os.path.join(temp_dir.strpath, "test-init") - options = {} - cmd = sh.molecule.bake("init", "role", "test-init", **options) - run_command(cmd) + cmd = ["molecule", "init", "role", "test-init"] + assert run_command(cmd).returncode == 0 metadata_lint_update(role_directory) with change_dir_to(role_directory): molecule_directory = pytest.helpers.molecule_directory() scenario_directory = os.path.join(molecule_directory, "test-scenario") - options = {"role_name": "test-init", "driver-name": driver_name} - cmd = sh.molecule.bake("init", "scenario", "test-scenario", **options) - run_command(cmd) + cmd = ["molecule", "init", "scenario", "test-scenario", "--role-name", "test-init", "--driver-name", driver_name] + assert run_command(cmd).returncode == 0 assert os.path.isdir(scenario_directory) - cmd = sh.molecule.bake("test", "-s", "test-scenario") - run_command(cmd) + cmd = ["molecule", "test", "-s", "test-scenario"] + assert run_command(cmd).returncode == 0 diff --git a/setup.cfg b/setup.cfg index 44b4c71..fb9320c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,17 +1,14 @@ [aliases] dists = clean --all sdist bdist_wheel -[bdist_wheel] -universal = 1 - [metadata] name = molecule-gce url = https://github.com/ansible-community/molecule-gce project_urls = Bug Tracker = https://github.com/ansible-community/molecule-gce/issues Release Management = https://github.com/ansible-community/molecule-gce/projects - CI: Zuul = https://dashboard.zuul.ansible.com/t/ansible/builds?project=ansible-community/molecule-gce - Mailing lists = https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information + CI = https://github.com/ansible-community/molecule-gce/actions + Discussions = https://github.com/ansible-community/molecule/discussions Source Code = https://github.com/ansible-community/molecule-gce description = Molecule GCE Plugin :: run molecule tests on Google Cloud Engine long_description = file: README.rst @@ -23,9 +20,8 @@ maintainer_email = info@ansible.com license = MIT license_file = LICENSE classifiers = - Development Status :: 2 - Pre-Alpha + Development Status :: 4 - Beta Environment :: Console - Framework :: Pytest Intended Audience :: Developers Intended Audience :: Information Technology Intended Audience :: System Administrators @@ -33,9 +29,10 @@ classifiers = Natural Language :: English Operating System :: OS Independent Programming Language :: Python :: 3 - Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 Topic :: System :: Systems Administration Topic :: Utilities @@ -63,22 +60,12 @@ setup_requires = # These are required in actual runtime: install_requires = - ansible >= 2.9 - apache-libcloud - molecule >= 3.0a9 + molecule >= 3.2.0a0 pyyaml >= 5.1, < 6 [options.extras_require] test = - mock>=3.0.5, < 4 - pytest-cov>=2.7.1, < 3 - pytest-dependency - pytest-helpers-namespace>=2019.1.8, < 2020 - pytest-mock>=1.10.4, < 2 - pytest-sugar - pytest-verbose-parametrize>=1.7.0, < 2 - pytest-xdist>=1.29.0, < 2 - pytest>=4.6.3, < 5 + molecule[test] [options.entry_points] molecule.driver = diff --git a/tox.ini b/tox.ini index 6f635b4..4c21d43 100644 --- a/tox.ini +++ b/tox.ini @@ -4,9 +4,11 @@ minversion = 3.9.0 envlist = lint packaging - py{35,36,37,38} - devel -skipsdist = True + py{36,37,38,39} + py{36,37,38,39}-{devel} + +# do not enable skip missing to avoid CI false positives +skip_missing_interpreters = False isolated_build = True [testenv] @@ -17,6 +19,9 @@ usedevelop = True download = true # sitepackages = True extras = test +deps = + py{36,37,38,39}: molecule[test] + py{36,37,38,39}-{devel}: git+https://github.com/ansible-community/molecule.git@master#egg=molecule[test] commands = pytest --collect-only pytest --color=yes {tty:-s} @@ -28,6 +33,7 @@ setenv = ANSIBLE_RETRY_FILES_ENABLED=0 ANSIBLE_STDOUT_CALLBACK={env:ANSIBLE_STDOUT_CALLBACK:debug} ANSIBLE_VERBOSITY={env:ANSIBLE_VERBOSITY:0} + MOLECULE_NO_LOG={env:MOLECULE_NO_LOG:0} PIP_DISABLE_PIP_VERSION_CHECK=1 PY_COLORS={env:PY_COLORS:1} # pip: Avoid 2020-01-01 warnings: https://github.com/pypa/pip/issues/6207 @@ -70,15 +76,6 @@ commands = {toxinidir} twine check dist/* -[testenv:devel] -description= Unit testing using master branches of molecule and ansible -extras = test -commands = - {[testenv]commands} -deps = - git+https://github.com/ansible/ansible.git#egg=ansible - git+https://github.com/ansible/molecule#egg=molecule - [testenv:lint] description = Performs linting, style checks skip_install = true @@ -87,12 +84,3 @@ deps = pre-commit commands = pre-commit run -a - -[testenv:upload] -description = Builds the packages and uploads them to https://pypi.org -envdir={toxworkdir}/dist -deps= - {[testenv:packaging]deps} -commands = - {[testenv:packaging]commands} - twine upload --verbose dist/*