-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathused-tasks-tags
More file actions
executable file
·49 lines (37 loc) · 1.48 KB
/
used-tasks-tags
File metadata and controls
executable file
·49 lines (37 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python3
# SPDX-License-Identifier: LGPL-2.1-or-later
# Determine all tasks container tags that are used in our projects.
# Used for cleaning up obsolete tasks tags.
import asyncio
import re
import sys
from lib import testmap
from lib.aio.base import SubjectSpecification
from lib.aio.jobcontext import JobContext
async def main() -> None:
used_tags = set()
async with JobContext(None) as ctx:
for repo, branches in testmap.REPO_BRANCH_CONTEXT.items():
forge: str | None
if ":" in repo:
forge, _, repo = repo.partition(":")
else:
forge = None
for branch in branches:
if branch.startswith("_"):
continue
subject = await ctx.resolve_subject(
SubjectSpecification({"forge": forge, "repo": repo, "branch": branch})
)
content = await subject.read_file(".cockpit-ci/container")
if content is None:
print(f"Note: {repo}/{branch} has no .cockpit-ci/container", file=sys.stderr)
continue
m = re.match(r"ghcr\.io/([^/]+)/([^:]+):([\w\-\.]+)", content.strip())
if m:
tag = m.group(3)
print(f"Note: {repo}/{branch} uses tag {tag}", file=sys.stderr)
used_tags.add(tag)
print(",".join(sorted(used_tags)))
if __name__ == '__main__':
asyncio.run(main())