| #!/bin/bash -x |
| |
| set -euo pipefail |
| |
| DIRECTORY=$WORKSPACE"/"${DIRECTORY} |
| cd $DIRECTORY |
| |
| # Read desired Go version from go.mod file |
| desired_version=$(grep '^go' go.mod | grep -Eo '[0-9]\.[0-9]+') |
| |
| # Remove existing Go installation |
| sudo rm -fr /usr/local/go |
| |
| echo "Download go $desired_version" |
| curl -L "https://go.dev/dl/go$desired_version.linux-amd64.tar.gz" | sudo tar -C /usr/local -zxf - |
| |
| export PATH=$PATH:/usr/local/go/bin |
| |
| echo "Download project deps" |
| go mod tidy |
| |
| echo "Force build" |
| go build -a -v |
| |
| echo "Run tests" |
| go test ./... -json |