summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.git_archival.txt8
-rw-r--r--.github/workflows/ack.yml3
-rw-r--r--.github/workflows/tox.yml13
-rw-r--r--.pre-commit-config.yaml6
-rw-r--r--src/ansible_compat/__init__.py1
-rw-r--r--src/ansible_compat/config.py1
-rw-r--r--src/ansible_compat/errors.py1
-rw-r--r--src/ansible_compat/loaders.py1
-rw-r--r--src/ansible_compat/ports.py1
-rw-r--r--src/ansible_compat/prerun.py1
-rw-r--r--src/ansible_compat/runtime.py29
-rw-r--r--src/ansible_compat/schema.py1
-rw-r--r--src/ansible_compat/types.py1
-rw-r--r--test/conftest.py1
-rw-r--r--test/test_config.py1
-rw-r--r--test/test_configuration_example.py1
-rw-r--r--test/test_loaders.py1
-rw-r--r--test/test_prerun.py1
-rw-r--r--test/test_runtime.py10
-rw-r--r--test/test_runtime_example.py1
-rw-r--r--test/test_schema.py1
21 files changed, 57 insertions, 27 deletions
diff --git a/.git_archival.txt b/.git_archival.txt
index 242fcd6..d6cf91b 100644
--- a/.git_archival.txt
+++ b/.git_archival.txt
@@ -1,4 +1,4 @@
-node: e92db9f0811206312edf621372de35ea9cff719f
-node-date: 2024-01-10T12:47:29+00:00
-describe-name: v4.1.11
-ref-names: HEAD -> main, tag: v4.1.11
+node: 1ff572c26b20363436af440921fec1b3d6d1d19f
+node-date: 2024-03-11T15:50:46+00:00
+describe-name: v4.1.12
+ref-names: tag: v4.1.12
diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml
index bdf02b5..1a73a9d 100644
--- a/.github/workflows/ack.yml
+++ b/.github/workflows/ack.yml
@@ -6,4 +6,5 @@ on:
jobs:
ack:
- uses: ansible/devtools/.github/workflows/ack.yml@main
+ uses: ansible/team-devtools/.github/workflows/ack.yml@main
+ secrets: inherit
diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml
index f56f266..c767c48 100644
--- a/.github/workflows/tox.yml
+++ b/.github/workflows/tox.yml
@@ -42,6 +42,7 @@ jobs:
macos: minmax
build:
name: ${{ matrix.name }}
+ environment: test
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
needs: pre
strategy:
@@ -62,13 +63,13 @@ jobs:
python-version: ${{ matrix.python_version }}
- name: Pre-commit cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ matrix.name }}-pre-commit-${{ hashFiles('setup.cfg', 'tox.ini', 'pyproject.toml', '.pre-commit-config.yaml') }}
- name: Pip cache
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ matrix.name }}-pip-${{ hashFiles('setup.cfg', 'tox.ini', 'pyproject.toml', '.pre-commit-config.yaml') }}
@@ -90,11 +91,11 @@ jobs:
- name: Upload coverage data
if: ${{ startsWith(matrix.passed_name, 'py') }}
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
with:
name: ${{ matrix.passed_name }}
- fail_ci_if_error: false # see https://github.com/codecov/codecov-action/issues/598
token: ${{ secrets.CODECOV_TOKEN }}
+ fail_ci_if_error: true # see https://github.com/codecov/codecov-action/issues/598
verbose: true # optional (default = false)
check: # This job does nothing and is only used for the branch protection
@@ -104,6 +105,10 @@ jobs:
- build
runs-on: ubuntu-22.04
steps:
+ - name: Check codecov.io status
+ if: github.event_name == 'pull_request'
+ uses: coactions/codecov-status@main
+
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index a0749a0..57030ab 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -22,7 +22,7 @@ exclude: |
)$
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: "v0.1.9"
+ rev: "v0.2.0"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
@@ -32,7 +32,7 @@ repos:
- id: toml-sort-fix
- repo: https://github.com/pre-commit/mirrors-prettier
# keep it before yamllint
- rev: "v3.0.3"
+ rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
additional_dependencies:
@@ -67,7 +67,7 @@ repos:
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/psf/black
- rev: 23.12.1
+ rev: 24.1.1
hooks:
- id: black
language_version: python3
diff --git a/src/ansible_compat/__init__.py b/src/ansible_compat/__init__.py
index b23c8ca..3c437d4 100644
--- a/src/ansible_compat/__init__.py
+++ b/src/ansible_compat/__init__.py
@@ -1,4 +1,5 @@
"""ansible_compat package."""
+
from importlib.metadata import PackageNotFoundError, version
try:
diff --git a/src/ansible_compat/config.py b/src/ansible_compat/config.py
index a0b41b7..6bed01b 100644
--- a/src/ansible_compat/config.py
+++ b/src/ansible_compat/config.py
@@ -1,4 +1,5 @@
"""Store configuration options as a singleton."""
+
from __future__ import annotations
import ast
diff --git a/src/ansible_compat/errors.py b/src/ansible_compat/errors.py
index 6369412..25db7c7 100644
--- a/src/ansible_compat/errors.py
+++ b/src/ansible_compat/errors.py
@@ -1,4 +1,5 @@
"""Module to deal with errors."""
+
from __future__ import annotations
from typing import TYPE_CHECKING, Any
diff --git a/src/ansible_compat/loaders.py b/src/ansible_compat/loaders.py
index d2ae080..9951094 100644
--- a/src/ansible_compat/loaders.py
+++ b/src/ansible_compat/loaders.py
@@ -1,4 +1,5 @@
"""Utilities for loading various files."""
+
from __future__ import annotations
from typing import TYPE_CHECKING, Any
diff --git a/src/ansible_compat/ports.py b/src/ansible_compat/ports.py
index 9c46ae6..bdb9db5 100644
--- a/src/ansible_compat/ports.py
+++ b/src/ansible_compat/ports.py
@@ -1,4 +1,5 @@
"""Portability helpers."""
+
from functools import cache, cached_property
__all__ = ["cache", "cached_property"]
diff --git a/src/ansible_compat/prerun.py b/src/ansible_compat/prerun.py
index 6dfa44f..9448269 100644
--- a/src/ansible_compat/prerun.py
+++ b/src/ansible_compat/prerun.py
@@ -1,4 +1,5 @@
"""Utilities for configuring ansible runtime environment."""
+
import hashlib
import os
from pathlib import Path
diff --git a/src/ansible_compat/runtime.py b/src/ansible_compat/runtime.py
index ad81132..4556b7e 100644
--- a/src/ansible_compat/runtime.py
+++ b/src/ansible_compat/runtime.py
@@ -1,4 +1,5 @@
"""Ansible runtime environment manager."""
+
from __future__ import annotations
import contextlib
@@ -94,11 +95,11 @@ class Plugins: # pylint: disable=too-many-instance-attributes
lookup: dict[str, str] = field(init=False)
netconf: dict[str, str] = field(init=False)
shell: dict[str, str] = field(init=False)
- vars: dict[str, str] = field(init=False) # noqa: A003
+ vars: dict[str, str] = field(init=False)
module: dict[str, str] = field(init=False)
strategy: dict[str, str] = field(init=False)
test: dict[str, str] = field(init=False)
- filter: dict[str, str] = field(init=False) # noqa: A003
+ filter: dict[str, str] = field(init=False)
role: dict[str, str] = field(init=False)
keyword: dict[str, str] = field(init=False)
@@ -589,6 +590,7 @@ class Runtime:
_logger.error(result.stderr)
raise AnsibleCommandError(result)
+ # pylint: disable=too-many-locals
def prepare_environment( # noqa: C901
self,
required_collections: dict[str, str] | None = None,
@@ -608,7 +610,10 @@ class Runtime:
# https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#ansible-galaxy-support
# https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#collections-support
for req_file in REQUIREMENT_LOCATIONS:
- self.install_requirements(Path(req_file), retry=retry, offline=offline)
+ file_path = Path(req_file)
+ if self.project_dir:
+ file_path = self.project_dir / req_file
+ self.install_requirements(file_path, retry=retry, offline=offline)
self._prepare_ansible_paths()
@@ -773,13 +778,15 @@ class Runtime:
]
alterations_list.extend(
- [
- (roles_path, f"{self.cache_dir}/roles", False),
- (library_paths, f"{self.cache_dir}/modules", False),
- (collections_path, f"{self.cache_dir}/collections", False),
- ]
- if self.isolated
- else [],
+ (
+ [
+ (roles_path, f"{self.cache_dir}/roles", False),
+ (library_paths, f"{self.cache_dir}/modules", False),
+ (collections_path, f"{self.cache_dir}/collections", False),
+ ]
+ if self.isolated
+ else []
+ ),
)
for path_list, path_, must_be_present in alterations_list:
@@ -853,7 +860,7 @@ class Runtime:
fqrn = _get_role_fqrn(galaxy_info, project_dir)
if role_name_check in [0, 1]:
- if not re.match(r"[a-z0-9][a-z0-9_]+\.[a-z][a-z0-9_]+$", fqrn):
+ if not re.match(r"[a-z0-9][a-z0-9_-]+\.[a-z][a-z0-9_]+$", fqrn):
msg = MSG_INVALID_FQRL.format(fqrn)
if role_name_check == 1:
_logger.warning(msg)
diff --git a/src/ansible_compat/schema.py b/src/ansible_compat/schema.py
index 2950e08..d9d1206 100644
--- a/src/ansible_compat/schema.py
+++ b/src/ansible_compat/schema.py
@@ -1,4 +1,5 @@
"""Utils for JSON Schema validation."""
+
from __future__ import annotations
import json
diff --git a/src/ansible_compat/types.py b/src/ansible_compat/types.py
index 4514606..44d3328 100644
--- a/src/ansible_compat/types.py
+++ b/src/ansible_compat/types.py
@@ -1,4 +1,5 @@
"""Custom types."""
+
from __future__ import annotations
from collections.abc import Mapping, Sequence
diff --git a/test/conftest.py b/test/conftest.py
index a1e4893..59ea315 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -1,4 +1,5 @@
"""Pytest fixtures."""
+
import importlib.metadata
import json
import pathlib
diff --git a/test/test_config.py b/test/test_config.py
index 4f854ae..ebdde00 100644
--- a/test/test_config.py
+++ b/test/test_config.py
@@ -1,4 +1,5 @@
"""Tests for ansible_compat.config submodule."""
+
import copy
import subprocess
diff --git a/test/test_configuration_example.py b/test/test_configuration_example.py
index 3a2c9b7..c7ed310 100644
--- a/test/test_configuration_example.py
+++ b/test/test_configuration_example.py
@@ -1,4 +1,5 @@
"""Sample usage of AnsibleConfig."""
+
from ansible_compat.config import AnsibleConfig
diff --git a/test/test_loaders.py b/test/test_loaders.py
index 7a91a4c..01cc892 100644
--- a/test/test_loaders.py
+++ b/test/test_loaders.py
@@ -1,4 +1,5 @@
"""Test for ansible_compat.loaders module."""
+
from pathlib import Path
from ansible_compat.loaders import colpath_from_path
diff --git a/test/test_prerun.py b/test/test_prerun.py
index 1549756..d832088 100644
--- a/test/test_prerun.py
+++ b/test/test_prerun.py
@@ -1,4 +1,5 @@
"""Tests for ansible_compat.prerun module."""
+
from pathlib import Path
from ansible_compat.prerun import get_cache_dir
diff --git a/test/test_runtime.py b/test/test_runtime.py
index 2af343d..6a110d4 100644
--- a/test/test_runtime.py
+++ b/test/test_runtime.py
@@ -1,4 +1,5 @@
"""Tests for Runtime class."""
+
# pylint: disable=protected-access
from __future__ import annotations
@@ -242,8 +243,8 @@ def cwd(path: Path) -> Iterator[None]:
def test_prerun_reqs_v1(caplog: pytest.LogCaptureFixture) -> None:
"""Checks that the linter can auto-install requirements v1 when found."""
- runtime = Runtime(verbosity=1)
path = Path(__file__).parent.parent / "examples" / "reqs_v1"
+ runtime = Runtime(project_dir=path, verbosity=1)
with cwd(path):
runtime.prepare_environment()
assert any(
@@ -257,8 +258,8 @@ def test_prerun_reqs_v1(caplog: pytest.LogCaptureFixture) -> None:
def test_prerun_reqs_v2(caplog: pytest.LogCaptureFixture) -> None:
"""Checks that the linter can auto-install requirements v2 when found."""
- runtime = Runtime(verbosity=1)
path = (Path(__file__).parent.parent / "examples" / "reqs_v2").resolve()
+ runtime = Runtime(project_dir=path, verbosity=1)
with cwd(path):
runtime.prepare_environment()
assert any(
@@ -271,9 +272,10 @@ def test_prerun_reqs_v2(caplog: pytest.LogCaptureFixture) -> None:
)
-def test_prerun_reqs_broken(runtime: Runtime) -> None:
+def test_prerun_reqs_broken() -> None:
"""Checks that the we report invalid requirements.yml file."""
path = (Path(__file__).parent.parent / "examples" / "reqs_broken").resolve()
+ runtime = Runtime(project_dir=path, verbosity=1)
with cwd(path), pytest.raises(InvalidPrerequisiteError):
runtime.prepare_environment()
@@ -580,7 +582,7 @@ def test_install_galaxy_role_name_role_name_check_equals_to_1(
caplog: pytest.LogCaptureFixture,
) -> None:
"""Check install role with bad role name in galaxy info."""
- caplog.set_level(logging.WARN)
+ caplog.set_level(logging.WARNING)
pathlib.Path(f"{runtime_tmp.project_dir}/meta").mkdir()
pathlib.Path(f"{runtime_tmp.project_dir}/meta/main.yml").write_text(
galaxy_info,
diff --git a/test/test_runtime_example.py b/test/test_runtime_example.py
index e500e59..17be483 100644
--- a/test/test_runtime_example.py
+++ b/test/test_runtime_example.py
@@ -1,4 +1,5 @@
"""Sample use of Runtime class."""
+
from ansible_compat.runtime import Runtime
diff --git a/test/test_schema.py b/test/test_schema.py
index b253cb5..10c1a9a 100644
--- a/test/test_schema.py
+++ b/test/test_schema.py
@@ -1,4 +1,5 @@
"""Tests for schema utilities."""
+
from __future__ import annotations
import json