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)"