rohithrajneesh | c04abca | 2023-08-24 16:06:37 +0100 | [diff] [blame] | 1 | #!/bin/bash -x |
nauman | 55ba941 | 2022-03-28 15:15:19 +0000 | [diff] [blame] | 2 | |
3 | set -euo pipefail | ||||
4 | |||||
rohithrajneesh | 3f14c40 | 2023-09-21 15:45:22 +0100 | [diff] [blame] | 5 | DIRECTORY=$WORKSPACE"/"${DIRECTORY} |
rohithrajneesh | c04abca | 2023-08-24 16:06:37 +0100 | [diff] [blame] | 6 | cd $DIRECTORY |
nauman | 55ba941 | 2022-03-28 15:15:19 +0000 | [diff] [blame] | 7 | |
rohithrajneesh | c04abca | 2023-08-24 16:06:37 +0100 | [diff] [blame] | 8 | # Read desired Go version from go.mod file |
9 | desired_version=$(grep '^go' go.mod | grep -Eo '[0-9]\.[0-9]+') | ||||
nauman | 55ba941 | 2022-03-28 15:15:19 +0000 | [diff] [blame] | 10 | |
rohithrajneesh | aec245a | 2023-09-22 15:27:42 +0100 | [diff] [blame] | 11 | # Remove existing Go installation |
12 | sudo rm -fr /usr/local/go | ||||
nauman | 55ba941 | 2022-03-28 15:15:19 +0000 | [diff] [blame] | 13 | |
rohithrajneesh | aec245a | 2023-09-22 15:27:42 +0100 | [diff] [blame] | 14 | echo "Download go $desired_version" |
15 | curl -L "https://go.dev/dl/go$desired_version.linux-amd64.tar.gz" | sudo tar -C /usr/local -zxf - | ||||
rohithrajneesh | c04abca | 2023-08-24 16:06:37 +0100 | [diff] [blame] | 16 | |
rohithrajneesh | aec245a | 2023-09-22 15:27:42 +0100 | [diff] [blame] | 17 | export PATH=$PATH:/usr/local/go/bin |
nauman | 55ba941 | 2022-03-28 15:15:19 +0000 | [diff] [blame] | 18 | |
19 | echo "Download project deps" | ||||
20 | go mod tidy | ||||
21 | |||||
rohithrajneesh | c04abca | 2023-08-24 16:06:37 +0100 | [diff] [blame] | 22 | echo "Force build" |
23 | go build -a -v | ||||
24 | |||||
nauman | 55ba941 | 2022-03-28 15:15:19 +0000 | [diff] [blame] | 25 | echo "Run tests" |
rohithrajneesh | c04abca | 2023-08-24 16:06:37 +0100 | [diff] [blame] | 26 | go test ./... -json |