Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
wadhah101 authored May 9, 2023
2 parents fcafedf + c69541c commit d3c16c4
Show file tree
Hide file tree
Showing 64 changed files with 510 additions and 409 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
branches:
- main
- 'releases/**'
- 'stable/**'
- "releases/**"
- "stable/**"

jobs:
ack:
Expand Down
52 changes: 26 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ jobs:
TOX_PARALLEL_NO_SPINNER: 1

steps:
- name: Switch to using Python 3.9 by default
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install tox
run: >-
python3 -m
pip install
--user
tox
- name: Check out src from Git
uses: actions/checkout@v3
with:
fetch-depth: 0 # needed by setuptools-scm

- name: Build dists
run: python -m tox -e pkg

- name: Publish to pypi.org
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_password }}
- name: Switch to using Python 3.9 by default
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install tox
run: >-
python3 -m
pip install
--user
tox
- name: Check out src from Git
uses: actions/checkout@v3
with:
fetch-depth: 0 # needed by setuptools-scm

- name: Build dists
run: python -m tox -e pkg

- name: Publish to pypi.org
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_password }}
20 changes: 15 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ default_language_version:
python: python3
minimum_pre_commit_version: 1.14.0
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
# keep it before yamllint
rev: "v3.0.0-alpha.6"
hooks:
- id: prettier
# Temporary excludes so we can gradually normalize the formatting
exclude: >
(?x)^(
.*\.md|
.*\{\{.*
)$
- repo: https://github.com/PyCQA/doc8.git
rev: v1.1.1
hooks:
Expand All @@ -30,12 +41,11 @@ repos:
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.262"
hooks:
- id: flake8
additional_dependencies:
- flake8-black
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/ansible/ansible-lint.git
rev: v6.15.0
hooks:
Expand Down
13 changes: 7 additions & 6 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import string

import pytest

from molecule import config, logger, util
from molecule.scenario import ephemeral_directory

Expand All @@ -23,9 +24,9 @@ def _rebake_command(cmd, env, out=LOG.info, err=LOG.error):
return cmd.bake(_env=env, _out=out, _err=err)


@pytest.fixture
@pytest.fixture()
def random_string(length=5):
return "".join((random.choice(string.ascii_uppercase) for _ in range(length)))
return "".join(random.choice(string.ascii_uppercase) for _ in range(length))


@contextlib.contextmanager
Expand All @@ -36,15 +37,15 @@ def change_dir_to(dir_name):
os.chdir(cwd)


@pytest.fixture
@pytest.fixture()
def temp_dir(tmpdir, random_string, request):
directory = tmpdir.mkdir(random_string)

with change_dir_to(directory.strpath):
yield directory


@pytest.fixture
@pytest.fixture()
def resources_folder_path():
resources_folder_path = os.path.join(os.path.dirname(__file__), "resources")
return resources_folder_path
Expand Down Expand Up @@ -77,9 +78,9 @@ def get_molecule_file(path):

@pytest.helpers.register
def molecule_ephemeral_directory(_fixture_uuid):
project_directory = "test-project-{}".format(_fixture_uuid)
project_directory = f"test-project-{_fixture_uuid}"
scenario_name = "test-instance"

return ephemeral_directory(
os.path.join("molecule_test", project_directory, scenario_name)
os.path.join("molecule_test", project_directory, scenario_name),
)
45 changes: 42 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"

[project]
# https://peps.python.org/pep-0621/#readme
requires-python = ">=3.8"
requires-python = ">=3.9"
dynamic = ["version"]
name = "molecule-plugins"
description = "Molecule Plugins"
Expand All @@ -26,7 +26,6 @@ classifiers = [
"Operating System :: MacOS",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -40,7 +39,7 @@ classifiers = [
keywords = ["ansible", "testing", "molecule", "plugin"]
dependencies = [
# molecule plugins are not allowed to mention Ansible as a direct dependency
"molecule >= 4.0",
"molecule >= 5.0",
]

[project.urls]
Expand Down Expand Up @@ -78,7 +77,47 @@ selinux = [
'selinux; sys_platform=="linux2"',
'selinux; sys_platform=="linux"',
]
vagrant = [
"python-vagrant",
]

[tool.ruff]
ignore = [
"E501", # we use black
# we deliberately ignore these:
"EM102",
# temporary disabled until we either fix them or decide to ignore them:
"A001",
"ANN",
"ARG",
"B006",
"B028",
"BLE",
"C901",
"D",
"DTZ",
"FBT",
"INP",
"ISC",
"N",
"PGH",
"PLR",
"PT",
"PTH",
"RET",
"S",
"TRY",
]
select = ["ALL"]
target-version = "py39"
# Same as Black.
line-length = 88

[tool.ruff.flake8-pytest-style]
parametrize-values-type = "tuple"

[tool.ruff.isort]
known-first-party = ["molecule_plugins"]

[project.entry-points."molecule.driver"]
azure = "molecule_plugins.azure.driver:Azure"
Expand Down
1 change: 1 addition & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ collections:
version: ">=1,<2"
- name: community.crypto
version: "1.8.0"
- name: community.vagrant
6 changes: 3 additions & 3 deletions src/molecule_plugins/azure/cookiecutter/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"molecule_directory": "molecule",
"role_name": "OVERRIDDEN",
"scenario_name": "OVERRIDDEN"
"molecule_directory": "molecule",
"role_name": "OVERRIDDEN",
"scenario_name": "OVERRIDDEN"
}
13 changes: 6 additions & 7 deletions src/molecule_plugins/azure/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
import os
from molecule import logger
from molecule.api import Driver

from molecule import util
from molecule import logger, util
from molecule.api import Driver

LOG = logger.get_logger(__name__)

Expand Down Expand Up @@ -72,10 +71,10 @@ class Azure(Driver):
- foo
.. _`Azure`: https://azure.microsoft.com
""" # noqa
"""

def __init__(self, config=None):
super(Azure, self).__init__(config)
def __init__(self, config=None) -> None:
super().__init__(config)
self._name = "azure"

@property
Expand Down Expand Up @@ -125,7 +124,7 @@ def ansible_connection_options(self, instance_name):
}
except StopIteration:
return {}
except IOError:
except OSError:
# Instance has yet to be provisioned , therefore the
# instance_config is not on disk.
return {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"molecule_directory": "molecule",
"role_name": "OVERRIDDEN",
"scenario_name": "OVERRIDDEN"
"molecule_directory": "molecule",
"role_name": "OVERRIDDEN",
"scenario_name": "OVERRIDDEN"
}
8 changes: 3 additions & 5 deletions src/molecule_plugins/containers/driver.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Containers Driver Module."""
from __future__ import absolute_import

import inspect
import os
import shutil
from typing import Dict

from molecule import logger

Expand Down Expand Up @@ -34,9 +32,9 @@ class Container(DriverBackend):
This class aims to provide an agnostic container enginer implementation,
which should allow users to consume whichever enginer they have available.
""" # noqa
"""

def __init__(self, config=None):
def __init__(self, config=None) -> None:
"""Construct Container."""
super().__init__(config)
self._name = "containers"
Expand All @@ -45,7 +43,7 @@ def __init__(self, config=None):
self._path = os.path.abspath(os.path.dirname(inspect.getfile(DriverBackend)))

@property
def required_collections(self) -> Dict[str, str]:
def required_collections(self) -> dict[str, str]:
"""Return collections dict containing names and versions required."""
return {
"ansible.posix": "1.3.0",
Expand Down
6 changes: 3 additions & 3 deletions src/molecule_plugins/docker/cookiecutter/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"molecule_directory": "molecule",
"role_name": "OVERRIDDEN",
"scenario_name": "OVERRIDDEN"
"molecule_directory": "molecule",
"role_name": "OVERRIDDEN",
"scenario_name": "OVERRIDDEN"
}
10 changes: 4 additions & 6 deletions src/molecule_plugins/docker/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
# DEALINGS IN THE SOFTWARE.
"""Docker Driver Module."""

from __future__ import absolute_import

import os
from typing import Dict

from molecule import logger
from molecule.api import Driver
Expand Down Expand Up @@ -187,13 +185,13 @@ class Docker(Driver):
.. _`Docker`: https://www.docker.com
.. _`systemd`: https://www.freedesktop.org/wiki/Software/systemd/
.. _`CMD`: https://docs.docker.com/engine/reference/builder/#cmd
""" # noqa
"""

_passed_sanity = False

def __init__(self, config=None):
def __init__(self, config=None) -> None:
"""Construct Docker."""
super(Docker, self).__init__(config)
super().__init__(config)
self._name = "docker"

@property
Expand Down Expand Up @@ -269,7 +267,7 @@ def reset(self):
n.remove()

@property
def required_collections(self) -> Dict[str, str]:
def required_collections(self) -> dict[str, str]:
"""Return collections dict containing names and versions required."""
# https://galaxy.ansible.com/community/docker
return {"community.docker": "3.0.2", "ansible.posix": "1.4.0"}
2 changes: 1 addition & 1 deletion src/molecule_plugins/docker/playbooks/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
- not item.pre_build_image | default(false)
register: docker_images

- name: Build an Ansible compatible image (new) # noqa: no-handler
- name: Build an Ansible compatible image (new) # noqa: no-handler
when:
- platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
- not item.item.pre_build_image | default(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_docker_networks(data, labels={}):
return network_list


class FilterModule(object):
class FilterModule:
"""Core Molecule filter plugins."""

def filters(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
tags:
- always
tasks:

- name: Assure we have docker module installed
ansible.builtin.pip:
name: docker
Expand Down
6 changes: 3 additions & 3 deletions src/molecule_plugins/ec2/cookiecutter/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"molecule_directory": "molecule",
"role_name": "OVERRIDDEN",
"scenario_name": "OVERRIDDEN"
"molecule_directory": "molecule",
"role_name": "OVERRIDDEN",
"scenario_name": "OVERRIDDEN"
}
Loading

0 comments on commit d3c16c4

Please sign in to comment.