Merge "add ci image building job"
[infra/cicd.git] / jjb / oransc / verify-jobs-go.sh
1 #!/bin/bash -x
2
3 set -euo pipefail
4
5 DIRECTORY=$WORKSPACE"/"${DIRECTORY}
6 cd $DIRECTORY
7
8 # Read desired Go version from go.mod file
9 desired_version=$(grep '^go' go.mod | grep -Eo '[0-9]\.[0-9]+')
10
11 # Remove existing Go installation
12 sudo rm -fr /usr/local/go
13
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 -
16
17 export PATH=$PATH:/usr/local/go/bin
18
19 echo "Download project deps"
20 go mod tidy
21
22 echo "Force build"
23 go build -a -v
24
25 echo "Run tests"
26 go test ./... -json