File: jenkins.sh

package info (click to toggle)
golang-github-vmware-photon-controller-go-sdk 0.0~PROMOTED-339-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,080 kB
  • ctags: 458
  • sloc: sh: 33; makefile: 4
file content (52 lines) | stat: -rwxr-xr-x 1,327 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -e

if [ -z "$WORKSPACE" ]
then
  pushd $(dirname $BASH_SOURCE)
  export WORKSPACE=$(git rev-parse --show-toplevel)
  echo Assume default WORKSPACE $WORKSPACE
  popd
fi

# Go expects to have a "Go workspace" (GOPATH) present in order to build.
# This workspace is not supposed to be checked in, so we must create it at
# build time.
cd $WORKSPACE
export GOPATH=$WORKSPACE

# $WORKSPACE will be the root of the git repo that is pulled in by Jenkins.
# We need to move its contents into the expected package path inside
# $GOPATH/src (defined by PACKAGESRC) before we can build.
PACKAGESRC=src/github.com/vmware/photon-controller-go-sdk

# clean the directory
if [ -n "$WORKSPACE" ]
then
	rm -rf $WORKSPACE/src $WORKSPACE/pkg $WORKSPACE/bin
fi

REPOFILES=(*)
echo ${REPOFILES[*]}
mkdir -p $PACKAGESRC
cp -r ${REPOFILES[*]} $PACKAGESRC/

go get github.com/tools/godep
pushd $PACKAGESRC
$GOPATH/bin/godep restore

# Fail if there is any go fmt error.
if [[ -n "$(gofmt -l photon)" ]]; then
	echo Fix gofmt errors
	gofmt -d photon
	exit 1
fi

export cmd="go test ./... -v"
# Test against a real external endpoint requires longer timeout than GO's default 600s
if [ "" != "$TEST_ENDPOINT" ]
	then
		export cmd="$cmd -timeout 1800s"
fi
# Build and run tests
$cmd -ginkgo.noColor -ginkgo.slowSpecThreshold=60 -ginkgo.v