diff --git a/.ansible-lint b/.ansible-lint index 6442de86..788ebba2 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -10,3 +10,4 @@ exclude_paths: - "roles/install_module/vars/" # Exclude copied playbook - uses nsls2.general collection - "scripts/deploy_ioc.yml" + - "collections/ansible_collections/" diff --git a/.github/workflows/validate_module_configs.yml b/.github/workflows/validate_configs.yml similarity index 100% rename from .github/workflows/validate_module_configs.yml rename to .github/workflows/validate_configs.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 97125e8b..ee5e285c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,8 @@ --- +exclude: | + ^collections/ansible_collections/ + repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 diff --git a/pytest.ini b/pytest.ini index a603533b..29e91593 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,3 +2,4 @@ log_format = "%(asctime)s,%(msecs)03d %(levelname)s (%(threadName)s) %(message)s" log_date_format = "%H:%M:%S" addopts = "-v" +testpaths = tests diff --git a/ruff.toml b/ruff.toml index 02f33cfd..23aedd09 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,4 +1,6 @@ +exclude = ["collections/ansible_collections"] line-length = 88 +indent-width = 4 lint.select = [ "B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b "C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4 diff --git a/tests/test_device_roles.py b/tests/test_device_roles.py index 50954856..b13f5730 100644 --- a/tests/test_device_roles.py +++ b/tests/test_device_roles.py @@ -1,15 +1,22 @@ -import os +from pathlib import Path import pytest -DEVICE_ROLES = [ - role - for role in os.listdir("roles/device_roles") - if os.path.isdir(os.path.join("roles/device_roles", role)) -] +DEVICE_ROLES_PATH = Path("roles/device_roles") + +DEVICE_ROLES = [role.stem for role in DEVICE_ROLES_PATH.iterdir() if role.is_dir()] @pytest.mark.parametrize("device_role", DEVICE_ROLES) def test_ensure_var_file_for_device_role_exists(device_role): - var_file_path = os.path.join("roles", "deploy_ioc", "vars", f"{device_role}.yml") - assert os.path.exists(var_file_path), f"Vars file {var_file_path} not found" + var_file_path = Path("roles/deploy_ioc/vars") / f"{device_role}.yml" + assert var_file_path.exists(), f"Vars file {var_file_path} not found" + + +@pytest.mark.parametrize("device_role", DEVICE_ROLES) +def test_every_device_role_has_a_readme(device_role): + device_role_path = DEVICE_ROLES_PATH / device_role + readme_path = device_role_path / "README.md" + assert readme_path.exists(), ( + f"README.md not found for device role: {device_role}" + )