blob: 84b3f5a090a64a53a512a5a373c7f9d3ce26d558 [file] [log] [blame]
rohithrajneeshc04abca2023-08-24 16:06:37 +01001#!/bin/bash -x
nauman55ba9412022-03-28 15:15:19 +00002
3set -euo pipefail
4
rohithrajneesh3f14c402023-09-21 15:45:22 +01005DIRECTORY=$WORKSPACE"/"${DIRECTORY}
rohithrajneeshc04abca2023-08-24 16:06:37 +01006cd $DIRECTORY
nauman55ba9412022-03-28 15:15:19 +00007
rohithrajneeshc04abca2023-08-24 16:06:37 +01008# Read desired Go version from go.mod file
9desired_version=$(grep '^go' go.mod | grep -Eo '[0-9]\.[0-9]+')
nauman55ba9412022-03-28 15:15:19 +000010
rohithrajneeshaec245a2023-09-22 15:27:42 +010011# Remove existing Go installation
12sudo rm -fr /usr/local/go
nauman55ba9412022-03-28 15:15:19 +000013
rohithrajneeshaec245a2023-09-22 15:27:42 +010014echo "Download go $desired_version"
15curl -L "https://go.dev/dl/go$desired_version.linux-amd64.tar.gz" | sudo tar -C /usr/local -zxf -
rohithrajneeshc04abca2023-08-24 16:06:37 +010016
rohithrajneeshaec245a2023-09-22 15:27:42 +010017export PATH=$PATH:/usr/local/go/bin
nauman55ba9412022-03-28 15:15:19 +000018
19echo "Download project deps"
20go mod tidy
21
rohithrajneeshc04abca2023-08-24 16:06:37 +010022echo "Force build"
23go build -a -v
24
nauman55ba9412022-03-28 15:15:19 +000025echo "Run tests"
rohithrajneeshc04abca2023-08-24 16:06:37 +010026go test ./... -json