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 trigger: batch: true paths: exclude: - assets/* - deploy/* name: $(Date:yyyyMMdd)$(Rev:r) variables: skipComponentGovernanceDetection: true 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 displayName: Build project - publish: $(Build.SourcesDirectory)/build artifact: build ###################################################################### # Tests ###################################################################### - job: UnitTests container: golang displayName: 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 displayName: Run unit tests ###################################################################### # Container Creation ###################################################################### - job: Containerize displayName: Publish Container container: docker dependsOn: UnitTests variables: MyBuildId: $(Build.BuildNumber) # Buildah STORAGE_DRIVER: vfs BUILDAH_FORMAT: docker steps: - download: current artifact: build - script: | rm -rf $(System.DefaultWorkingDirectory)/build/_output mv $(Pipeline.Workspace)/build/_output $(System.DefaultWorkingDirectory)/build displayName: Download build artifact - task: AzureCLI@1 displayName: Login to ACR inputs: azureSubscription: AzureRM scriptPath: build/login.sh arguments: $(OperatorRegistry) $(OperatorRepository) - script: buildah bud -f build/Dockerfile -t $(OperatorRegistry)/$(OperatorRepository):$(MyBuildId) displayName: Build and Push $(MyBuildId) - script: buildah bud -f build/Dockerfile -t $(OperatorRegistry)/$(OperatorRepository):$(MyBuildId) displayName: Build and Push latest condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))