#!/usr/bin/env bash
set -eu
cd "$(dirname "$0")/build/app"
echo '== generation and native build =='
go generate ./...
go run .
make test
make build VERSION=v1.2.3 COMMIT=abc123
./dist/app
echo '== build tag =='
go run -tags=enterprise .
go test -tags=enterprise ./...
echo '== fixed inputs repeat build =='
go build -trimpath -ldflags='-X main.version=v1.2.3 -X main.commit=abc123' -o dist/repeat .
cmp dist/app dist/repeat
echo identical=true
sha256sum dist/app dist/repeat
echo '== cross compile only, not executed =='
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -o dist/app_linux_arm64 .
go version -m dist/app_linux_arm64
file dist/app_linux_arm64
echo '== cgo native =='
cd ../cgodemo
CGO_ENABLED=1 go run .
echo '== cgo disabled: expected failure =='
if CGO_ENABLED=0 go build .; then exit 1; else echo expected_failure=true; fi
