Skip to content

Commit

Permalink
test: Test with the 5 most recent Docker tags
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Dec 27, 2024
1 parent 9fe8ac5 commit c599f5e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/resources/docker-tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"6-apache",
"5-apache"
]
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
- name: Test against latest tags
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Release') && !inputs.all_integrations && github.event_name != 'schedule' }}
run: |
echo '["6-apache", "5-apache"]' > limesurvey-docker-tags.json
cp ${{ github.workspace }}/.github/workflows/resources/docker-tags.json limesurvey-docker-tags.json
- name: Output tags
id: tags
Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
39 changes: 34 additions & 5 deletions scripts/docker_tags.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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


Expand Down

0 comments on commit c599f5e

Please sign in to comment.