Skip to content

Commit f73bcb6

Browse files
committed
[GR-71651] Adopt labsjdk-builder changes for delayed PR comment.
PullRequest: labsjdk-ce/248
2 parents fbf4153 + 79973c8 commit f73bcb6

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

.ci/common.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626

2727
# Version of the labsjdk-builder scripts to use
28-
labsjdk_builder_version:: 'ec2b508e842f96673cdfe3f60535b9e588885f0a',
28+
labsjdk_builder_version:: 'ffbb806c0031d473184dcece976cf4dd9e94901a',
2929

3030
# Clones a JDK repository
3131
# If `!is_closed`, then the cloned repo is checked out to branch ${MAIN_REVISION}.

.ci/update_labsjdk_in_common_json.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,10 @@
4040
parser = argparse.ArgumentParser(description="Updates jdks.labsjdk-ce-latest.version and jdks.labsjdk-ee-latest.version values in common.json.")
4141
parser.add_argument("labsjdk_versions", action="store", help="URL or path to file from which labsjdk versions will be read. " \
4242
"The content must be a JSON object with ce and ee fields that specify the new values.")
43-
parser.add_argument("common_json", action="store", help="common.json file to process")
43+
parser.add_argument("common.json", action="store", nargs="+", help="path to a common.json file to process")
4444

4545
args = parser.parse_args()
4646

47-
common_json_path = Path(args.common_json)
48-
common_json_text = common_json_path.read_text()
49-
common_json = json.loads(common_json_text)
50-
ce_version = common_json["jdks"]["labsjdk-ce-latest"]["version"]
51-
ee_version = common_json["jdks"]["labsjdk-ee-latest"]["version"]
52-
5347
if args.labsjdk_versions.startswith("http://") or args.labsjdk_versions.startswith("https://"):
5448
from urllib import request
5549
url = args.labsjdk_versions
@@ -70,22 +64,29 @@
7064
new_versions = new_versions[0:1024] + "... (truncated)"
7165
raise SystemExit(f"Error decoding content of size {size} from {args.labsjdk_versions} as JSON: {e}\nContent:\n{new_versions}")
7266

73-
try:
74-
new_common_json_text = common_json_text\
75-
.replace(ce_version, new_versions["ce"])\
76-
.replace(ee_version, new_versions["ee"])
77-
except KeyError as e:
78-
raise SystemExit(f"Error extracting versions from JSON in {args.labsjdk_versions}: Missing value for {e}\nJSON:\n{json.dumps(new_versions, indent=2)}")
79-
80-
if new_common_json_text == common_json_text:
81-
print(f"No change to {common_json_path}")
82-
else:
83-
patch = "\n".join((line for line in difflib.unified_diff(
84-
common_json_text.split("\n"),
85-
new_common_json_text.split("\n"),
86-
fromfile=f"a/{common_json_path.name}",
87-
tofile=f"b/{common_json_path.name}",
88-
lineterm=""
89-
)))
90-
print(f"Updated {common_json_path} with this patch:\n{patch}")
91-
common_json_path.write_text(new_common_json_text)
67+
for common_json_path in getattr(args, "common.json"):
68+
common_json_path = Path(common_json_path)
69+
common_json_text = common_json_path.read_text()
70+
common_json = json.loads(common_json_text)
71+
ce_version = common_json["jdks"]["labsjdk-ce-latest"]["version"]
72+
ee_version = common_json["jdks"]["labsjdk-ee-latest"]["version"]
73+
74+
try:
75+
new_common_json_text = common_json_text\
76+
.replace(ce_version, new_versions["ce"])\
77+
.replace(ee_version, new_versions["ee"])
78+
except KeyError as e:
79+
raise SystemExit(f"Error extracting versions from JSON in {args.labsjdk_versions}: Missing value for {e}\nJSON:\n{json.dumps(new_versions, indent=2)}")
80+
81+
if new_common_json_text == common_json_text:
82+
print(f"No change to {common_json_path}")
83+
else:
84+
patch = "\n".join((line for line in difflib.unified_diff(
85+
common_json_text.split("\n"),
86+
new_common_json_text.split("\n"),
87+
fromfile=f"a/{common_json_path.name}",
88+
tofile=f"b/{common_json_path.name}",
89+
lineterm=""
90+
)))
91+
print(f"Updated {common_json_path} with this patch:\n{patch}")
92+
common_json_path.write_text(new_common_json_text)

0 commit comments

Comments
 (0)