Skip to content

Commit

Permalink
Add pip upgrade (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock authored Jun 13, 2024
1 parent b88eb13 commit a0416f2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ line-length = 100

[tool.coverage.report]
exclude_also = ["if TYPE_CHECKING:", "pragma: no cover"]
fail_under = 75
fail_under = 82
ignore_errors = true
show_missing = true
skip_covered = true
Expand Down
9 changes: 8 additions & 1 deletion src/tox_ansible/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def conf_commands_for_sanity(
return commands


def conf_commands_pre(
def conf_commands_pre( # noqa: C901
env_conf: EnvConfigSet,
c_name: str,
c_namespace: str,
Expand All @@ -473,6 +473,13 @@ def conf_commands_pre(
galaxy_build_dir = f"{envtmpdir}/collection_build"
end_group = "echo ::endgroup::"

if in_action():
group = "echo ::group::Ensure pip is up to date"
commands.append(group)
commands.append("python -m ensurepip --upgrade")
if in_action():
commands.append(end_group)

if in_action():
group = "echo ::group::Make the galaxy build dir"
commands.append(group)
Expand Down
42 changes: 42 additions & 0 deletions tests/unit/test_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Unit plugin tests."""

from pathlib import Path

import pytest

from tox.config.cli.parser import Parsed
from tox.config.main import Config
from tox.config.source import discover_source

from tox_ansible.plugin import conf_commands_pre


def test_commands_pre(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
"""Test pre-command generation.
Args:
monkeypatch: Pytest fixture.
tmp_path: Pytest fixture.
"""
monkeypatch.setenv("GITHUB_ACTIONS", "true")

ini_file = tmp_path / "tox.ini"
ini_file.touch()
source = discover_source(ini_file, None)

conf = Config.make(
Parsed(work_dir=tmp_path, override=[], config_file=ini_file, root_dir=tmp_path),
pos_args=[],
source=source,
).get_env("py39")

conf.add_config(
keys=["env_tmp_dir", "envtmpdir"],
of_type=Path,
default=tmp_path,
desc="",
)

result = conf_commands_pre(env_conf=conf, c_name="test", c_namespace="test")
number_commands = 15
assert len(result) == number_commands, result

0 comments on commit a0416f2

Please sign in to comment.