Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

ci(compat): record the native build size in the job summary and keep the stats JSON (#3016)

Hector Venturaaa455fbba0cf
diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml
index 9c57e18bef..91ad290864 100644
--- a/.github/workflows/compatibility.yml
+++ b/.github/workflows/compatibility.yml
@@ -149,6 +149,38 @@ jobs:
- name: Build native executable (quick build)
run: mvn clean package -Dnative -DskipTests -B -Dquarkus.native.additional-build-args-append="-Ob"
+ # Quarkus always writes GraalVM's build-output JSON next to the native source jar. Surfacing
+ # it here gives every PR a size record for both architectures: code area, image heap, total
+ # image size and reachable type/method counts, plus the gzip size of the binary, which tracks
+ # the compressed layer Docker Hub will report. No extra build flags, a few seconds.
+ - name: Record native build size
+ run: |
+ python3 - "$GITHUB_STEP_SUMMARY" "${{ matrix.arch }}" <<'PY'
+ import glob, json, subprocess, sys
+ summary, arch = sys.argv[1], sys.argv[2]
+ stats = json.load(open(glob.glob("target/*-native-image-source-jar/*-build-output-stats.json")[0]))
+ d, a = stats["image_details"], stats["analysis_results"]
+ runner = glob.glob("target/*-runner")[0]
+ gz = int(subprocess.run(f"gzip -c '{runner}' | wc -c", shell=True, capture_output=True, text=True).stdout)
+ mib = lambda b: f"{b / 2**20:.1f} MiB"
+ rows = [("total image", mib(d["total_bytes"])), ("code area", mib(d["code_area"]["bytes"])),
+ ("image heap", mib(d["image_heap"]["bytes"])),
+ ("resources in heap", f"{mib(d['image_heap']['resources']['bytes'])} ({d['image_heap']['resources']['count']} files)"),
+ ("binary gzip (Hub layer estimate)", f"{gz / 1e6:.2f} MB"),
+ ("reachable types / methods", f"{a['types']['reachable']} / {a['methods']['reachable']}")]
+ with open(summary, "a") as f:
+ f.write(f"### Native build size ({arch}, quick build)\n\n| metric | value |\n|---|---|\n")
+ f.writelines(f"| {k} | {v} |\n" for k, v in rows)
+ print("\n".join(f"{k}: {v}" for k, v in rows))
+ PY
+
+ - name: Upload native build stats
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: native-build-stats-${{ matrix.arch }}
+ path: target/*-native-image-source-jar/*-build-output-stats.json
+ retention-days: 30
+
- name: Stage native binary for packaging
run: |
mkdir -p native/${{ matrix.arch }}