Skip to content

Commit 0a5ec06

Browse files
cristianonicolaissbarnea
authored andcommitted
Add macos to test matrix
1 parent b4d1d97 commit 0a5ec06

File tree

4 files changed

+45
-31
lines changed

4 files changed

+45
-31
lines changed

.github/workflows/tox.yml

+11-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
pkg
3333
eco
3434
py311-devel
35+
platforms: linux,macos
3536

3637
build:
3738
name: ${{ matrix.name }}
@@ -47,7 +48,7 @@ jobs:
4748
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}
4849

4950
env:
50-
PYTEST_REQPASS: 450
51+
PYTEST_REQPASS: 451
5152
environment: test
5253
steps:
5354
- uses: actions/checkout@v4
@@ -62,24 +63,25 @@ jobs:
6263
path: |
6364
~/.cache/pre-commit
6465
key: pre-commit-${{ matrix.name || matrix.passed_name }}-${{ hashFiles('.pre-commit-config.yaml') }}
65-
- name: Install system dependencies
66+
67+
- name: Install system dependencies on Linux
68+
if: ${{ runner.os == 'Linux' }}
6669
# remove broken .deb ansible and replace with pip version:
6770
# https://github.com/actions/virtual-environments/issues/3001
6871
run: |
6972
sudo apt-get remove -y ansible \
7073
&& sudo apt-get update \
71-
&& sudo apt-get install -y libvirt-dev python3-cryptography python3-jinja2 python3-yaml virtualenv \
74+
&& sudo apt-get install -y libvirt-dev python3-cryptography python3-jinja2 python3-yaml virtualenv fish zsh \
7275
&& pip3 install --user ansible-core ansible-lint\
7376
&& echo "$HOME/.local/bin" >> $GITHUB_PATH
7477
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
75-
- name: Validate that ansible works
78+
79+
- name: Install system dependencies on macOS
80+
if: ${{ runner.os == 'macOS' }}
7681
run: |
77-
ansible --version \
78-
&& virtualenv foo \
79-
&& source foo/bin/activate \
80-
&& ansible --version
82+
brew install bash fish
83+
8184
- name: Set up Python ${{ matrix.python_version || '3.10' }}
82-
if: "!contains(matrix.shell, 'wsl')"
8385
uses: actions/setup-python@v5
8486
with:
8587
cache: pip

pyproject.toml

+6-8
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ filterwarnings = [
176176
]
177177

178178
[tool.ruff]
179-
ignore = [
179+
lint.ignore = [
180180
# Disabled on purpose:
181181
"E501", # we use black
182182
"FBT", # Boolean positional value in function call
@@ -204,27 +204,25 @@ ignore = [
204204
"T",
205205
"TRY",
206206
]
207-
select = ["ALL"]
207+
lint.select = ["ALL"]
208208
target-version = "py310"
209209
# Same as Black.
210210
line-length = 88
211211

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

215-
[tool.ruff.isort]
215+
[tool.ruff.lint.isort]
216216
known-first-party = ["molecule"]
217217

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

222222
[tool.setuptools.dynamic]
223223
optional-dependencies.docs = { file = [".config/requirements-docs.txt"] }
224224
optional-dependencies.test = { file = [".config/requirements-test.txt"] }
225-
optional-dependencies.testinfra = { file = [
226-
".config/requirements-testinfra.txt",
227-
] }
225+
optional-dependencies.testinfra = { file = [".config/requirements-testinfra.txt"] }
228226
dependencies = { file = [".config/requirements.in"] }
229227

230228
[tool.setuptools_scm]

test/a_unit/command/test_base.py

+18-12
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# DEALINGS IN THE SOFTWARE.
2020

2121
import os
22+
import shutil
2223

2324
import pytest
2425
from pytest_mock import MockerFixture
@@ -287,25 +288,30 @@ def test_get_subcommand() -> None:
287288

288289

289290
@pytest.mark.parametrize(
290-
"shell",
291+
("shell", "rc", "prepare_cmd"),
291292
[
292-
"bash",
293-
"zsh",
294-
"fish",
293+
pytest.param("bash", 0, "", id="bash"),
294+
pytest.param("zsh", 0, "autoload -Uz compinit;compinit;", id="zsh"),
295+
pytest.param("fish", 0, "", id="fish"),
296+
pytest.param("foo", 127, "", id="foo"),
295297
],
296298
)
297-
def test_command_completion(shell: str) -> None:
299+
def test_command_completion(shell: str, rc: int, prepare_cmd: str) -> None:
298300
env = os.environ.copy()
299301
env["_MOLECULE_COMPLETE"] = f"{shell}_source"
300302

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

304-
result = util.run_command(["molecule"], env=env)
306+
cmd = [
307+
shell,
308+
"-c",
309+
f'{prepare_cmd}eval "$(_MOLECULE_COMPLETE={shell}_source molecule)"',
310+
]
311+
result = util.run_command(cmd, env=env)
305312

306-
if "bash" in shell and (float(bash_version) < 4.4):
307-
assert result.returncode == 1
308-
assert "Found config file" not in result.stdout
313+
if "completion is not supported for Bash versions older than 4.4" in result.stderr:
314+
assert result.returncode == 2
309315
else:
310-
assert result.returncode == 0
316+
assert result.returncode == rc
311317
assert "Found config file" not in result.stdout

test/b_functional/test_command.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import os
2323
import pathlib
24+
import sys
2425
from test.b_functional.conftest import (
2526
idempotence,
2627
init_scenario,
@@ -382,20 +383,27 @@ def mock_return(scenario_paths) -> list[str]:
382383

383384

384385
def test_podman() -> None:
386+
expected = 0
387+
if bool(os.getenv("GITHUB_ACTIONS")) and sys.platform == "darwin":
388+
expected = 1
389+
385390
assert (
386391
run_command(
387392
["molecule", "test", "--scenario-name", "podman"],
388393
).returncode
389-
== 0
394+
== expected
390395
)
391396

392397

393398
def test_docker() -> None:
399+
expected = 0
400+
if bool(os.getenv("GITHUB_ACTIONS")) and sys.platform == "darwin":
401+
expected = 1
394402
assert (
395403
run_command(
396404
["molecule", "test", "--scenario-name", "docker"],
397405
).returncode
398-
== 0
406+
== expected
399407
)
400408

401409

0 commit comments

Comments
 (0)