forked from newrelic/newrelic-fluent-bit-output
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpr-pipeline.yml
61 lines (53 loc) · 1.68 KB
/
pr-pipeline.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
pr:
branches:
include:
- '*'
pool:
vmImage: 'ubuntu-16.04' # Has Docker
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
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'
displayName: 'Set up the Go workspace'
- task: Bash@3
displayName: 'Run tests'
inputs:
targetType: 'inline'
workingDirectory: '$(modulePath)'
script: |
go get -v -u github.com/jstemmer/go-junit-report
go test -v 2>&1 | go-junit-report > test-results.xml
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '$(modulePath)/test-results.xml'
failTaskOnFailedTests: true
# Attempt to build (running tests does not do all the things that making the project does)
- script: make all
workingDirectory: '$(modulePath)'
displayName: 'Build project file'
- task: Bash@3
inputs:
targetType: 'inline'
workingDirectory: '$(modulePath)'
script: |
VERSION=`cat version.go | grep VERSION | awk '{gsub(/"/, "", $4); print $4}'`
echo "##vso[task.setvariable variable=VERSION]$VERSION"
displayName: 'Get the current version into a variable'
- task: Docker@2
displayName: Build Docker image
inputs:
command: build
buildContext: '$(modulePath)'
Dockerfile: '$(modulePath)/Dockerfile'
repository: newrelic/newrelic-fluentbit-output
tags: $(VERSION)