ring-operator/azure-pipelines.yml

108 строки
3.2 KiB
YAML
Исходник Обычный вид История

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
image: devcrewsacr.azurecr.io/docker-builder:latest
2019-07-26 23:58:55 +03:00
endpoint: AzureCR
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'
# trigger:
# paths:
# exclude:
# - assets/*
# - deploy/*
2019-07-26 21:26:54 +03:00
name: $(Date:yyyyMMdd)$(Rev:r)
2019-07-26 23:58:55 +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
variables:
GOPATH: $(Pipeline.Workspace)/go
2019-07-26 21:26:54 +03:00
steps:
- task: CacheBeta@0
inputs:
key: |
vendor
$(Agent.OS)
$(Build.SourcesDirectory)/go.sum
path: $(GOPATH)/src
displayName: Cache Vendor Directory
- script: go build -o build/_output/bin/ring-operator cmd/manager/main.go
- publish: $(Build.SourcesDirectory)/build
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-26 21:26:54 +03:00
displayName: Run unit tests
dependsOn: Build
variables:
GOPATH: $(Pipeline.Workspace)/go
2019-07-26 21:26:54 +03:00
steps:
- task: CacheBeta@0
inputs:
key: |
vendor
$(Agent.OS)
$(Build.SourcesDirectory)/go.sum
path: $(GOPATH)/src
displayName: Cache Vendor Directory
- script: go test -cover github.com/microsoft/ring-operator/pkg/controller/ring
2019-07-26 21:26:54 +03:00
######################################################################
# Container Creation
######################################################################
- job: Containerize
displayName: Build and push container
dependsOn: UnitTests
variables:
OperatorImage: devcrewsacr.azurecr.io/public/k8s/bedrock/ring-operator
MyBuildId: $(Date:yyyyMMdd)$(Rev:r)
2019-07-26 21:26:54 +03:00
steps:
- download: current
artifact: build
2019-07-26 21:26:54 +03:00
- script: |
rm -rf $(System.DefaultWorkingDirectory)/build/_output
mv $(Pipeline.Workspace)/build/_output $(System.DefaultWorkingDirectory)/build
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
- task: Docker@2
displayName: Build and Push
inputs:
command: buildAndPush
containerRegistry: AzureCR
buildContext: $(System.DefaultWorkingDirectory)
Dockerfile: build/Dockerfile
repository: $(OperatorImage)
tags: $(MyBuildId)
- task: Docker@2
displayName: Build and Push Latest
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
command: buildAndPush
containerRegistry: AzureCR
buildContext: $(System.DefaultWorkingDirectory)
Dockerfile: build/Dockerfile
repository: $(OperatorImage)
tags: latest