11# This contains common build steps
22
33steps :
4- - script : |
5- mkdir -p '$(GOBIN)'
6- mkdir -p '$(GOPATH)/pkg'
7- mkdir -p '$(modulePath)'
8- shopt -s extglob
9- shopt -s dotglob
10- mv !(gopath) '$(modulePath)'
11- echo '##vso[task.prependpath]$(GOBIN)'
12- echo '##vso[task.prependpath]$(GOROOT)/bin'
13- displayName : ' Set up the Go workspace'
14-
15- - script : |
16- go get -u golang.org/x/lint/golint
17- golint $(go list ./... | grep -v /vendor/) | tee /tmp/lint.out
18- if [ -s /tmp/lint.out ]; then
19- echo -e "\e[101;97m golint FAILED \e[0m"``
20- exit 1
21- else
22- echo -e "\e[42;97m golint SUCCEEDED \e[0m"
23- fi
24- workingDirectory : ' $(modulePath)'
25- displayName : ' Go lint'
26-
27- - script : |
28- if go vet ./...; then
29- echo -e "\e[42;97m govet SUCCEEDED \e[0m"
30- else
31- echo -e "\e[101;97m govet FAILED \e[0m"``
32- exit 1
33- fi
34-
35- if go vet -tags=unittest ./...; then
36- echo -e "\e[42;97m govet SUCCEEDED \e[0m"
37- else
38- echo -e "\e[101;97m govet FAILED \e[0m"``
39- exit 1
40- fi
41-
42- cd ./scripts/e2e
43- if go vet -tags=e2e ./...; then
44- echo -e "\e[42;97m govet SUCCEEDED \e[0m"
45- else
46- echo -e "\e[101;97m govet FAILED \e[0m"``
47- exit 1
48- fi
49- cd ../..
50- workingDirectory : ' $(modulePath)'
51- displayName : ' Go vet'
52-
53- - script : |
54- set -u
55- go version
56- echo -e "\e[44;97m Compiling ... \e[0m"
57-
58- # set version
59- ORG_PATH="github.com/Azure"
60- PROJECT_NAME="application-gateway-kubernetes-ingress"
61- REPO_PATH="${ORG_PATH}/${PROJECT_NAME}"
62- VERSION_VAR="${REPO_PATH}/pkg/version.Version"
63- VERSION=$(git describe --abbrev=0 --tags)
64- DATE_VAR="${REPO_PATH}/pkg/version.BuildDate"
65- BUILD_DATE=$(date +%Y-%m-%d-%H:%MT%z)
66- COMMIT_VAR="${REPO_PATH}/pkg/version.GitCommit"
67- GIT_HASH=$(git rev-parse --short HEAD)
68-
69- echo "VERSION $VERSION_VAR:$VERSION, BUILD_DATE $DATE_VAR:$BUILD_DATE, GIT_HASH $COMMIT_VAR:$GIT_HASH"
70- if go install -ldflags "-s -X ${VERSION_VAR}=${VERSION} -X ${DATE_VAR}=${BUILD_DATE} -X ${COMMIT_VAR}=${GIT_HASH}" -v ./cmd/appgw-ingress; then
71- chmod -R 777 $(GOBIN)
72- $(GOBIN)/appgw-ingress --version
73- echo -e "\e[42;97m Build SUCCEEDED \e[0m"
74- else
75- echo -e "\e[101;97m Build FAILED \e[0m"
76- exit 1
77- fi
78- workingDirectory : ' $(modulePath)'
79- displayName : ' Get dependencies and build'
80-
81- - script : |
82- go get github.com/jstemmer/go-junit-report
83- go get github.com/axw/gocov/gocov
84- go get github.com/AlekSi/gocov-xml
85- go get github.com/matm/gocov-html
86- go test -timeout 80s -v -coverprofile=coverage.txt -covermode count -tags unittest ./... > testoutput.txt || { echo "go test returned non-zero"; cat testoutput.txt; exit 1; }
87- cat testoutput.txt | go-junit-report > report.xml
88- gocov convert coverage.txt > coverage.json
89- gocov-xml < coverage.json > coverage.xml
90- mkdir coverage
91- gocov-html < coverage.json > coverage/index.html
92- workingDirectory : ' $(modulePath)'
93- displayName : ' Run unit tests with code coverage'
94-
95- - script : |
96- helm lint ./helm/ingress-azure
97- workingDirectory : ' $(modulePath)'
98- displayName : ' Helm lint'
99-
100- - task : PublishTestResults@2
101- continueOnError : true
102- condition : succeededOrFailed()
103- inputs :
104- failTaskOnFailedTests : true
105- testRunner : JUnit
106- testResultsFiles : $(System.DefaultWorkingDirectory)/**/report.xml
107-
108-
109- - task : PublishCodeCoverageResults@1
110- continueOnError : true
111- condition : succeededOrFailed()
112- inputs :
113- codeCoverageTool : Cobertura
114- summaryFileLocation : $(modulePath)/coverage.xml
115- reportDirectory : $(modulePath)/coverage
116-
117- - task : CopyFiles@2
118- inputs :
119- contents : |
120- $(GOBIN)/appgw-ingress
121- $(modulePath)/dockerfiles/deploy.Dockerfile
122- $(modulePath)/scripts/**
123- $(modulePath)/helm/**
124- targetFolder : $(Build.ArtifactStagingDirectory)
125-
126- - task : PublishBuildArtifacts@1
127- inputs :
128- pathtoPublish : $(Build.ArtifactStagingDirectory)
129- artifactName : drop
4+ - script : |
5+ mkdir -p '$(GOBIN)'
6+ mkdir -p '$(GOPATH)/pkg'
7+ mkdir -p '$(modulePath)'
8+ shopt -s extglob
9+ shopt -s dotglob
10+ mv !(gopath) '$(modulePath)'
11+ echo '##vso[task.prependpath]$(GOBIN)'
12+ echo '##vso[task.prependpath]$(GOROOT)/bin'
13+ displayName: "Set up the Go workspace"
14+
15+ - script : make lint-all
16+ workingDirectory : " $(modulePath)"
17+ displayName : " Go and Helm lint check"
18+
19+ - script : make vet-all
20+ workingDirectory : " $(modulePath)"
21+ displayName : " Go vet"
22+
23+ - script : make build
24+ workingDirectory : " $(modulePath)"
25+ displayName : " Get dependencies and build"
26+
27+ - script : make unittest
28+ workingDirectory : " $(modulePath)"
29+ displayName : " Run unit tests with code coverage"
30+
31+ - task : PublishTestResults@2
32+ continueOnError : true
33+ condition : succeededOrFailed()
34+ inputs :
35+ failTaskOnFailedTests : true
36+ testRunner : JUnit
37+ testResultsFiles : $(System.DefaultWorkingDirectory)/**/report.xml
38+
39+ - task : PublishCodeCoverageResults@1
40+ continueOnError : true
41+ condition : succeededOrFailed()
42+ inputs :
43+ codeCoverageTool : Cobertura
44+ summaryFileLocation : $(modulePath)/coverage.xml
45+ reportDirectory : $(modulePath)/coverage
46+
47+ - task : CopyFiles@2
48+ inputs :
49+ contents : |
50+ $(modulePath)/scripts/**
51+ $(modulePath)/helm/**
52+ targetFolder : $(Build.ArtifactStagingDirectory)
53+
54+ - task : PublishBuildArtifacts@1
55+ inputs :
56+ pathtoPublish : $(Build.ArtifactStagingDirectory)
57+ artifactName : drop
0 commit comments