Skip to content

Commit 47b0fe7

Browse files
authored
Merge pull request #305 from vizzuhq/size
Check lib size in CI
2 parents 6e6e1f0 + f677ca0 commit 47b0fe7

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

ci/cloudbuild/vizzu-devenv-prebuild-docker.yaml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,40 @@ steps:
5656
waitFor:
5757
- wasm_cmake
5858
timeout: 1800s
59+
- name: gcr.io/cloud-builders/gsutil
60+
args:
61+
- cp
62+
- 'gs://vizzu-lib-main/lib/size.txt'
63+
- '/workspace/build/cmake-wasm/weblib/size_downloaded.txt'
64+
id: download_size
65+
waitFor:
66+
- wasm_make
67+
- name: vizzu/vizzu-devenv:v0.8.x
68+
args:
69+
- python3
70+
- '-c'
71+
- |
72+
threshold = 1.05
73+
with open('/workspace/build/cmake-wasm/weblib/size.txt', 'r') as size_file:
74+
for line in size_file:
75+
file, actual_size = line.strip().split()
76+
downloaded_line = next(
77+
(d_line for d_line in open('/workspace/build/cmake-wasm/weblib/size_downloaded.txt', 'r') if d_line.startswith(file)),
78+
None
79+
)
80+
if downloaded_line:
81+
downloaded_size = downloaded_line.split()[1]
82+
if float(actual_size) > float(downloaded_size) * threshold:
83+
print(f"Error: File {file} size exceeds the threshold.")
84+
exit(1)
85+
else:
86+
print(f"Success: File {file} size comparison passed. Actual: {actual_size}, Downloaded: {downloaded_size}")
87+
else:
88+
print(f"Warning: Downloaded size not found for file {file}. Skipping comparison. Actual: {actual_size}")
89+
90+
id: check_size
91+
waitFor:
92+
- download_size
5993
- name: vizzu/vizzu-devenv:v0.8.x
6094
args:
6195
- node
@@ -106,6 +140,7 @@ steps:
106140
- .
107141
id: test_integration
108142
waitFor:
143+
- check_size
109144
- test_jsUnit
110145
- test_desktopUnit
111146
- test_wasmUnit
@@ -118,7 +153,7 @@ steps:
118153
echo $SHORT_SHA > sha.txt
119154
fi
120155
dir: /workspace/example
121-
id: sha_generate
156+
id: meta_generate
122157
waitFor:
123158
- test_integration
124159
entrypoint: bash
@@ -129,10 +164,11 @@ steps:
129164
if [ $BRANCH_NAME == "main" ]
130165
then
131166
gsutil -m cp '/workspace/example/sha.txt' 'gs://vizzu-lib-main/lib'
167+
gsutil -m cp '/workspace/build/cmake-wasm/weblib/size.txt' 'gs://vizzu-lib-main/lib'
132168
fi
133-
id: sha_upload
169+
id: meta_upload
134170
waitFor:
135-
- sha_generate
171+
- meta_generate
136172
entrypoint: bash
137173
- name: gcr.io/cloud-builders/gsutil
138174
args:

project/cmake/weblib/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ if(EMSCRIPTEN)
3838

3939
add_custom_command(TARGET cvizzu POST_BUILD
4040
COMMAND gzip -9 < "$<TARGET_FILE_DIR:cvizzu>/cvizzu.wasm" > "$<TARGET_FILE_DIR:cvizzu>/cvizzu.wasm.gz"
41-
COMMAND stat -c "%s : %n" "$<TARGET_FILE_DIR:cvizzu>/cvizzu.*")
41+
COMMAND stat -c "%s : %n" "$<TARGET_FILE_DIR:cvizzu>/cvizzu.*"
42+
COMMAND stat -c "%n %s" "$<TARGET_FILE_DIR:cvizzu>/cvizzu.*" > $<TARGET_FILE_DIR:cvizzu>/size.txt)
4243

4344

4445
endif()

0 commit comments

Comments
 (0)