Skip to content

Commit

Permalink
Minor build fixes (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Sep 27, 2024
1 parent 5a92cfc commit 3e265ff
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .config/pydoclint-baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tests/conftest.py
DOC503: Method `Infrastructure.__post_init__` exceptions in the "Raises" section in the docstring do not match those in the function body Raises values in the docstring: ['ValueError', 'ValueError', 'ValueError']. Raised exceptions in the body: ['ValueError'].
--------------------
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@ cython_debug/
_readthedocs

# ansible-builder
context
collections
/context
/collections
22 changes: 13 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,31 @@ repos:
- prettier-plugin-toml
- prettier-plugin-sort-json

- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black

- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort-fix

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.3.1
rev: 1.4.1
hooks:
- id: tox-ini-fmt

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
rev: v0.6.8
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix
types_or: [python, pyi]
- id: ruff-format # must be after ruff
types_or: [python, pyi]

- repo: https://github.com/psf/black # must be after ruff
rev: 24.8.0
hooks:
- id: black

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.13.3
Expand All @@ -72,15 +76,15 @@ repos:
name: Spell check with cspell

- repo: https://github.com/jsh9/pydoclint
rev: "0.5.6"
rev: "0.5.8"
hooks:
- id: pydoclint
# This allows automatic reduction of the baseline file when needed.
entry: sh -ec "pydoclint . && pydoclint --generate-baseline=1 ."
pass_filenames: false

- repo: https://github.com/pycqa/pylint.git
rev: v3.2.7
rev: v3.3.1
hooks:
- id: pylint
args:
Expand Down
2 changes: 1 addition & 1 deletion bindep.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python3-devel
python3-devel [platform:redhat]
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ homepage = "https://github.com/ansible/ansible-dev-tools"
repository = "https://github.com/ansible/ansible-dev-tools"

[tool.black]
enable-unstable-feature = ["string_processing"]
line-length = 100
preview = true

[tool.coverage.report]
exclude_also = ["if TYPE_CHECKING:", "pragma: no cover"]
Expand Down Expand Up @@ -336,6 +338,14 @@ line-length = 100
target-version = "py310"

[tool.ruff.lint]
external = [
"DOC" # pydoclint
]
ignore = [
# incompatible with ruff formatter
"COM812", # missing-space-after-comma
"ISC001" # implicit-str-concat
]
select = ["ALL"]

[tool.ruff.lint.flake8-pytest-style]
Expand Down
25 changes: 14 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<...>
Tracing '/**/src/<package>/__init__.py'
"""

from __future__ import annotations

import errno
Expand Down Expand Up @@ -315,12 +316,7 @@ def _start_container() -> None:
try:
subprocess.run(cmd, check=True, capture_output=True, shell=True, text=True)
except subprocess.CalledProcessError as exc:
err = (
f"Failed to start container:\n"
f"cmd: {cmd}\n"
f"stdout: {exc.stdout}\n"
f"stderr: {exc.stderr}"
)
err = f"Failed to start container:\ncmd: {cmd}\nstdout: {exc.stdout}\nstderr: {exc.stderr}"
pytest.fail(err)

# image is local, can't be pulled, use default
Expand Down Expand Up @@ -419,17 +415,24 @@ def _start_server() -> None:
env=os.environ,
)
tries = 0
max_tries = 10
timeout = 2
max_tries = 15 # GHA macos runner showed occasional failures with 10s
msg = "Could not start the server."
while tries < max_tries:
try:
res = requests.get("http://localhost:8000", timeout=1)
# timeout increased to 2s due to observed GHA macos failures
res = requests.get("http://localhost:8000", timeout=timeout)
if res.status_code == requests.codes.get("not_found"):
return
except requests.exceptions.ConnectionError: # noqa: PERF203
except (requests.exceptions.ConnectionError, requests.RequestException): # noqa: PERF203
tries += 1
time.sleep(1)

msg = "Could not start the server."
INFRASTRUCTURE.proc.terminate()
stdout, stderr = INFRASTRUCTURE.proc.communicate()
msg += (
f"Could not start the server after {tries} tries with a timeout of {timeout} seconds each."
f" Server stdout:\n{stdout.decode()}\nServer stderr:\n{stderr.decode()}"
)
raise RuntimeError(msg)


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test_nav_playbook(
assert any(output in line for line in stdout)
cmd = (
f"cd {tmp_path} &&"
f" ansible-navigator run site.yml"
" ansible-navigator run site.yml"
f" --pp never --eei {infrastructure.navigator_ee}"
)
stdout = container_tmux.send_and_wait(cmd=cmd, wait_for="Successful", timeout=10)
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tox]
requires =
tox>=4.11.3
tox-extra>=2.0.1
env_list =
py
deps
Expand Down

0 comments on commit 3e265ff

Please sign in to comment.