File tree Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Original file line number Diff line number Diff line change 1+ name : check-size
2+
3+ on : pull_request
4+
5+ jobs :
6+ check-size :
7+ runs-on : ubuntu-latest
8+ steps :
9+ - name : Checkout
10+ uses : actions/checkout@v2
11+
12+ - name : Set up Python
13+ uses : actions/setup-python@v2
14+ with :
15+ python-version : 3.7
16+
17+ - name : Install dependencies
18+ run : |
19+ pip install virtualenv
20+ virtualenv venv
21+ source venv/bin/activate
22+ pip install .[dev]
23+
24+ - name : Build Layers
25+ run : ./scripts/build_layers.sh
26+
27+ - name : Check Size
28+ run : ./scripts/check_layer_size.sh
Original file line number Diff line number Diff line change 1- #! /bin/sh
1+ #! /bin/bash
22
33# Unless explicitly stated otherwise all files in this repository are licensed
44# under the Apache License Version 2.0.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Unless explicitly stated otherwise all files in this repository are licensed
4+ # under the Apache License Version 2.0.
5+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
6+ # Copyright 2019 Datadog, Inc.
7+
8+ # Compares layer size to threshold, and fails if below that threshold
9+
10+ # 5 mb size limit
11+ MAX_LAYER_COMPRESSED_SIZE_KB=$( expr 5 \* 1024)
12+ MAX_LAYER_UNCOMPRESSED_SIZE_KB=$( expr 16 \* 1024)
13+
14+
15+ LAYER_FILES_PREFIX=" datadog_lambda_py"
16+ LAYER_DIR=" .layers"
17+ VERSIONS=(" 2.7" " 3.6" " 3.7" " 3.8" )
18+
19+ for version in " ${VERSIONS[@]} "
20+ do
21+ FILE=$LAYER_DIR /${LAYER_FILES_PREFIX}${version} .zip
22+ FILE_SIZE=$( stat --printf=" %s" $FILE )
23+ FILE_SIZE_KB=" $(( ${FILE_SIZE%% * } / 1024 )) "
24+ echo " Layer file ${FILE} has zipped size ${FILE_SIZE_KB} kb"
25+ if [ " $FILE_SIZE_KB " -gt " $MAX_LAYER_COMPRESSED_SIZE_KB " ]; then
26+ echo " Zipped size exceeded limit $MAX_LAYER_COMPRESSED_SIZE_KB kb"
27+ exit 1
28+ fi
29+ mkdir tmp
30+ unzip -q $FILE -d tmp
31+ UNZIPPED_FILE_SIZE=$( du -shb tmp/ | cut -f1)
32+ UNZIPPED_FILE_SIZE_KB=" $(( ${UNZIPPED_FILE_SIZE%% * } / 1024 )) "
33+ rm -rf tmp
34+ echo " Layer file ${FILE} has unzipped size ${UNZIPPED_FILE_SIZE_KB} kb"
35+ if [ " $UNZIPPED_FILE_SIZE_KB " -gt " $MAX_LAYER_UNCOMPRESSED_SIZE_KB " ]; then
36+ echo " Unzipped size exceeded limit $MAX_LAYER_UNCOMPRESSED_SIZE_KB kb"
37+ exit 1
38+ fi
39+ done
You can’t perform that action at this time.
0 commit comments