This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines-ext.yml
106 lines (94 loc) · 3.5 KB
/
azure-pipelines-ext.yml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
trigger:
- ext
pr: none
pool:
vmImage: 'Ubuntu 16.04'
variables:
- name: GOBIN
value: '$(GOPATH)/bin' # Go binaries path
- name: GOPATH
value: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
- name: modulePath
value: '$(GOPATH)/$(build.repository.name)'
- group: hwsc-dev-container-vars
- group: hwsc-user-svc-env-vars
steps:
- script: |
go version
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
docker pull postgres:alpine
docker pull hwsc/hwsc-user-svc:int
shopt -s extglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set Up the Go Workspace'
- script: go get -v -t -d ./...
workingDirectory: '$(modulePath)'
displayName: 'Go Get Dependencies'
- task: DownloadSecureFile@1
inputs:
secureFile: hwsctestgmail_pw.txt # contains info for test gmail
- script: go build -v .
workingDirectory: '$(modulePath)'
displayName: 'Build Go Executable Test'
- script: |
PASSWORD=$(cat $(Agent.TempDirectory)/hwsctestgmail_pw.txt)
export hosts_user_address=""
export hosts_user_port="50052"
export hosts_user_network="tcp"
export hosts_postgres_host="localhost"
export hosts_postgres_db="test_user_svc"
export hosts_postgres_user="postgres"
export hosts_postgres_password="secret"
export hosts_postgres_sslmode="disable"
export hosts_postgres_port="5432"
export hosts_smtp_host=$(testGmailHost)
export hosts_smtp_port=$(testGmailPort)
export hosts_smtp_username=$(testGmailUser)
export hosts_smtp_password=$PASSWORD
docker-compose up -d
sleep 10
go test -v -cover -race ./...
docker-compose down
docker-compose up -d
go get github.com/jstemmer/go-junit-report
go get github.com/axw/gocov/gocov
go get github.com/AlekSi/gocov-xml
go test -coverprofile=coverage.out -v -race -covermode atomic ./... 2>&1 | go-junit-report > report.xml
gocov convert coverage.out | gocov-xml > coverage.xml
mkdir -p coverage/official-tool
go tool cover -html=coverage.out -o coverage/official-tool/coverage.html
go get -u github.com/matm/gocov-html
gocov convert coverage.out > coverage.json
gocov-html < coverage.json > coverage/index.html
docker-compose down
workingDirectory: '$(modulePath)'
displayName: 'Run Unit Test'
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml
failTaskOnFailedTests: 'true'
failOnStandardError: 'true'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml
reportDirectory: $(System.DefaultWorkingDirectory)/**/coverage
failIfCoverageEmpty: 'true'
failOnStandardError: 'true'
- task: DownloadSecureFile@1
inputs:
secureFile: hwscdevcontainer_pw.txt
- script: |
cat $(Agent.TempDirectory)/hwscdevcontainer_pw.txt | docker login -u "$(hwscDevContainerUser)" --password-stdin
docker build --no-cache -f Dockerfile -t hwsc/hwsc-app-gateway-svc:ext .
workingDirectory: '$(modulePath)'
displayName: 'Build Docker Image External Release'
- script: |
docker push hwsc/hwsc-app-gateway-svc:ext
workingDirectory: '$(modulePath)'
displayName: 'Push Docker Image External Release'