2019-07-26 21:26:54 +03:00
|
|
|
resources:
|
|
|
|
containers:
|
2019-07-26 23:50:33 +03:00
|
|
|
- container: golang
|
2019-07-26 21:26:54 +03:00
|
|
|
image: devcrewsacr.azurecr.io/operator-sdk-builder:latest
|
2019-07-26 21:41:41 +03:00
|
|
|
endpoint: AzureCR
|
2019-07-26 23:58:55 +03:00
|
|
|
|
|
|
|
- container: docker
|
2019-07-29 18:30:14 +03:00
|
|
|
image: debian:buster
|
2019-07-26 21:26:54 +03:00
|
|
|
options: '-v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock'
|
|
|
|
|
2019-07-27 07:31:35 +03:00
|
|
|
trigger:
|
|
|
|
batch: true
|
2019-07-27 07:45:29 +03:00
|
|
|
paths:
|
|
|
|
exclude:
|
|
|
|
- assets/*
|
|
|
|
- deploy/*
|
2019-07-26 21:26:54 +03:00
|
|
|
|
|
|
|
name: $(Date:yyyyMMdd)$(Rev:r)
|
2019-07-29 18:30:14 +03:00
|
|
|
variables:
|
|
|
|
skipComponentGovernanceDetection: true
|
2019-07-27 07:38:00 +03:00
|
|
|
|
2019-07-26 21:26:54 +03:00
|
|
|
jobs:
|
|
|
|
######################################################################
|
|
|
|
# Build
|
|
|
|
######################################################################
|
|
|
|
- job: Build
|
2019-07-26 23:50:33 +03:00
|
|
|
container: golang
|
2019-07-26 21:26:54 +03:00
|
|
|
displayName: Build Operator
|
2019-07-27 04:07:32 +03:00
|
|
|
variables:
|
2019-07-27 04:15:54 +03:00
|
|
|
GOPATH: $(Pipeline.Workspace)/go
|
2019-07-26 21:26:54 +03:00
|
|
|
steps:
|
2019-07-27 03:54:42 +03:00
|
|
|
- task: CacheBeta@0
|
|
|
|
inputs:
|
|
|
|
key: |
|
|
|
|
vendor
|
|
|
|
$(Agent.OS)
|
|
|
|
$(Build.SourcesDirectory)/go.sum
|
2019-07-27 04:07:32 +03:00
|
|
|
path: $(GOPATH)/src
|
2019-07-27 03:54:42 +03:00
|
|
|
displayName: Cache Vendor Directory
|
2019-07-27 04:13:21 +03:00
|
|
|
|
2019-07-27 04:25:21 +03:00
|
|
|
- script: go build -o build/_output/bin/ring-operator cmd/manager/main.go
|
2019-07-29 18:34:23 +03:00
|
|
|
displayName: Build project
|
2019-07-27 03:56:52 +03:00
|
|
|
|
|
|
|
- publish: $(Build.SourcesDirectory)/build
|
2019-07-27 04:18:23 +03:00
|
|
|
artifact: build
|
2019-07-26 21:26:54 +03:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Tests
|
|
|
|
######################################################################
|
|
|
|
- job: UnitTests
|
2019-07-26 23:50:33 +03:00
|
|
|
container: golang
|
2019-07-29 18:33:14 +03:00
|
|
|
displayName: Unit Tests
|
2019-07-26 21:26:54 +03:00
|
|
|
dependsOn: Build
|
2019-07-27 04:28:13 +03:00
|
|
|
variables:
|
|
|
|
GOPATH: $(Pipeline.Workspace)/go
|
2019-07-26 21:26:54 +03:00
|
|
|
steps:
|
2019-07-27 03:54:42 +03:00
|
|
|
- task: CacheBeta@0
|
|
|
|
inputs:
|
|
|
|
key: |
|
|
|
|
vendor
|
|
|
|
$(Agent.OS)
|
|
|
|
$(Build.SourcesDirectory)/go.sum
|
2019-07-27 04:22:36 +03:00
|
|
|
path: $(GOPATH)/src
|
2019-07-27 03:54:42 +03:00
|
|
|
displayName: Cache Vendor Directory
|
2019-07-27 03:37:08 +03:00
|
|
|
|
2019-07-27 04:38:22 +03:00
|
|
|
- script: go test -cover github.com/microsoft/ring-operator/pkg/controller/ring
|
2019-07-29 18:33:14 +03:00
|
|
|
displayName: Run unit tests
|
2019-07-26 21:26:54 +03:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Container Creation
|
|
|
|
######################################################################
|
|
|
|
- job: Containerize
|
2019-07-29 18:33:14 +03:00
|
|
|
displayName: Publish Container
|
2019-07-29 18:30:14 +03:00
|
|
|
container: docker
|
2019-07-27 07:45:29 +03:00
|
|
|
dependsOn: UnitTests
|
2019-07-27 03:17:24 +03:00
|
|
|
variables:
|
2019-07-27 07:42:12 +03:00
|
|
|
OperatorImage: public/k8s/bedrock/ring-operator
|
2019-07-27 07:31:35 +03:00
|
|
|
MyBuildId: $(Build.BuildNumber)
|
2019-07-26 21:26:54 +03:00
|
|
|
steps:
|
2019-07-27 03:56:52 +03:00
|
|
|
- download: current
|
|
|
|
artifact: build
|
2019-07-26 21:26:54 +03:00
|
|
|
|
2019-07-27 04:59:40 +03:00
|
|
|
- script: |
|
2019-07-27 04:59:52 +03:00
|
|
|
rm -rf $(System.DefaultWorkingDirectory)/build/_output
|
2019-07-27 04:59:40 +03:00
|
|
|
mv $(Pipeline.Workspace)/build/_output $(System.DefaultWorkingDirectory)/build
|
2019-07-29 18:33:14 +03:00
|
|
|
displayName: Download build artifact
|
2019-07-27 04:50:20 +03:00
|
|
|
|
2019-07-26 21:26:54 +03:00
|
|
|
- task: Docker@2
|
|
|
|
displayName: Login to Azure Container Registry
|
|
|
|
inputs:
|
|
|
|
command: login
|
2019-07-26 21:41:41 +03:00
|
|
|
azureSubscriptionEndpoint: AzureRM
|
|
|
|
containerRegistry: AzureCR
|
2019-07-27 07:17:02 +03:00
|
|
|
|
2019-07-27 03:45:34 +03:00
|
|
|
- task: Docker@2
|
2019-07-27 07:45:29 +03:00
|
|
|
displayName: Build and Push $(MyBuildId)
|
2019-07-27 07:17:02 +03:00
|
|
|
inputs:
|
|
|
|
command: buildAndPush
|
|
|
|
containerRegistry: AzureCR
|
|
|
|
buildContext: $(System.DefaultWorkingDirectory)
|
|
|
|
Dockerfile: build/Dockerfile
|
|
|
|
repository: $(OperatorImage)
|
2019-07-27 07:31:35 +03:00
|
|
|
tags: $(MyBuildId)
|
2019-07-27 07:17:02 +03:00
|
|
|
|
|
|
|
- task: Docker@2
|
2019-07-27 07:45:29 +03:00
|
|
|
displayName: Build and Push latest
|
2019-07-27 07:17:02 +03:00
|
|
|
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
2019-07-27 03:45:34 +03:00
|
|
|
inputs:
|
|
|
|
command: buildAndPush
|
|
|
|
containerRegistry: AzureCR
|
2019-07-27 07:11:12 +03:00
|
|
|
buildContext: $(System.DefaultWorkingDirectory)
|
2019-07-27 04:46:29 +03:00
|
|
|
Dockerfile: build/Dockerfile
|
2019-07-27 03:45:34 +03:00
|
|
|
repository: $(OperatorImage)
|
2019-07-27 07:41:14 +03:00
|
|
|
tags: latest
|