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 5fd0c23 commit 570ffce
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 129 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 }}
146 changes: 146 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
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 docker_container
- 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: |
docker version
docker info
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 }}
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
repos:
- repo: https://github.com/PyCQA/doc8.git
rev: 0.8.1rc1
rev: 0.9.0a1
hooks:
- id: doc8
- repo: https://github.com/python/black.git
rev: 19.3b0
rev: 20.8b1
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks.git
rev: v2.2.3
rev: v3.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -20,20 +20,20 @@ repos:
- id: check-merge-conflict
- id: debug-statements
- repo: https://gitlab.com/pycqa/flake8.git
rev: 3.7.8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-black
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.16.0
rev: v1.25.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/codespell-project/codespell.git
rev: v1.15.0
rev: v1.17.1
hooks:
- id: codespell
name: codespell
Expand Down
2 changes: 1 addition & 1 deletion molecule_libvirt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def sanity_checks(self):
pass

def template_dir(self):
""" Return path to its own cookiecutterm templates. It is used by init
"""Return path to its own cookiecutterm templates. It is used by init
command in order to figure out where to load the templates from.
"""
return os.path.join(
Expand Down
32 changes: 18 additions & 14 deletions molecule_libvirt/test/functional/test_libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

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
Expand All @@ -35,23 +35,27 @@
@pytest.mark.xfail(reason="need to fix template path")
def test_command_init_scenario(temp_dir):
role_directory = os.path.join(temp_dir.strpath, "test-init")
options = {"role_name": "test-init"}
cmd = sh.molecule.bake("init", "role", **options)
run_command(cmd)
cmd = ["molecule", "init", "role", "--role-name", "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 = {
"scenario_name": "test-scenario",
"role_name": "test-init",
"driver-name": "libvirt",
}
cmd = sh.molecule.bake("init", "scenario", **options)
run_command(cmd)
cmd = [
"molecule",
"init",
"scenario",
"--scenario-name",
"test-scenario",
"--role-name",
"test-init",
"--driver-name",
"libvirt",
]
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
20 changes: 17 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
[build-system]
requires = [
"pip >= 19.3.1",
"setuptools >= 42.0.2",
"setuptools_scm >= 1.15.0",
"setuptools_scm_git_archive >= 1.0",
"wheel",
"setuptools_scm[toml] >= 3.5.0",
"setuptools_scm_git_archive >= 1.1",
"wheel >= 0.33.6",
]
build-backend = "setuptools.build_meta"

[tool.black]
skip-string-normalization = false

[tool.isort]
profile = "black"
float_to_top = true
known_third_party = [
"molecule"
]

[tool.setuptools_scm]
local_scheme = "no-local-version"
Loading

0 comments on commit 570ffce

Please sign in to comment.