Skip to content

Commit 82228b8

Browse files
committed
Process jobs "Downloads" and extract 'key' to env
This fixes: python-unittest-standalone by downloading and exporting GRADLE_JAVA_HOME NOTE: This only works on linux at this time, other platforms will follow WIP: Download Links depending on platform Todo: Build link using self.runs_on
1 parent a359514 commit 82228b8

File tree

3 files changed

+52
-16
lines changed

3 files changed

+52
-16
lines changed

.github/scripts/extract_matrix.py

100755100644
Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from functools import cached_property, total_ordering
1313
from typing import Any
1414

15-
1615
DEFAULT_ENV = {
1716
"CI": "true",
1817
"PYTHONIOENCODING": "utf-8"
@@ -26,11 +25,28 @@
2625
"corporate-compliance",
2726

2827
# Jobs failing in GitHub Actions:buffer overflow, out of memory, auditwheel incompatible with runner ubuntu-latest's glibc version
29-
"darwin",
3028
"python-svm-unittest",
3129
"cpython-gate",
3230
)
3331

32+
# TODO build link using self.runs_on
33+
DOWNLOADS_LINKS = {
34+
"GRADLE_JAVA_HOME": {
35+
"https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz": ["linux", "amd64"],
36+
"https://download.oracle.com/java/21/latest/jdk-21_linux-aarch64_bin.tar.gz": ["linux", "aarch64"],
37+
"https://download.oracle.com/java/21/latest/jdk-21_macos-aarch64_bin.tar.gz": ["darwin", "aarch64"],
38+
"https://download.oracle.com/java/21/latest/jdk-21_windows-x64_bin.zip": ["windows", "amd64"],
39+
}
40+
}
41+
42+
# Gitlab Runners OSS
43+
OSS = {
44+
"macos-latest": ["darwin", "aarch64"],
45+
"ubuntu-latest": ["linux", "amd64"],
46+
"ubuntu-24.04-arm": ["linux", "aarch64"],
47+
"windows-latest": ["windows", "amd64"]
48+
}
49+
3450

3551
@dataclass
3652
class Artifact:
@@ -47,13 +63,7 @@ def __init__(self, job: dict[str, Any]):
4763
def runs_on(self) -> str:
4864
capabilities = self.job.get("capabilities", [])
4965

50-
available_oss = {
51-
"macos-latest": ["darwin", "aarch64"],
52-
"ubuntu-24.04-arm": ["linux", "aarch64"],
53-
"windows-latest": ["windows", "amd64"]
54-
}
55-
56-
for os, caps in available_oss.items():
66+
for os, caps in OSS.items():
5767
if all(required in capabilities for required in caps): return os
5868

5969
return "ubuntu-latest"
@@ -111,10 +121,31 @@ def python_packages(self) -> list[str]:
111121
python_packages.append(f"'{k[4:]}{v}'" if self.runs_on != "windows-latest" else f"{k[4:]}{v}")
112122
return python_packages
113123

124+
def get_download_steps(self, key: str) -> str:
125+
download_link = self.get_download_link(key)
126+
filename = download_link.split('/')[-1]
127+
return (f"wget -q {download_link} && "
128+
f"dirname=$(tar -tzf {filename} | head -1 | cut -f1 -d '/') && "
129+
f"tar -xzf {filename} && "
130+
f'echo {key}=$(realpath "$dirname") >> $GITHUB_ENV')
131+
132+
def get_download_link(self, key) -> str:
133+
os_pair = OSS[self.runs_on]
134+
oss_links = DOWNLOADS_LINKS[key]
135+
136+
for k, v in oss_links.items():
137+
if os_pair == v: return k
138+
139+
return ""
140+
114141
@cached_property
115-
def downloads(self) -> dict[str, str] | None:
116-
# TODO
117-
return None
142+
def downloads(self) -> list[str]:
143+
downloads = []
144+
for k, v in self.job.get("downloads", {}).items():
145+
if k in DOWNLOADS_LINKS:
146+
downloads.append(self.get_download_steps(k))
147+
#print(f"[DEBUG] {k}, {downloads}")
148+
return downloads
118149

119150
@staticmethod
120151
def common_glob(strings: list[str]) -> str:
@@ -201,6 +232,7 @@ def to_dict(self):
201232
"require_artifact": [self.download_artifact.name, self.download_artifact.pattern] if self.download_artifact else None,
202233
"logs": self.logs.replace("../", "${{ env.PARENT_DIRECTORY }}/"),
203234
"env": self.env,
235+
"downloads_steps": " ".join(self.downloads),
204236
}
205237

206238
def __str__(self):
@@ -233,8 +265,8 @@ def get_tagged_jobs(buildspec, target, filter=None):
233265
continue
234266
if filter and not re.match(filter, job.name):
235267
continue
236-
if job.runs_on not in ["ubuntu-latest"]:
237-
continue
268+
#if job.runs_on not in ["ubuntu-latest"]:
269+
# continue
238270
if [x for x in JOB_EXCLUSION_TERMS if x in str(job)]:
239271
continue
240272
jobs.append(job.to_dict())

.github/workflows/ci-matrix-gen.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,15 @@ jobs:
174174
if: ${{ runner.os == 'Windows' }}
175175
uses: microsoft/setup-msbuild@v2
176176

177+
- name: Process matrix downloads
178+
if: ${{ matrix.downloads_steps }}
179+
run: |
180+
${{ matrix.downloads_steps }}
181+
177182
- name: Setup
178183
working-directory: main
179184
if: ${{ matrix.setup_steps }}
180185
run: |
181-
ls -la .github/scripts
182186
${{ matrix.setup_steps }}
183187
- name: Run on Unix
184188
working-directory: main

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
"linux:amd64:jdk-latest" : tier1,
242242
}),
243243
"python-unittest-retagger": ut_retagger + platform_spec(no_jobs) + platform_spec({
244-
"linux:amd64:jdk-latest" : weekly + t("20:00:00"),
244+
"linux:amd64:jdk-latest" : tier3,
245245
"linux:aarch64:jdk-latest" : weekly + t("20:00:00"),
246246
"darwin:aarch64:jdk-latest" : weekly + t("20:00:00"),
247247
"windows:amd64:jdk-latest" : weekly + t("20:00:00"),

0 commit comments

Comments
 (0)