Skip to content

Commit

Permalink
Auto update adt version output inside README
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jan 29, 2024
1 parent 58c5c06 commit 735ce4a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ The curated list of tools installed as part of the Ansible automation developer

In addition to installing each of the above tools, `ansible-dev-tools` provides an easy way to show the versions of the content creation tools that make up the current development environment.

<!-- START -->

```
$ adt --version
ansible-builder 3.0.0
ansible-core 2.16.2
ansible-creator 24.1.0
ansible-dev-environment 24.1.0
ansible-dev-tools 0.2.0a1.dev26
ansible-dev-tools 0.1a0
ansible-lint 6.22.2
ansible-navigator 3.6.0
ansible-sign 0.1.1
Expand All @@ -47,6 +49,8 @@ pytest-ansible 24.1.2
tox-ansible 2.1.0
```

<!-- END -->

## Documentation

For more information, please visit our [documentation](https://ansible.readthedocs.io/projects/dev-tools/) page.
4 changes: 2 additions & 2 deletions src/ansible_dev_tools/version_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

PKGS = [
"ansible-builder",
"ansible-dev-environment",
"ansible-dev-tools",
"ansible-core",
"ansible-creator",
"ansible-dev-environment",
"ansible-dev-tools",
"ansible-lint",
"ansible-navigator",
"ansible-sign",
Expand Down
31 changes: 31 additions & 0 deletions tools/update-readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!python3
"""Script that tests rule markdown documentation."""
from __future__ import annotations

import re
import subprocess

from pathlib import Path


if __name__ == "__main__":
result = subprocess.run(
"adt --version", # noqa: S607
shell=True, # noqa: S602
check=True,
capture_output=True,
text=True,
)

file = Path("README.md")
with file.open(encoding="utf-8", mode="r+") as fh:
content = fh.read()
content = re.sub(
"<!-- START -->(.*?)<!-- END -->",
f"<!-- START -->\n\n```\n$ adt --version\n{result.stdout}```\n\n<!-- END -->",
content,
flags=re.DOTALL,
)
fh.seek(0)
fh.write(content)
fh.truncate()
12 changes: 9 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ set_env =
commands =
coverage run --debug=trace -m pytest {posargs}
sh -c "coverage combine -q .tox/.coverage.* && coverage xml || true && coverage report"
# We fail if files are modified at the end
git diff --exit-code
allowlist_externals =
bash
git
rm
sh
Expand Down Expand Up @@ -65,18 +68,21 @@ commands =
--outdir {toxinidir}/dist/ \
{toxinidir}
sh -c "python -m twine check --strict {toxinidir}/dist/*"
pip install --target=.tox/dist '.[test,docs]'
pip install '.[test,docs]'
adt --version

[testenv:docs]
description = Builds docs
package = editable
skip_install = false
skip_install = true
extras =
docs
set_env =
NO_COLOR = 1
TERM = dump
commands =
bash -c "SETUPTOOLS_SCM_PRETEND_VERSION=$(git describe --tags --abbrev=0) pip install -q -e ."
adt --version
python3 tools/update-readme.py
mkdocs {posargs:build --strict --site-dir=_readthedocs/html/}

[testenv:deps]
Expand Down

0 comments on commit 735ce4a

Please sign in to comment.