diff --git a/docs/index.md b/docs/index.md index 63784297..8d6ae067 100644 --- a/docs/index.md +++ b/docs/index.md @@ -25,9 +25,13 @@ Integration tests are run against a LimeSurvey instance, and both PostgreSQL and - {ls_tag}`6.8.2+241203` - {ls_tag}`6.8.1+241120` - {ls_tag}`6.8.0+241119` +- {ls_tag}`6.6.7+241028` +- {ls_tag}`6.6.6+241002` - {ls_tag}`5.6.68+240625` - {ls_tag}`5.6.67+240612` - {ls_tag}`5.6.66+240604` +- {ls_tag}`5.6.65+240522` +- {ls_tag}`5.6.63+240508` But also, the latest 5.x and 6.x are tested continuously and are expected to work. diff --git a/noxfile.py b/noxfile.py index c6955c67..644df85b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -207,4 +207,4 @@ def notebook(session: nox.Session) -> None: def tags(session: nox.Session) -> None: """Print tags.""" session.install("requests", "requests-cache") - session.run("python", "scripts/docker_tags.py") + session.run("python", "scripts/docker_tags.py", "--max-tags", "5") diff --git a/scripts/docker_tags.py b/scripts/docker_tags.py index 4a2a8d32..81f56f26 100644 --- a/scripts/docker_tags.py +++ b/scripts/docker_tags.py @@ -1,7 +1,13 @@ -"""Get all tags from the Docker Hub.""" # noqa: INP001 +# /// script +# dependencies = ["requests", "requests-cache"] +# requires-python = ">=3.9" +# /// + +"""Get all tags from the Docker Hub.""" from __future__ import annotations +import argparse import json import re import typing as t @@ -63,11 +69,16 @@ def sort_tags(tags: t.Iterable[dict]) -> list[dict]: return sorted(tags, key=_extract_version, reverse=True) -def filter_tags(tags: t.Iterable[dict]) -> t.Generator[str, None, None]: +def filter_tags( + tags: t.Iterable[dict], + *, + max_tags: int = 3, +) -> t.Generator[str, None, None]: """Filter tags. Args: tags: An iterable of tags. + max_tags: Maximum number of tags to yield. Yields: Tag names. @@ -76,19 +87,37 @@ def filter_tags(tags: t.Iterable[dict]) -> t.Generator[str, None, None]: count_6 = 0 for tag in tags: name = tag["name"] + if name in {"6-apache", "5-apache"}: yield name - if re.match(PATTERN_5x, name) and count_5 < 3: # noqa: PLR2004 + + if re.match(PATTERN_5x, name) and count_5 < max_tags: yield name count_5 += 1 - if re.match(PATTERN_6x, name) and count_6 < 3: # noqa: PLR2004 + + if re.match(PATTERN_6x, name) and count_6 < max_tags: yield name count_6 += 1 def main() -> None: """Print tags.""" - tags = filter_tags(sort_tags(get_tags())) + + class ParserNamespace(argparse.Namespace): + """Namespace for CLI arguments.""" + + max_tags: int + + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--max-tags", + type=int, + default=3, + help="Maximum tags to present for each version.", + ) + args = parser.parse_args(namespace=ParserNamespace) + + tags = filter_tags(sort_tags(get_tags()), max_tags=args.max_tags) print(json.dumps(list(tags))) # noqa: T201