From 50ea2d816421d371cbbee7094310c0b8d3786113 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Tue, 3 Nov 2020 13:42:44 -0800 Subject: [PATCH] Fix size check and make script shell consistent Related to #2205 Signed-off-by: Brad Davidson --- scripts/binary_size_check.sh | 14 +++++++++++--- scripts/ci | 8 ++++++-- scripts/dispatch | 4 ++-- scripts/manifest | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/binary_size_check.sh b/scripts/binary_size_check.sh index d8dccaccbfd0..5f2268c10522 100755 --- a/scripts/binary_size_check.sh +++ b/scripts/binary_size_check.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e @@ -7,10 +7,18 @@ if [ "${DEBUG}" = 1 ]; then fi MAX_BINARY_SIZE=61000000 -SIZE=$(ls -l dist/artifacts/k3s | awk -F ' ' '{print $5}') +BIN_SUFFIX="-${ARCH}" +if [ ${ARCH} = amd64 ]; then + BIN_SUFFIX="" +elif [ ${ARCH} = arm ]; then + BIN_SUFFIX="-armhf" +fi + +CMD_NAME="dist/artifacts/k3s${BIN_SUFFIX}" +SIZE=$(stat -c '%s' ${CMD_NAME}) if [ ${SIZE} -gt ${MAX_BINARY_SIZE} ]; then - echo "k3s binary exceeds acceptable size of "${MAX_BINARY_SIZE} + echo "k3s binary ${CMD_NAME} size ${SIZE} exceeds acceptable size of ${MAX_BINARY_SIZE}" exit 1 fi diff --git a/scripts/ci b/scripts/ci index 0e69a4637601..21df29638e09 100755 --- a/scripts/ci +++ b/scripts/ci @@ -1,7 +1,8 @@ #!/bin/bash set -e -cd $(dirname $0) +SCRIPT_DIR=$(dirname $0) +pushd $SCRIPT_DIR ./download if [ -z "$SKIP_VALIDATE" ]; then @@ -10,4 +11,7 @@ fi ./build ./package -./binary_size_check.sh + +popd + +$SCRIPT_DIR/binary_size_check.sh diff --git a/scripts/dispatch b/scripts/dispatch index e9a5622eaad1..3884955f122c 100755 --- a/scripts/dispatch +++ b/scripts/dispatch @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e set -x @@ -8,4 +8,4 @@ REPO="https://api.github.com/repos/rancher/k3s-upgrade/dispatches" curl -XPOST -u "${PAT_USERNAME}:${PAT_TOKEN}" \ -H "Accept: application/vnd.github.everest-preview+json" \ -H "Content-Type: application/json" $REPO \ - --data '{"event_type": "create_tag", "client_payload": {"tag":"'"$DRONE_TAG"'"}}' \ No newline at end of file + --data '{"event_type": "create_tag", "client_payload": {"tag":"'"$DRONE_TAG"'"}}' diff --git a/scripts/manifest b/scripts/manifest index b6759a58802d..5e863d26fd49 100755 --- a/scripts/manifest +++ b/scripts/manifest @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if [ -z "${DRONE_TAG}" ]; then echo "DRONE_TAG not defined" >&2