From be4c7259aab72981813aac2cce6bf33bace77b65 Mon Sep 17 00:00:00 2001 From: Lyle McKarns Date: Tue, 23 Jul 2024 16:15:34 -0400 Subject: [PATCH] Issue #1633 nox session for tagging (#1649) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * WIP tagger session for nox * First pass tagging nox session * Formatting fixup * Adding removal of tmpdir as per discussion * tag session checks for, and uses, existing ansible checkout if it exists, removes tmpdir if it created one. * isort fixup * Working out suggested changes. * Linting cleanup on changes * Different approach to noted chagnes * Reducing tagging session to a bare bones wrapper around the script, leaving all repo management alone * Staging deletion per discussion * Adding tag session to dependency update job * after removing hacking/tagger/requirements.txt moved "gitpython" here for the typing test session requiremnts. * Adding that here didd not accomplish what I'd expected. Removing it and revisiting how to do that. * I think this is where the call needed added to get the tags dependencies automatically updated * remove gitpython, add tag.txt, add blank line * Comment cleanup per OraNod * doc README: document nox tag session instead of manual mode * Update tests/typing.in Per suggestion from @webnjaz Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) --------- Co-authored-by: Maxwell G Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) --- .github/workflows/pip-compile-dev.yml | 1 + README.md | 20 ++++--------- noxfile.py | 15 ++++++++++ .../tagger/requirements.txt => tests/tag.in | 0 tests/tag.txt | 30 +++++++++++++++++++ tests/typing.in | 2 +- 6 files changed, 53 insertions(+), 15 deletions(-) rename hacking/tagger/requirements.txt => tests/tag.in (100%) create mode 100644 tests/tag.txt diff --git a/.github/workflows/pip-compile-dev.yml b/.github/workflows/pip-compile-dev.yml index c648cd9dcf9..89ae8e77184 100644 --- a/.github/workflows/pip-compile-dev.yml +++ b/.github/workflows/pip-compile-dev.yml @@ -39,6 +39,7 @@ jobs: 'pip-compile-3.10(typing)' 'pip-compile-3.10(static)' 'pip-compile-3.10(spelling)' + 'pip-compile-3.10(tag)' reset-branch: "${{ inputs.reset-branch || false }}" labels: "${{ inputs.labels || 'backport-2.14,backport-2.15,backport-2.16,backport-2.17,tooling' }}" secrets: inherit diff --git a/README.md b/README.md index 2c729580b0d..9ec6cd5a5be 100644 --- a/README.md +++ b/README.md @@ -141,30 +141,22 @@ podman run --rm --tty --volume "$(pwd):/mnt:z" --workdir /mnt docker.io/library/ When a tag is created in the [`ansible/ansible`](https://github.com/ansible/ansible) repository for a release or release candidate, a corresponding tag should be created in this `ansible-documentation` repository. -First, install the additional tagging dependencies from this repository as follows, creating or activating a `venv` as needed: - -``` bash -python3 -m venv ./venv -source ./venv/bin/activate -pip install -r hacking/tagger/requirements.txt -``` - -Next, ensure that you have the [`ansible/ansible`](https://github.com/ansible/ansible) and [`ansible/ansible-documentation`](https://github.com/ansible/ansible-documentation) repositories checked out. +First, ensure that you have the [`ansible/ansible`](https://github.com/ansible/ansible) and [`ansible/ansible-documentation`](https://github.com/ansible/ansible-documentation) repositories checked out. The tool assumes that both checkouts have the same parent directory. You can set different paths to your checkouts with the `--docs` and `--core` options if you have them set up another way. -Lastly, run the tagger script. +Next, run the `tag` `nox` session. This will determine any missing `ansible-core` tags and create them in `ansible-documentation` if needed, exiting normally otherwise: ``` bash # The tagger scripts assumes "origin" as the upstream remote. -./hacking/tagger/tag.py tag +nox -s tag # If you use a different upstream remote, specify the name. -./hacking/tagger/tag.py --remote tag +nox -s tag -- --remote tag # If your core repo is not in the same filesystem location, specify the path. -./hacking/tagger/tag.py --core tag +nox -s tag -- --core tag ``` -See `--help` for extended options. +See `nox -s tag -- --help` for extended options. diff --git a/noxfile.py b/noxfile.py index fbb0beb757d..e685f9349e7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -180,3 +180,18 @@ def make(session: nox.Session): *(args.make_args or ("clean", "coredocs")), ] session.run("make", "-C", "docs/docsite", *make_args, external=True) + + +@nox.session +def tag(session: nox.Session): + """ + Check the core repo for new releases and create tags in ansible-documentation + """ + install(session, req="tag") + args = list(session.posargs) + + # If run without any arguments, default to "tag" + if not any(arg.startswith(("hash", "mantag", "new-tags", "tag")) for arg in args): + args.append("tag") + + session.run("python", "hacking/tagger/tag.py", *args) diff --git a/hacking/tagger/requirements.txt b/tests/tag.in similarity index 100% rename from hacking/tagger/requirements.txt rename to tests/tag.in diff --git a/tests/tag.txt b/tests/tag.txt new file mode 100644 index 00000000000..faa6f01587c --- /dev/null +++ b/tests/tag.txt @@ -0,0 +1,30 @@ +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile --allow-unsafe --output-file=tests/tag.txt --strip-extras tests/tag.in +# +click==8.1.7 + # via typer +gitdb==4.0.11 + # via gitpython +gitpython==3.1.43 + # via -r tests/tag.in +markdown-it-py==3.0.0 + # via rich +mdurl==0.1.2 + # via markdown-it-py +packaging==24.1 + # via -r tests/tag.in +pygments==2.18.0 + # via rich +rich==13.7.1 + # via typer +shellingham==1.5.4 + # via typer +smmap==5.0.1 + # via gitdb +typer==0.12.3 + # via -r tests/tag.in +typing-extensions==4.12.2 + # via typer diff --git a/tests/typing.in b/tests/typing.in index 5eaee63794a..9701e2c5780 100644 --- a/tests/typing.in +++ b/tests/typing.in @@ -1,4 +1,4 @@ -r ../hacking/pr_labeler/requirements.txt --r ../hacking/tagger/requirements.txt +-r tag.in mypy nox