Skip to content

Commit

Permalink
Test maintenance
Browse files Browse the repository at this point in the history
- ensure uv uses same constraints as pip
- update deps
- fixed linting issues
- remove black
  • Loading branch information
ssbarnea committed Jan 29, 2025
1 parent 0377e05 commit ea4b6b6
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 95 deletions.
56 changes: 32 additions & 24 deletions .config/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --all-extras --no-annotate --output-file=.config/constraints.txt --strip-extras .config/requirements.in pyproject.toml
#
# This file was autogenerated by uv via the following command:
# tox run -e deps
ansible-compat==25.1.1
ansible-lint==25.1.1
argcomplete==3.5.3
astroid==3.3.8
attrs==25.1.0
babel==2.16.0
beautifulsoup4==4.12.3
black==24.10.0
build==1.2.2.post1
black==25.1.0
bracex==2.5.post1
cachetools==5.5.1
cairocffi==1.7.1
cairosvg==2.7.1
Expand All @@ -20,26 +20,29 @@ charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
coverage==7.6.10
cryptography==44.0.0
csscompressor==0.9.5
cssselect2==0.7.0
defusedxml==0.7.1
dill==0.3.9
distlib==0.3.9
dnspython==2.7.0
docstring-parser-fork==0.0.12
exceptiongroup==1.2.2
execnet==2.1.1
filelock==3.17.0
flake8==7.1.1
ghp-import==2.1.0
griffe==1.5.5
hjson==3.1.0
htmlmin2==0.1.13
identify==2.6.6
idna==3.10
importlib-metadata==8.6.1
iniconfig==2.0.0
isort==5.13.2
isort==6.0.0
jinja2==3.1.5
jsmin==3.0.1
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
linkchecker==10.5.0
markdown==3.7
markdown-exec==1.10.0
Expand Down Expand Up @@ -67,46 +70,51 @@ packaging==24.2
paginate==0.5.7
pathspec==0.12.1
pillow==11.1.0
pip-tools==7.4.1
pipdeptree==2.24.0
platformdirs==4.3.6
pluggy==1.5.0
pre-commit==4.1.0
pycodestyle==2.12.1
pycparser==2.22
pydoclint==0.6.0
pyflakes==3.2.0
pygments==2.19.1
pylint==3.3.3
pymdown-extensions==10.14.1
pylint==3.3.4
pymdown-extensions==10.14.2
pyproject-api==1.9.0
pyproject-hooks==1.2.0
pytest==8.3.4
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
python-slugify==8.0.4
pyyaml==6.0.2
pyyaml-env-tag==0.1
referencing==0.36.2
regex==2024.11.6
requests==2.32.3
rpds-py==0.22.3
ruamel-yaml==0.18.10
ruff==0.9.3
six==1.17.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
toml-sort==0.24.2
tomli==2.2.1
tomlkit==0.13.2
tox==4.24.1
types-pyyaml==6.0.12.20241230
typing-extensions==4.12.2
urllib3==2.3.0
virtualenv==20.29.1
watchdog==6.0.0
wcmatch==10.0
webencodings==0.5.1
wheel==0.45.1
yamllint==1.35.1
zipp==3.21.0

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
# The following packages were excluded from the output:
# ansible-core
# exceptiongroup
# resolvelib
# ruamel-yaml-clib
# tomli
# typing-extensions
# uv
1 change: 0 additions & 1 deletion .config/requirements-docs.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
mkdocs-ansible>=24.3.0
pipdeptree>=2.7.1
5 changes: 2 additions & 3 deletions .config/requirements-test.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
argcomplete
ansible-lint
black
argcomplete
coverage[toml]
mypy
pip-tools
pre-commit
pydoclint
pylint
Expand All @@ -13,3 +11,4 @@ ruff
toml-sort
tox
types-PyYAML
uv
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ cython_debug/

.DS_Store
node_modules
_readthedocs
73 changes: 40 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ ci:
autoupdate_commit_msg: "chore: pre-commit autoupdate"
autoupdate_schedule: monthly
autofix_commit_msg: "chore: auto fixes from pre-commit.com hooks"
skip:
# https://github.com/pre-commit-ci/issues/issues/55
- ccv
- lock
# No docker on pre-commit.ci

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -17,13 +22,6 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/add-trailing-comma.git
rev: v3.1.0
hooks:
- id: add-trailing-comma
args:
- --py36-plus

- repo: https://github.com/Lucas-C/pre-commit-hooks.git
rev: v1.5.5
hooks:
Expand All @@ -33,7 +31,7 @@ repos:
.config/pydoclint-baseline.txt
)$
- repo: https://github.com/pycontribs/mirrors-prettier
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
Expand All @@ -49,12 +47,12 @@ repos:
- id: toml-sort-fix

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

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.3
hooks:
- id: ruff
args:
Expand All @@ -64,27 +62,22 @@ repos:
- id: ruff-format # must be after ruff
types_or: [python, pyi]

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

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.17.0
rev: v8.17.1
hooks:
- id: cspell
name: Spell check with cspell

- repo: https://github.com/jsh9/pydoclint
rev: "0.5.14"
rev: "0.6.0"
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.3.3
rev: v3.3.4
hooks:
- id: pylint
args:
Expand All @@ -106,19 +99,33 @@ repos:
# Override default pre-commit '--ignore-missing-imports'
args: [--strict]

