Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
[ci][docker] Use RFC image tags only (apache#11938)
Browse files Browse the repository at this point in the history
This ignores image names like `123-123-abc-validated`

Co-authored-by: driazati <[email protected]>
  • Loading branch information
2 people authored and xinetzone committed Nov 25, 2022
1 parent 22d20d6 commit 5318c7e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tests/python/ci/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,15 +834,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 @@ -852,45 +852,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

0 comments on commit 5318c7e

Please sign in to comment.