Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split release pipeline into stages #727

Merged
merged 1 commit into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ These are assets used by the CI build.

Our pipeline is broken into a few discrete builds so that we can control how and when they are triggered:

* **azure-pipelines.release.yml**: Validates canary and tag releases.
* **azure-pipelines.release.yml**: Validates canary and tag releases. This can be tested in a pull request
using `/azp run porter-release` though steps that require credentials will fail.
* **azure-pipelines.install.yml**: Validates our install scripts against canary and tag releases.
* **azure-pipelines.pr-automatic.yml**: Validates everything we can without a live environment.
* **azure-pipelines.pr-manual.yml**: Validates a pull request using a live environment. Requires manual triggering using `/azp run porter-integration` by a maintainer because this accesses secrets in the environment, e.g. kubeconfig. We don't want this accessible to anyone who submits a PR without a code review first.
* **azure-pipelines.pr-manual.yml**: Validates a pull request using a live environment. Requires manual triggering
using `/azp run porter-integration` by a maintainer because this accesses secrets in the environment,
e.g. kubeconfig. We don't want this accessible to anyone who submits a PR without a code review first.

178 changes: 110 additions & 68 deletions build/azure-pipelines.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go

pr: none
trigger:
branches:
include:
Expand All @@ -14,72 +13,115 @@ pool:
vmImage: 'Ubuntu 16.04'

variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

steps:
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'

- task: Docker@1
displayName: Login
inputs:
containerRegistryType: Container Registry
dockerRegistryEndpoint: deislabs-registry
command: login

- task: DownloadSecureFile@1
inputs:
secureFile: kubeconfig

- script: |
make verify
workingDirectory: '$(modulePath)'
displayName: 'Verify'

- script: |
make build
workingDirectory: '$(modulePath)'
displayName: 'Build'

- script: |
make test-unit
workingDirectory: '$(modulePath)'
displayName: 'Unit Test'

- script: |
make xbuild-all
workingDirectory: '$(modulePath)'
displayName: 'Cross Compile'

- script: |
export KUBECONFIG=$DOWNLOADSECUREFILE_SECUREFILEPATH
make test-integration
workingDirectory: '$(modulePath)'
displayName: 'Integration Test'

- script: |
export KUBECONFIG=$DOWNLOADSECUREFILE_SECUREFILEPATH
REGISTRY=deislabs make test-cli
workingDirectory: '$(modulePath)'
displayName: 'CLI Test'

- script: |
sudo make ajv
make build-bundle validate-bundle publish-bundle
workingDirectory: '$(modulePath)'
displayName: 'Publish Example Bundles'

- script: |
AZURE_STORAGE_CONNECTION_STRING=$(AZURE_STORAGE_CONNECTION_STRING) make publish
workingDirectory: '$(modulePath)'
displayName: 'Publish'
GOBIN: '$(GOPATH)/bin' # Go binaries path
MODULE_PATH: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

stages:
- stage: Test
jobs:
- job: unit_test
steps:
- script: build/azure-pipelines.setup-go-workspace.sh
displayName: 'Set up the Go workspace'

- script: make verify
workingDirectory: '$(MODULE_PATH)'
displayName: 'Verify'

- script: make test-unit
workingDirectory: '$(MODULE_PATH)'
displayName: 'Unit Test'

- job: integration_test
steps:
- script: build/azure-pipelines.setup-go-workspace.sh
displayName: 'Set up the Go workspace'

- task: Docker@1
displayName: Docker Login
inputs:
containerRegistryType: Container Registry
dockerRegistryEndpoint: deislabs-registry
command: login

- task: DownloadSecureFile@1
displayName: Download Kubeconfig
inputs:
secureFile: kubeconfig

- script: |
export KUBECONFIG=$DOWNLOADSECUREFILE_SECUREFILEPATH
make test-integration
workingDirectory: '$(MODULE_PATH)'
displayName: 'Integration Test'

- job: cli_test
steps:
- script: build/azure-pipelines.setup-go-workspace.sh
displayName: 'Set up the Go workspace'

- task: Docker@1
displayName: Docker Login
inputs:
containerRegistryType: Container Registry
dockerRegistryEndpoint: deislabs-registry
command: login

- task: DownloadSecureFile@1
displayName: Download Kubeconfig
inputs:
secureFile: kubeconfig

- script: make build
workingDirectory: '$(MODULE_PATH)'
displayName: 'Build'

- script: |
export KUBECONFIG=$DOWNLOADSECUREFILE_SECUREFILEPATH
export REGISTRY=deislabs
make test-cli
workingDirectory: '$(MODULE_PATH)'
displayName: 'CLI Test'

- stage: Publish
jobs:
- job: publish_binaries
steps:
- script: build/azure-pipelines.setup-go-workspace.sh
displayName: 'Set up the Go workspace'

- script: make xbuild-all
workingDirectory: '$(MODULE_PATH)'
displayName: 'Cross Compile'

- script: |
export AZURE_STORAGE_CONNECTION_STRING=$(AZURE_STORAGE_CONNECTION_STRING)
make publish
workingDirectory: '$(MODULE_PATH)'
condition: and(and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')),eq(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: 'Publish Porter Binaries'

- job: publish_example_bundles
steps:
- script: build/azure-pipelines.setup-go-workspace.sh
displayName: 'Set up the Go workspace'

- script: |
sudo make ajv
make build build-bundle validate-bundle
workingDirectory: '$(MODULE_PATH)'
displayName: 'Validate Example Bundles'

- task: Docker@1
displayName: Docker Login
inputs:
containerRegistryType: Container Registry
dockerRegistryEndpoint: deislabs-registry
command: login

- script: publish-bundle
workingDirectory: '$(MODULE_PATH)'
condition: and(and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')),eq(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: 'Publish Example Bundles'