@@ -8,65 +8,25 @@ set -euo pipefail
88
99TABLE_NAME=" CWABinarySizes"
1010S3_BUCKET=" ${S3_BUCKET:? S3_BUCKET is required} "
11- COMMIT_HASH=" ${COMMIT_HASH:? COMMIT_HASH is required} "
12- COMMIT_DATE=" ${COMMIT_DATE:? COMMIT_DATE is required} "
13- TAG=" ${TAG:- } "
11+ export COMMIT_HASH=" ${COMMIT_HASH:? COMMIT_HASH is required} "
12+ export COMMIT_DATE=" ${COMMIT_DATE:? COMMIT_DATE is required} "
13+ export TAG=" ${TAG:- } "
1414REGION=" us-west-2"
1515
16- S3_PREFIX=" integration-test/binary/${COMMIT_HASH} /"
16+ export S3_PREFIX=" integration-test/binary/${COMMIT_HASH} /"
1717
18- echo " Collecting binary sizes from S3 (${COMMIT_HASH: 0: 12} )..."
19-
20- ITEM_JSON=$(
21- aws s3 ls " s3://${S3_BUCKET} /${S3_PREFIX} " --recursive --region " $REGION " |
22- awk ' {print $3, $4}' |
23- python3 - " $S3_PREFIX " " $COMMIT_HASH " " $COMMIT_DATE " " $TAG " << 'PYEOF '
24- import sys, json
25-
26- prefix = sys.argv[1]
27- commit_hash = sys.argv[2]
28- commit_date = sys.argv[3]
29- tag = sys.argv[4]
30-
31- skip_ext = ('.sig', '.jar', '.rpm', '.deb', '.pkg', '.msi', '.tar.gz', '.gz', '.zip')
32- skip_names = ('CWAGENT_VERSION', 'buildMSI.zip')
33-
34- binaries = {}
35- for line in sys.stdin:
36- line = line.strip()
37- if not line:
38- continue
39- parts = line.split(' ', 1)
40- if len(parts) != 2:
41- continue
42- size, key = int(parts[0]), parts[1]
43- rel_path = key[len(prefix):] if key.startswith(prefix) else key
44- segments = rel_path.split('/')
45- if len(segments) != 2:
46- continue
47- filename = segments[1]
48- if any(filename.endswith(ext) for ext in skip_ext):
49- continue
50- if filename in skip_names:
51- continue
52- binaries[rel_path] = {"N": str(size)}
18+ SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
5319
54- if not binaries:
55- sys.exit(1)
20+ echo " Collecting binary sizes from S3 (${COMMIT_HASH: 0: 12} )..."
5621
57- record_type = "release" if tag else "commit"
58- item = {
59- "CommitHash": {"S": commit_hash},
60- "CommitDate": {"N": commit_date},
61- "Branch": {"S": "main"},
62- "RecordType": {"S": record_type},
63- "Binaries": {"M": binaries},
64- }
65- if tag:
66- item["Tag"] = {"S": tag}
22+ S3_LISTING=$( aws s3 ls " s3://${S3_BUCKET} /${S3_PREFIX} " --recursive --region " $REGION " || true)
23+ if [[ -z " $S3_LISTING " ]]; then
24+ echo " No binaries found in S3, skipping."
25+ exit 0
26+ fi
6727
68- print(json.dumps(item))
69- PYEOF
28+ ITEM_JSON= $(
29+ echo " $S3_LISTING " | awk ' {print $3, $4} ' | python3 " $SCRIPT_DIR /parse-s3-binaries.py "
7030) || {
7131 echo " No binaries found in S3, skipping."
7232 exit 0
0 commit comments