Skip to content

Commit

Permalink
Compatibility with ansible-core 2.18 (#1882)
Browse files Browse the repository at this point in the history
* Testing and compatibility with ansible-core 2.18

* REmove tox-extra

* docstring

* Additional fixture updates

* Update images

* Update constraint

* Constrain 2.18

* More fixtures

* Unquiet docker

* Fixtures

* Fixture update

* Image name update

* latest for small

* Image update

* Cleanup image tests

* Restore venv name

* Remove tmux error

* Workaround for codecov-action bug with oidc

* Add test for changes in parse_and_merge in config.py

* test cleanup

---------

Co-authored-by: shatakshiiii <[email protected]>
Co-authored-by: abhikdps <[email protected]>
  • Loading branch information
3 people authored Jan 20, 2025
1 parent bdf7983 commit 12272bf
Show file tree
Hide file tree
Showing 726 changed files with 7,211 additions and 4,501 deletions.
15 changes: 10 additions & 5 deletions .config/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
#
# pip-compile --all-extras --no-annotate --output-file=.config/constraints.txt --strip-extras pyproject.toml
#
# For testing with ansible-core 2.18, please restore the ansible-core lines manually
ansible-builder==3.1.0
ansible-compat==24.10.0
ansible-core==2.16.5
ansible-lint==24.12.2
ansible-core==2.17.6 ; python_version < '3.11'
ansible-core==2.18.0 ; python_version > '3.10'
ansible-lint==24.10.0
ansible-runner==2.4.0
attrs==24.2.0
babel==2.16.0
Expand All @@ -33,17 +35,18 @@ defusedxml==0.7.1
distlib==0.3.9
distro==1.9.0
dnspython==2.7.0
docutils==0.21.2
exceptiongroup==1.2.2
execnet==2.1.1
filelock==3.16.1
flake8==7.1.1
flake8-docstrings==1.7.0
ghp-import==2.1.0
griffe==1.5.1
hjson==3.1.0
htmlmin2==0.1.13
identify==2.6.3
idna==3.10
importlib-metadata==8.5.0
iniconfig==2.0.0
jinja2==3.1.4
jsmin==3.0.1
Expand All @@ -60,10 +63,11 @@ markupsafe==3.0.2
mccabe==0.7.0
mdurl==0.1.2
mergedeep==1.3.4
mkdocs==1.6.0
mkdocs==1.6.1
mkdocs-ansible==24.12.0
mkdocs-autorefs==1.2.0
mkdocs-gen-files==0.5.0
mkdocs-get-deps==0.2.0
mkdocs-htmlproofer-plugin==1.3.0
mkdocs-macros-plugin==1.3.7
mkdocs-material==9.5.48
Expand Down Expand Up @@ -107,7 +111,6 @@ pyyaml-env-tag==0.1
referencing==0.35.1
regex==2024.11.6
requests==2.32.3
requirements-parser==0.11.0
resolvelib==1.0.1
rich==13.9.4
rpds-py==0.22.3
Expand All @@ -117,6 +120,7 @@ six==1.17.0
snowballstemmer==2.2.0
soupsieve==2.6
subprocess-tee==0.4.2
super-collections==0.5.3
termcolor==2.5.0
text-unidecode==1.3
tinycss2==1.4.0
Expand All @@ -130,6 +134,7 @@ watchdog==6.0.0
wcmatch==10.0
webencodings==0.5.1
yamllint==1.35.1
zipp==3.21.0

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
with:
name: ${{ matrix.name }}
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc

- name: Check codecov.io status
if: github.event_name == 'pull_request'
Expand Down
4 changes: 4 additions & 0 deletions src/ansible_navigator/actions/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,12 @@ def _parse_and_merge(self, list_output: str, dump_output: str) -> None:
self._logger.debug("error yaml loading list output: '%s'", str(exc))
return

parsed.pop("GALAXY_SERVERS", None)

regex = re.compile(r"^(?P<variable>\S+)\((?P<source>.*)\)\s=\s(?P<current>.*)$")
for line in dump_output.splitlines():
if not line:
break
extracted = regex.match(line)
if extracted:
variable = extracted.groupdict()["variable"]
Expand Down
9 changes: 7 additions & 2 deletions src/ansible_navigator/configuration_subsystem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,22 @@ def parse_ansible_cfg(ee_enabled: bool) -> ParseAnsibleCfgResponse:
return response


def parse_ansible_verison() -> tuple[list[LogMessage], list[ExitMessage], dict[str, Any] | None]:
def parse_ansible_verison(
path: Path | None = None,
) -> tuple[list[LogMessage], list[ExitMessage], dict[str, Any] | None]:
"""Parse the output of the ansible --version command.
:param path: The path to the ansible executable
:returns: Log messages, exit messages, and the stdout as a dictionary
"""
messages: list[LogMessage] = []
exit_messages: list[ExitMessage] = []

ansible_cmd = "ansible" if path is None else str(path / "ansible")

command = Command(
identity="ansible_version",
command="ansible --version",
command=f"{ansible_cmd} --version",
post_process=ansible_verison_parser,
)

Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/data/images_dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
FROM ghcr.io/ansible/community-ansible-dev-tools:latest as DEFAULT_EE

# This is also hard coded in tests/fixtures/integration/execution_environment_image/ansible-navigator_set_ee_image.yml
FROM ghcr.io/ansible/creator-base:latest as SMALL_IMAGE
FROM quay.io/fedora/python-313:latest as SMALL_IMAGE

FROM registry.hub.docker.com/library/alpine:latest as PULLABLE_IMAGE
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def valid_ce() -> str:
# the habit of getting stuck.
try:
cmd = [engine, "info"]
subprocess.check_output(cmd, stderr=subprocess.STDOUT, timeout=6)
subprocess.check_output(cmd, stderr=subprocess.STDOUT, timeout=10)
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as exc:
msg = f"Container engine is broken, fail to run: {' '.join(cmd)}: {exc}"
continue
Expand Down Expand Up @@ -381,7 +381,9 @@ def pytest_configure(config: pytest.Config) -> None:
print(f"[NOTE] The environment variable(s) {env_vars} will be restored after the test run")

# look for ansible.cfg
_log, errors, details = parse_ansible_verison()
# use the current interpreter to get the ansible version
bin_dir = Path(sys.executable).parent
_log, errors, details = parse_ansible_verison(path=bin_dir)
if details is None:
err = "\n".join(error.message for error in errors)
pytest.exit(f"Error parsing ansible version:\n{err}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 3

images:
base_image:
name: registry.fedoraproject.org/fedora:38
name: quay.io/fedora/python-313:latest

dependencies:
ansible_core:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test[builder help-builder with ee clear && ansible-navigator builder --help-builder --ee True --ll debug --mode stdout]",
"name": "test[step0]",
"index": 0,
"comment": "builder help-builder with ee",
"additional_information": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test[builder help-builder without ee clear && ansible-navigator builder --help-builder --ee False --ll debug --mode stdout]",
"name": "test[step1]",
"index": 1,
"comment": "builder help-builder without ee",
"additional_information": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test[builder help-builder with interactive with ee clear && ansible-navigator builder --help-builder --ee True --ll debug --mode interactive]",
"name": "test[step2]",
"index": 2,
"comment": "builder help-builder with interactive with ee",
"additional_information": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test[builder help-builder with interactive without ee clear && ansible-navigator builder --help-builder --ee False --ll debug --mode interactive]",
"name": "test[step3]",
"index": 3,
"comment": "builder help-builder with interactive without ee",
"additional_information": {
Expand Down
Loading

0 comments on commit 12272bf

Please sign in to comment.