Skip to content

Commit 63f6733

Browse files
authored
KON-604 Update Artifact Verification (#901)
* Rename script and fail when no files * Simplify script * Upd name
1 parent 028722e commit 63f6733

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

.github/workflows/check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ jobs:
249249
run: python3 scripts/check_dependencies_exposed_by_library_artifact.py
250250

251251
- name: Check Bytecode version
252-
run: python3 scripts/check_bytecode_version.py
252+
run: python3 scripts/check_konsist_artifact_bytecode_version.py
253253

254254
# ======================================= Other =========================================================
255255

scripts/check_bytecode_version.py scripts/check_konsist_artifact_bytecode_version.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,21 @@
1616

1717
def get_bytecode_version(class_file):
1818
result = subprocess.run(["javap", "-verbose", class_file], capture_output=True, text=True)
19+
1920
for line in result.stdout.splitlines():
2021
if "major version" in line:
2122
return line.split(":")[-1].strip()
2223

2324

24-
def main():
25+
def check_artifact_bytecode(desired_java_version, desired_bytecode_version):
2526
jar_path = get_artifact_path("jar")
26-
# Java 8 == bytecode version 52.0 (defined in the local.javalibrary.gradle.kts)
27-
# https://javaalmanac.io/bytecode/versions/
28-
desired_java_version = "8"
29-
desired_bytecode_version = "52"
3027

31-
print(
32-
f"Verify if the first class in {jar_path} is compiled to bytecode {desired_bytecode_version} (Java {desired_java_version})")
28+
print( f"Verify if the first class in {jar_path} is compiled to bytecode {desired_bytecode_version} (Java {desired_java_version})" )
3329

3430
checked = False # Variable to track if we've already checked a .class file
3531

3632
try:
37-
# Unzip the jar file to the temporary directory
33+
# Unzip the get_artifact_path jar file to the temporary directory
3834
subprocess.run(["unzip", "-qq", jar_path, "-d", build_dir], check=True)
3935

4036
# Walk the directory to find all .class files
@@ -55,12 +51,14 @@ def main():
5551
if checked:
5652
print(f"SUCCESS: First class has correct bytecode version: {desired_bytecode_version}")
5753
else:
58-
print("WARNING: No .class file found to check.")
54+
print("ERROR: No .class file found to check the artifact.")
55+
sys.exit(1)
5956

6057
finally:
6158
# Clean up the temporary directory
6259
shutil.rmtree(build_dir)
6360

6461

65-
if __name__ == "__main__":
66-
main()
62+
# Java 8 == bytecode version 52.0 (defined in the local.javalibrary.gradle.kts)
63+
# https://javaalmanac.io/bytecode/versions/
64+
check_artifact_bytecode("8", "52")

0 commit comments

Comments
 (0)