- repo: https://github.com/jazzband/pip-tools
rev: 7.4.1
# Keep last due to being considerably slower than the others:
- repo: local
hooks:
- id: deps
# To run it execute: `pre-commit run pip-compile-upgrade --hook-stage manual`
name: Upgrade constraints files and requirements
files: ^(pyproject\.toml|\.config/.*)$
always_run: true
language: python
language_version: "3.10" # minimal we support officially https://github.com/astral-sh/uv/issues/3883
entry: python3 -m uv pip compile -q --no-annotate --all-extras --universal pyproject.toml --upgrade | sed ':a;$ { /^#/d; N; ba }' >.config/constraints.txt
pass_filenames: false
stages:
- manual
additional_dependencies:
- uv>=0.5.25
- id: lock
name: Check constraints files and requirements
files: ^(pyproject\.toml|\.config/.*)$
language: python
language_version: "3.10" # minimal we support officially https://github.com/astral-sh/uv/issues/3883
entry: python3 -m uv pip compile -q --no-annotate --all-extras --universal --output-file=.config/constraints.txt pyproject.toml
pass_filenames: false
additional_dependencies:
- uv>=0.5.25
- repo: https://github.com/mashi/codecov-validator
rev: "1.0.1"
hooks:
- id: pip-compile
name: deps
alias: deps
stages: [manual]
entry: >-
pip-compile .config/requirements.in
--upgrade
--all-extras
--no-annotate
--strip-extras
--output-file=.config/constraints.txt pyproject.toml
files: ^.config\/.*requirements.*$
language_version: "3.10" # minimal we support officially
- id: ccv
name: codecov
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build:
python: "3.11"
commands:
- pip install --user tox
- python3 -m tox -e docs -- --strict --site-dir=_readthedocs/html/
- python3 -m tox -e docs
python:
install:
- method: pip
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"esbenp.prettier-vscode",
"gruntfuggly.triggertaskonsave",
"markis.code-coverage",
"ms-python.black-formatter",
"ms-python.debugpy",
"ms-python.mypy-type-checker",
"ms-python.pylint",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
},
"flake8.importStrategy": "fromEnvironment",
Expand Down
19 changes: 15 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ documentation = "https://ansible.readthedocs.io/projects/creator/"
homepage = "https://github.com/ansible/ansible-creator"
repository = "https://github.com/ansible/ansible-creator"

[tool.black]
exclude = "tests/fixtures"
line-length = 100

[tool.coverage.report]
exclude_also = ["if TYPE_CHECKING:", "pragma: no cover"]
fail_under = 93
Expand Down Expand Up @@ -383,9 +379,24 @@ git_describe_command = [
"v*.*"
]
local_scheme = "no-local-version"
tag_regex = "^(?P<prefix>v)?(?P<version>\\d+[^\\+]*)(?P<suffix>.*)?$"
write_to = "src/ansible_creator/_version.py"

[tool.tomlsort]
in_place = true
sort_inline_tables = true
sort_table_keys = true

[tool.uv.pip]
annotation-style = "line"
custom-compile-command = "tox run -e deps"
no-emit-package = [
"ansible-core",
"exceptiongroup",
"pip",
"resolvelib",
"ruamel-yaml-clib",
"tomli",
"typing_extensions",
"uv"
]
1 change: 1 addition & 0 deletions src/ansible_creator/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa: A005
"""A home for shared types."""

from __future__ import annotations
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_run_init_no_input(cli: CliRunCallable) -> None:

@pytest.mark.parametrize(
argnames="command",
argvalues=["init --project ansible-project", "init --init-path /tmp"],
argvalues=("init --project ansible-project", "init --init-path /tmp"),
ids=["project_no_scm", "collection_no_name"],
)
def test_run_deprecated_failure(command: str, cli: CliRunCallable) -> None:
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_run_init_basic(cli: CliRunCallable, tmp_path: Path) -> None:
assert result.returncode == 0

# check stdout
assert re.search("Note: collection project created at", result.stdout) is not None
assert re.search(r"Note: collection project created at", result.stdout) is not None

# fail to override existing collection with force=false (default)
result = cli(
Expand All @@ -130,7 +130,7 @@ def test_run_init_basic(cli: CliRunCallable, tmp_path: Path) -> None:
# override existing collection with force=true
result = cli(f"{CREATOR_BIN} init testorg.testcol --init-path {tmp_path} --force")
assert result.returncode == 0
assert re.search("Warning: re-initializing existing directory", result.stdout) is not None
assert re.search(r"Warning: re-initializing existing directory", result.stdout) is not None

# override existing collection with override=true
result = cli(f"{CREATOR_BIN} init testorg.testcol --init-path {tmp_path} --overwrite")
Expand All @@ -140,4 +140,4 @@ def test_run_init_basic(cli: CliRunCallable, tmp_path: Path) -> None:
# use no-override=true
result = cli(f"{CREATOR_BIN} init testorg.testcol --init-path {tmp_path} --no-overwrite")
assert result.returncode != 0
assert re.search("The flag `--no-overwrite` restricts overwriting.", result.stderr) is not None
assert re.search(r"The flag `--no-overwrite` restricts overwriting.", result.stderr) is not None
Loading

0 comments on commit ea4b6b6

Please sign in to comment.