github.com/wfusion/gofusion@v1.1.14/test/ci-darwin.sh (about) 1 #!/usr/bin/env bash 2 3 set -ex 4 5 # project path 6 APP="gofusion" 7 WORKDIR=$(cd $(dirname "$0") || exit; pwd) 8 WORKDIR=${WORKDIR%"$APP"*}$APP 9 cd "${WORKDIR}" || exit 10 OUTPUT_DIR="${WORKDIR}"/assets 11 OUTPUT="${OUTPUT_DIR}"/unittest 12 mkdir -p "${OUTPUT}" 13 touch "${OUTPUT}"/coverage.out 14 15 # dep install 16 go install gotest.tools/gotestsum@latest 17 go install github.com/axw/gocov/gocov@latest 18 go install github.com/matm/gocov-html/cmd/gocov-html@latest 19 go install github.com/tdewolff/minify/v2/cmd/minify@v2.20.7 20 if ! type -p allure; then 21 brew install allure 22 fi 23 if ! type -p allure-combine; then 24 pip install allure-combine 25 fi 26 27 # run test 28 COVER_PKG=$(find . -type d | sed 's|^./||' | sed 's|^\.$||' | egrep -v '^$|^.git/*|^test/*|^assets/*|^.idea/*|^common/fus/*|^common/infra/drivers/orm/opengauss/*|^common/infra/drivers/orm/sqlite/*|^common/infra/asynq/*|^common/infra/metrics/*|^common/infra/watermill/*|^common/infra/rotatelog/*|^common/utils/gomonkey/*|^common/utils/sqlparser/*' | awk '{print "github.com/wfusion/gofusion/" $0}' | tr '\n' ',' | sed 's/,$//') 29 gotestsum --junitfile "${OUTPUT}"/junit.xml -- -timeout 30m -parallel 1 ./test/... -coverpkg="${COVER_PKG}" -coverprofile="${OUTPUT}"/coverage.out -covermode count || true 30 31 # export test report 32 echo "export complete.xml" 33 allure generate "${OUTPUT}" -o "${OUTPUT}"/allure --clean 34 while [ ! -d "${OUTPUT}"/allure ]; do 35 sleep 1 36 done 37 allure-combine --remove-temp-files --ignore-utf8-errors "${OUTPUT}"/allure --dest "${OUTPUT}" 38 minify -r -o "${OUTPUT}"/unittest.html "${OUTPUT}"/complete.html || true 39 40 # export test coverage report 41 echo "export coverage.html" 42 gocov convert "${OUTPUT}"/coverage.out > "${OUTPUT}"/coverage.json 43 gocov-html < "${OUTPUT}"/coverage.json > "${OUTPUT}"/gocov.html 44 minify -r -o "${OUTPUT}"/coverage.html "${OUTPUT}"/gocov.html || true 45 46 echo "export coverage.svg" 47 go-cover-treemap -coverprofile "${OUTPUT}"/coverage.out -only-folders > "${OUTPUT}"/coverage.svg 48 49 # remove temps 50 rm "${OUTPUT}"/coverage.out "${OUTPUT}"/coverage.json "${OUTPUT}"/junit.xml "${OUTPUT}"/gocov.html "${OUTPUT}"/complete.html 51 rm -rf "${OUTPUT}"/allure