ring-operator/azure-pipelines.yml

94 строки
2.7 KiB
YAML

resources:
containers:
- container: golang
image: devcrewsacr.azurecr.io/operator-sdk-builder:latest
endpoint: AzureCR
- container: docker
image: devcrewsacr.azurecr.io/docker-builder:latest
endpoint: AzureCR
options: '-v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock'
# trigger:
# paths:
# exclude:
# - assets/*
# - deploy/*
name: $(Date:yyyyMMdd)$(Rev:r)
jobs:
######################################################################
# Build
######################################################################
- job: Build
container: golang
displayName: Build Operator
variables:
GOPATH: $(Pipeline.Workspace)/go
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
######################################################################
# Tests
######################################################################
- job: UnitTests
container: golang
displayName: Run unit tests
dependsOn: Build
variables:
GOPATH: $(Pipeline.Workspace)/go
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
######################################################################
# 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)
steps:
- download: current
artifact: build
- script: mv $(Pipeline.Workspace)/build/_output $(System.DefaultWorkingDirectory)/build
- task: Docker@2
displayName: Login to Azure Container Registry
inputs:
command: login
azureSubscriptionEndpoint: AzureRM
containerRegistry: AzureCR
- task: Docker@2
displayName: Build and Push
inputs:
command: buildAndPush
containerRegistry: AzureCR
Dockerfile: build/Dockerfile
repository: $(OperatorImage)
tags: latest