Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions tests/python/ci/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,15 +832,15 @@ def run(source_type, data, check):
"results": [
{
"last_updated": "2022-06-01T00:00:00.123456Z",
"name": "abc-abc-123",
"name": "123-123-abc",
},
]
},
tlcpack_body={
"results": [
{
"last_updated": "2022-06-01T00:00:00.123456Z",
"name": "abc-abc-123",
"name": "123-123-abc",
},
]
},
Expand All @@ -850,45 +850,49 @@ def run(source_type, data, check):
dict(
tlcpackstaging_body={
"results": [
{
"last_updated": "2022-06-01T01:00:00.123456Z",
"name": "234-234-abc-staging",
},
{
"last_updated": "2022-06-01T00:00:00.123456Z",
"name": "abc-abc-234-staging",
"name": "456-456-abc",
},
]
},
tlcpack_body={
"results": [
{
"last_updated": "2022-06-01T00:00:00.123456Z",
"name": "abc-abc-123",
"name": "123-123-abc",
},
]
},
expected="Using tlcpackstaging tag on tlcpack",
expected_images=[
"ci_arm = 'tlcpack/ci-arm:abc-abc-234-staging'",
"ci_arm = 'tlcpack/ci-arm:456-456-abc'",
],
),
dict(
tlcpackstaging_body={
"results": [
{
"last_updated": "2022-06-01T00:00:00.123456Z",
"name": "abc-abc-123",
"name": "123-123-abc",
},
]
},
tlcpack_body={
"results": [
{
"last_updated": "2022-06-01T00:01:00.123456Z",
"name": "abc-abc-234",
"name": "234-234-abc",
},
]
},
expected="Found newer image, using: tlcpack",
expected_images=[
"ci_arm = 'tlcpack/ci-arm:abc-abc-234'",
"ci_arm = 'tlcpack/ci-arm:234-234-abc'",
],
),
)
Expand Down
6 changes: 6 additions & 0 deletions tests/scripts/open_docker_update_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import datetime
import os
import json
import re
from urllib import error
from typing import List, Dict, Any, Optional, Callable
from git_utils import git, parse_remote, GitHubRepo
Expand Down Expand Up @@ -52,6 +53,10 @@ def parse_docker_date(d: str) -> datetime.datetime:
return datetime.datetime.strptime(d, "%Y-%m-%dT%H:%M:%S.%fZ")


def check_tag(tag: Dict[str, Any]) -> bool:
return re.match(r"^[0-9]+-[0-9]+-[a-z0-9]+$", tag["name"]) is not None


def latest_tag(user: str, repo: str) -> List[Dict[str, Any]]:
"""
Queries Docker Hub and finds the most recent tag for the specified image/repo pair
Expand All @@ -63,6 +68,7 @@ def latest_tag(user: str, repo: str) -> List[Dict[str, Any]]:
result["last_updated"] = parse_docker_date(result["last_updated"])

results = list(sorted(results, key=lambda d: d["last_updated"]))
results = [tag for tag in results if check_tag(tag)]
return results[-1]


Expand Down