Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macos to test matrix #4100

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
pkg
eco
py311-devel
platforms: linux,macos

build:
name: ${{ matrix.name }}
Expand Down Expand Up @@ -62,33 +63,38 @@ jobs:
path: |
~/.cache/pre-commit
key: pre-commit-${{ matrix.name || matrix.passed_name }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install system dependencies

- name: Install system dependencies on Linux
if: ${{ runner.os == 'Linux' }}
# remove broken .deb ansible and replace with pip version:
# https://github.com/actions/virtual-environments/issues/3001
run: |
sudo apt-get remove -y ansible \
&& sudo apt-get update \
&& sudo apt-get install -y libvirt-dev python3-cryptography python3-jinja2 python3-yaml virtualenv \
&& sudo apt-get install -y libvirt-dev python3-cryptography python3-jinja2 python3-yaml virtualenv fish zsh \
&& pip3 install --user ansible-core ansible-lint\
&& echo "$HOME/.local/bin" >> $GITHUB_PATH
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
- name: Validate that ansible works

- name: Install system dependencies on macOS
if: ${{ runner.os == 'macOS' }}
run: |
ansible --version \
&& virtualenv foo \
&& source foo/bin/activate \
&& ansible --version
brew install bash fish

- name: Set up Python ${{ matrix.python_version || '3.10' }}
if: "!contains(matrix.shell, 'wsl')"
uses: actions/setup-python@v5
with:
cache: pip
python-version: ${{ matrix.python_version || '3.10' }}

- name: Install tox
run: |
set -euxo pipefail
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade "tox>=4.0.0"
bash --version
zsh --version
fish --version

- name: Log installed dists
run: python3 -m pip freeze --all
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ filterwarnings = [
]

[tool.ruff]
ignore = [
lint.ignore = [
# Disabled on purpose:
"E501", # we use black
"FBT", # Boolean positional value in function call
Expand Down Expand Up @@ -204,18 +204,18 @@ ignore = [
"T",
"TRY",
]
select = ["ALL"]
lint.select = ["ALL"]
target-version = "py310"
# Same as Black.
line-length = 88

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

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

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"test/**.py" = ["S"]
"src/molecule/*/\\{\\{*/**.py" = ["S"]

Expand Down
30 changes: 18 additions & 12 deletions test/a_unit/command/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# DEALINGS IN THE SOFTWARE.

import os
import shutil

import pytest
from pytest_mock import MockerFixture
Expand Down Expand Up @@ -287,25 +288,30 @@ def test_get_subcommand() -> None:


@pytest.mark.parametrize(
"shell",
("shell", "rc", "prepare_cmd"),
[
"bash",
"zsh",
"fish",
pytest.param("bash", 0, "", id="bash"),
pytest.param("zsh", 0, "autoload -Uz compinit;compinit;", id="zsh"),
pytest.param("fish", 0, "", id="fish"),
pytest.param("foo", 127, "", id="foo"),
],
)
def test_command_completion(shell: str) -> None:
def test_command_completion(shell: str, rc: int, prepare_cmd: str) -> None:
env = os.environ.copy()
env["_MOLECULE_COMPLETE"] = f"{shell}_source"

if "bash" in shell:
bash_version = util.run_command(["bash", "--version"]).stdout.split()[3][0:3]
if not shutil.which(shell) and rc == 0:
pytest.skip(f"Skipped test due to missing {shell} executable.")

result = util.run_command(["molecule"], env=env)
cmd = [
shell,
"-c",
f'{prepare_cmd}eval "$(_MOLECULE_COMPLETE={shell}_source molecule)"',
]
result = util.run_command(cmd, env=env)

if "bash" in shell and (float(bash_version) < 4.4):
assert result.returncode == 1
assert "Found config file" not in result.stdout
if "completion is not supported for Bash versions older than 4.4" in result.stderr:
assert result.returncode == 2
else:
assert result.returncode == 0
assert result.returncode == rc
assert "Found config file" not in result.stdout
12 changes: 10 additions & 2 deletions test/b_functional/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import os
import pathlib
import sys
from test.b_functional.conftest import (
idempotence,
init_scenario,
Expand Down Expand Up @@ -382,20 +383,27 @@ def mock_return(scenario_paths) -> list[str]:


def test_podman() -> None:
expected = 0
if bool(os.getenv("GITHUB_ACTIONS")) and sys.platform == "darwin":
expected = 1

assert (
run_command(
["molecule", "test", "--scenario-name", "podman"],
).returncode
== 0
== expected
)


def test_docker() -> None:
expected = 0
if bool(os.getenv("GITHUB_ACTIONS")) and sys.platform == "darwin":
expected = 1
assert (
run_command(
["molecule", "test", "--scenario-name", "docker"],
).returncode
== 0
== expected
)


Expand Down
Loading