Files
cgpcli/build

64 lines
1.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
export GOPATH="${HOME}/src/cgpcli"
# если на целевой ОС не совпадает glibc, то собираем без зависимостей.
# результирующий файл, возможно, получится медленнее и большего размера.
export CGO_ENABLED=0
if [ "$1" == "fmt" ]; then
go $*
elif [ "$1" == "run" ]; then
. .env
go run $2 $3 $4 $5
elif [ "$1" == "sandbox-test" ]; then
. .env
echo "--- Syncing sources to sandbox ---"
rsync -avz --delete \
--exclude '.git/' \
--exclude '*.bin' \
--exclude 'vendor/' \
"./" "${REMOTE_HOST}:${REMOTE_PATH}/"
echo ""
echo "--- Running tests on sandbox ---"
ssh "${REMOTE_HOST}" "cd ${REMOTE_PATH} && ./build test"
elif [ "$1" == "sandbox-test-one" ]; then
. .env
echo "--- Syncing sources to sandbox ---"
rsync -avz --delete \
--exclude '.git/' \
--exclude '*.bin' \
--exclude 'vendor/' \
"./" "${REMOTE_HOST}:${REMOTE_PATH}/"
echo ""
echo "--- Running tests on sandbox ---"
ssh "${REMOTE_HOST}" "cd ${REMOTE_PATH} && ./build test-once $2"
elif [ "$1" == "test" ]; then
. .env
go test -v
elif [ "$1" == "test-once" ]; then
. .env
go test -v -run $2
elif [ "$1" == "bench" ]; then
go test -bench=. -benchmem $2
elif [ "$1" == "bench2" ]; then
go test -bench=$2 -cpuprofile=cpu.pprof -benchmem $3
go test -bench=$2 -memprofile=mem.pprof -benchmem $3
elif [ "$1" == "tidy" ]; then
go mod tidy
elif [ "$1" == "vet" ]; then
echo "vet..."
go vet
else
go build
fi