From 1f1d9fce5898bd37b6055d12c5967d1d301e1d9e Mon Sep 17 00:00:00 2001 From: Jessica Grebenschikov Date: Wed, 20 Jan 2021 10:57:47 -0800 Subject: [PATCH] satellite/console/wasm: add test to confirm wasm size isnt growing Change-Id: I975a9f8ac3f6b98cc213140fdd7a99557efe14c8 --- Jenkinsfile.public | 1 + Makefile | 5 +++++ scripts/test-wasm-size.sh | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100755 scripts/test-wasm-size.sh diff --git a/Jenkinsfile.public b/Jenkinsfile.public index 4c24993e7..51e99de05 100644 --- a/Jenkinsfile.public +++ b/Jenkinsfile.public @@ -57,6 +57,7 @@ pipeline { sh 'golangci-lint --config /go/ci/.golangci.yml -j=2 run' sh 'check-mod-tidy -mod .build/go.mod.orig' sh 'make check-monitoring' + sh 'make test-wasm-size' } } diff --git a/Makefile b/Makefile index d5ddd4102..4709bcdaa 100644 --- a/Makefile +++ b/Makefile @@ -129,6 +129,11 @@ check-monitoring: ## Check for locked monkit calls that have changed || (echo "Locked monkit metrics have been changed. Notify #data-science and run \`go run github.com/storj/ci/check-monitoring -out monkit.lock ./...\` to update monkit.lock file." \ && exit 1) +.PHONY: test-wasm-size +test-wasm-size: ## Test that the built .wasm code has not increased in size + @echo "Running ${@}" + @./scripts/test-wasm-size.sh + ##@ Build .PHONY: storagenode-console diff --git a/scripts/test-wasm-size.sh b/scripts/test-wasm-size.sh new file mode 100755 index 000000000..a63f2dcd7 --- /dev/null +++ b/scripts/test-wasm-size.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -ueo pipefail +set +x + +cleanup(){ + rm main.wasm + echo "cleaned up test successfully" +} +trap cleanup EXIT + +cd satellite/console/wasm && pwd && GOOS=js GOARCH=wasm go build -o main.wasm . +BUILD_SIZE=$(stat -c %s main.wasm) +CURRENT_SIZE=10000000 +if [ $BUILD_SIZE -gt $CURRENT_SIZE ]; then + echo "Wasm size is too big, was $CURRENT_SIZE but now it is $BUILD_SIZE" + exit 1 +fi + +echo "Wasm size did not increase and it is $BUILD_SIZE (limit: $CURRENT_SIZE)"