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
/
Copy pathazure-pipelines-ext.yml
85 lines (73 loc) · 2.72 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
trigger:
- ext
pr: none
pool:
vmImage: 'Ubuntu 16.04'
variables:
- name: GOBIN
value: '$(GOPATH)/bin' # Go binaries path
- name: GOROOT
value: '/usr/local/go1.11' # Go installation path
- name: GOPATH
value: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
- name: modulePath
value: '$(GOPATH)/$(build.repository.name)'
- group: hwsc-dev-container-vars
steps:
- script: printenv
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
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'
- script: go build -v .
workingDirectory: '$(modulePath)'
displayName: 'Build Go Executable Test'
- script: |
export hosts_mongodb_db="test-document"
export hosts_mongodb_collection="test-document"
go test -v -cover -race ./...
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
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-document-svc:ext .
workingDirectory: '$(modulePath)'
displayName: 'Build Docker Image External Release'
- script: |
docker push hwsc/hwsc-document-svc:ext
workingDirectory: '$(modulePath)'
displayName: 'Push Docker Image External Release'