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

Commit 5318c7e

Browse files
driazatixinetzone
authored andcommitted
[ci][docker] Use RFC image tags only (apache#11938)
This ignores image names like `123-123-abc-validated` Co-authored-by: driazati <driazati@users.noreply.github.com>
1 parent 22d20d6 commit 5318c7e

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

tests/python/ci/test_ci.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -834,15 +834,15 @@ def run(source_type, data, check):
834834
"results": [
835835
{
836836
"last_updated": "2022-06-01T00:00:00.123456Z",
837-
"name": "abc-abc-123",
837+
"name": "123-123-abc",
838838
},
839839
]
840840
},
841841
tlcpack_body={
842842
"results": [
843843
{
844844
"last_updated": "2022-06-01T00:00:00.123456Z",
845-
"name": "abc-abc-123",
845+
"name": "123-123-abc",
846846
},
847847
]
848848
},
@@ -852,45 +852,49 @@ def run(source_type, data, check):
852852
dict(
853853
tlcpackstaging_body={
854854
"results": [
855+
{
856+
"last_updated": "2022-06-01T01:00:00.123456Z",
857+
"name": "234-234-abc-staging",
858+
},
855859
{
856860
"last_updated": "2022-06-01T00:00:00.123456Z",
857-
"name": "abc-abc-234-staging",
861+
"name": "456-456-abc",
858862
},
859863
]
860864
},
861865
tlcpack_body={
862866
"results": [
863867
{
864868
"last_updated": "2022-06-01T00:00:00.123456Z",
865-
"name": "abc-abc-123",
869+
"name": "123-123-abc",
866870
},
867871
]
868872
},
869873
expected="Using tlcpackstaging tag on tlcpack",
870874
expected_images=[
871-
"ci_arm = 'tlcpack/ci-arm:abc-abc-234-staging'",
875+
"ci_arm = 'tlcpack/ci-arm:456-456-abc'",
872876
],
873877
),
874878
dict(
875879
tlcpackstaging_body={
876880
"results": [
877881
{
878882
"last_updated": "2022-06-01T00:00:00.123456Z",
879-
"name": "abc-abc-123",
883+
"name": "123-123-abc",
880884
},
881885
]
882886
},
883887
tlcpack_body={
884888
"results": [
885889
{
886890
"last_updated": "2022-06-01T00:01:00.123456Z",
887-
"name": "abc-abc-234",
891+
"name": "234-234-abc",
888892
},
889893
]
890894
},
891895
expected="Found newer image, using: tlcpack",
892896
expected_images=[
893-
"ci_arm = 'tlcpack/ci-arm:abc-abc-234'",
897+
"ci_arm = 'tlcpack/ci-arm:234-234-abc'",
894898
],
895899
),
896900
)

tests/scripts/open_docker_update_pr.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import datetime
2323
import os
2424
import json
25+
import re
2526
from urllib import error
2627
from typing import List, Dict, Any, Optional, Callable
2728
from git_utils import git, parse_remote, GitHubRepo
@@ -52,6 +53,10 @@ def parse_docker_date(d: str) -> datetime.datetime:
5253
return datetime.datetime.strptime(d, "%Y-%m-%dT%H:%M:%S.%fZ")
5354

5455

56+
def check_tag(tag: Dict[str, Any]) -> bool:
57+
return re.match(r"^[0-9]+-[0-9]+-[a-z0-9]+$", tag["name"]) is not None
58+
59+
5560
def latest_tag(user: str, repo: str) -> List[Dict[str, Any]]:
5661
"""
5762
Queries Docker Hub and finds the most recent tag for the specified image/repo pair
@@ -63,6 +68,7 @@ def latest_tag(user: str, repo: str) -> List[Dict[str, Any]]:
6368
result["last_updated"] = parse_docker_date(result["last_updated"])
6469

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

6874

0 commit comments

Comments
 (0)