Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Made driver compatible with molecule 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Oct 29, 2020
1 parent ae9ba7b commit 1b70615
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 60 deletions.
23 changes: 16 additions & 7 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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: |
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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 }}
144 changes: 144 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 8 additions & 12 deletions molecule_gce/test/functional/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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
27 changes: 7 additions & 20 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,19 +20,19 @@ 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
License :: OSI Approved :: MIT License
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
Expand Down Expand Up @@ -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 =
Expand Down
30 changes: 9 additions & 21 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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/*

0 comments on commit 1b70615

Please sign in to comment.