ring-operator/azure-pipelines.yml

104 строки
3.0 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
2019-07-30 00:26:11 +03:00
image: devcrewsacr.azurecr.io/docker-builder:latest
endpoint: AzureCR
2019-07-26 21:26:54 +03:00
trigger:
batch: true
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-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
2019-07-29 18:34:23 +03:00
displayName: Build project
- 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-29 18:33:14 +03:00
displayName: Unit Tests
2019-07-26 21:26:54 +03:00
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-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
dependsOn: UnitTests
variables:
MyBuildId: $(Build.BuildNumber)
2019-07-29 19:16:25 +03:00
# Buildah
STORAGE_DRIVER: vfs
BUILDAH_FORMAT: docker
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-29 18:33:14 +03:00
displayName: Download build artifact
2019-07-30 00:05:42 +03:00
- task: AzureCLI@1
displayName: Login to ACR
2019-07-26 21:26:54 +03:00
inputs:
2019-07-30 00:05:42 +03:00
azureSubscription: AzureRM
scriptPath: build/login.sh
2019-07-30 00:15:56 +03:00
arguments: $(OperatorRegistry) $(OperatorRepository)
2019-07-30 00:05:42 +03:00
2019-07-30 00:15:56 +03:00
- script: buildah bud -f build/Dockerfile -t $(OperatorRegistry)/$(OperatorRepository):$(MyBuildId)
2019-07-30 00:05:42 +03:00
displayName: Build and Push $(MyBuildId)
2019-07-30 00:15:56 +03:00
- script: buildah bud -f build/Dockerfile -t $(OperatorRegistry)/$(OperatorRepository):$(MyBuildId)
2019-07-30 00:05:42 +03:00
displayName: Build and Push latest
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))