-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.docker.yml
63 lines (53 loc) · 1.72 KB
/
azure-pipelines.docker.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
#
#
#
#
pool:
vmImage: 'ubuntu-16.04' # examples of other options: 'macOS-10.13', 'vs2017-win2016'
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
GOMAXPROCS: 9
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
dockerId: aipiggybot
imageName: agil # Replace with the name of the image you want to publish
steps:
- 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'
echo 'Variables:'
echo ${MONGO_DATABASE}
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'
- script: |
set -e
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
if [[ -s coverage.txt ]]; then bash <(curl -s https://codecov.io/bash); fi
env:
MONGO_DATABASE: $(MONGO_DATABASE)
MONGO_CONNECTION_STRING: $(MONGO_CONNECTION_STRING)
CODECOV_TOKEN: $(CODECOV_TOKEN)
workingDirectory: '$(modulePath)'
displayName: 'Run tests'
# Docker
- script: |
set -e
docker build --no-cache -t $(dockerId)/$(imageName) .
echo "${DOCKERPASSWORD}"| docker login -u=$(dockerId) --password-stdin
docker push $(dockerId)/$(imageName)
docker logout
env:
DOCKERPASSWORD: $(dockerPassword)
workingDirectory: '$(modulePath)'
displayName: 'Building docker image and pushing'