Skip to content

Commit

Permalink
added Azure Pipelines build system (akkadotnet#3794)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed Jul 26, 2019
1 parent 0fe3ea9 commit b48b1c6
Show file tree
Hide file tree
Showing 9 changed files with 686 additions and 242 deletions.
3 changes: 3 additions & 0 deletions .artifactignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/*
!TestResults/*
!bin/incrementalist.txt
8 changes: 8 additions & 0 deletions build-system/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Azure Pipelines Build Files
These `.yaml` files are used by Windows Azure DevOps Pipelines to help execute the following types of builds:

- Pull request validation on Linux (Mono / .NET Core)
- Pull request validation on Windows (.NET Framework / .NET Core)
- NuGet releases with automatic release notes posted to a Github Release repository.

**NOTE**: you will need to change some of the pipeline variables inside the `windows-release.yaml` for your specific project and you will also want to create variable groups with your signing and NuGet push information.
54 changes: 54 additions & 0 deletions build-system/azure-pipeline.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
parameters:
name: ''
displayName: ''
vmImage: ''
dependsOn: 'WindowsBuild'
artifactName: 'akkaBuild'
scriptFileName: ''
scriptArgs: 'all'
outputDirectory: ''
timeoutInMinutes: 120

jobs:
- job: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
pool:
vmImage: ${{ parameters.vmImage }}
steps:
- task: Bash@3
displayName: Linux / OSX Build
inputs:
filePath: ${{ parameters.scriptFileName }}
arguments: ${{ parameters.scriptArgs }}
continueOnError: true
condition: in( variables['Agent.OS'], 'Linux', 'Darwin' )
# Windows
- task: BatchScript@1
displayName: Windows Build
inputs:
filename: ${{ parameters.scriptFileName }}
arguments: ${{ parameters.scriptArgs }}
continueOnError: true
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- task: PublishTestResults@2
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx' #TestResults folder usually
testRunTitle: ${{ parameters.name }}
mergeTestResults: true
- script: 'echo 1>&2'
failOnStderr: true
displayName: 'If above is partially succeeded, then fail'
condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues')
- task: CopyFiles@2
displayName: 'Copy Build Output'
inputs:
sourceFolder: ${{ parameters.outputDirectory }}
contents: '*'
targetFolder: $(Build.ArtifactStagingDirectory)
continueOnError: boolean # 'true' if future steps should run even if this step fails; defaults to 'false'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: ${{ parameters.name }}
22 changes: 22 additions & 0 deletions build-system/linux-pr-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Pull request validation for Linux against the `dev` and `master` branches
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for reference
trigger:
branches:
include:
- dev
- master

name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

pr:
autoCancel: true # indicates whether additional pushes to a PR should cancel in-progress runs for the same PR. Defaults to true
branches:
include: [ dev, master ] # branch names which will trigger a build

jobs:
- template: azure-pipeline.template.yaml
parameters:
name: Ubuntu
vmImage: 'ubuntu-16.04'
scriptFileName: ./build.sh
scriptArgs: all
103 changes: 103 additions & 0 deletions build-system/pr-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Pull request validation for Windows against the `dev` and `master` branches
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for reference
trigger:
branches:
include:
- dev
- test-dev
- master

pr:
autoCancel: true # indicates whether additional pushes to a PR should cancel in-progress runs for the same PR. Defaults to true
branches:
include: [ dev, test-dev, master ] # branch names which will trigger a build

name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

jobs:
- job: WindowsBuild
displayName: Windows Build
pool:
vmImage: vs2017-win2016
demands: Cmd
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: false # whether to fetch clean each time
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
persistCredentials: true
- task: BatchScript@1
displayName: Windows Build
inputs:
filename: build.cmd
arguments: 'buildRelease incremental' # Run an incremental build
continueOnError: true
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- task: CopyFiles@2
displayName: 'Copy Build Output'
inputs:
sourceFolder: bin
contents: '*'
targetFolder: $(Build.ArtifactStagingDirectory)
continueOnError: boolean # 'true' if future steps should run even if this step fails; defaults to 'false'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: incrementalistOutput
- script: 'echo 1>&2'
failOnStderr: true
displayName: 'If above is partially succeeded, then fail'
condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues')

- template: azure-pipeline.template.yaml
parameters:
name: 'netfx_tests_windows'
displayName: '.NET Framework Unit Tests (Windows)'
vmImage: 'vs2017-win2016'
scriptFileName: build.cmd
scriptArgs: runTests incremental
outputDirectory: 'TestResults'

- template: azure-pipeline.template.yaml
parameters:
name: 'net_core_tests_windows'
displayName: '.NET Core Unit Tests (Windows)'
vmImage: 'vs2017-win2016'
scriptFileName: build.cmd
scriptArgs: runTestsNetCore incremental
outputDirectory: 'TestResults'

- template: azure-pipeline.template.yaml
parameters:
name: 'net_core_tests_linux'
displayName: '.NET Core Unit Tests (Linux)'
vmImage: 'ubuntu-16.04'
scriptFileName: './build.sh'
scriptArgs: runTestsNetCore incremental
outputDirectory: 'TestResults'

- template: azure-pipeline.template.yaml
parameters:
name: 'net_core_mntr_windows'
displayName: '.NET Core Multi-Node Tests (Windows)'
vmImage: 'vs2017-win2016'
scriptFileName: 'build.cmd'
scriptArgs: MultiNodeTestsNetCore incremental
outputDirectory: 'TestResults'

- template: azure-pipeline.template.yaml
parameters:
name: 'net_fx_mntr_windows'
displayName: '.NET Framework Multi-Node Tests (Windows)'
vmImage: 'vs2017-win2016'
scriptFileName: 'build.cmd'
scriptArgs: MultiNodeTests incremental
outputDirectory: 'TestResults'

- template: azure-pipeline.template.yaml
parameters:
name: 'nuget_pack'
displayName: 'NuGet Pack'
vmImage: 'vs2017-win2016'
scriptFileName: build.cmd
scriptArgs: CreateNuget nugetprerelease=dev incremental
outputDirectory: 'bin/nuget'
118 changes: 118 additions & 0 deletions build-system/windows-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Release task for PbLib projects
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for reference
trigger:
branches:
include:
- refs/tags/*

variables:
- name: githubConnectionName
value: releases
- name: projectName
value: lighthouse
- name: githubRepositoryName
value: petabridge/lighthouse
- name: dockerConnectionName
value: PetabridgeDocker

jobs:
- job: publishNetCore
pool:
vmImage: windows-2019
demands: Cmd
steps:
- task: BatchScript@1
displayName: 'dotnet publish'
inputs:
filename: build.cmd
arguments: 'PublishCode'
- task: CopyFiles@2
displayName: 'Copy dotnet publish Output'
inputs:
sourceFolder: src/Lighthouse/bin/Release/netcoreapp2.1/publish/
targetFolder: $(Build.ArtifactStagingDirectory)/bin/Release/netcoreapp2.1/publish/
- task: CopyFiles@2
displayName: 'Copy Dockerfiles'
inputs:
sourceFolder: src/Lighthouse
contents: Dockerfile-*
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: drop
- task: GitHubRelease@0
displayName: 'GitHub release (create)'
inputs:
gitHubConnection: $(githubConnectionName)
repositoryName: $(githubRepositoryName)
title: '$(projectName) v$(Build.SourceBranchName)'
releaseNotesFile: 'RELEASE_NOTES.md'
assets: |
bin\nuget\*.nupkg
- job: linuxImageDeploy
pool:
vmImage: ubuntu-16.04
dependsOn: publishNetCore
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
itemPattern: drop/**
downloadPath: '$(Agent.BuildDirectory)'
- task: Docker@2
displayName: "Login to Docker Hub"
inputs:
command: login
containerRegistry: $(dockerConnectionName)
- task: Docker@2
displayName: Docker Build (Linux)
inputs:
command: buildAndPush
Dockerfile: $(Agent.BuildDirectory)/drop/Dockerfile-linux
repository: petabridge/lighthouse
tags: |
latest
linux-latest
$(Build.SourceBranchName)
$(Build.SourceBranchName)-linux
- task: Docker@2
displayName: Logout of Docker Hub
inputs:
command: logout
containerRegistry: $(dockerConnectionName)

- job: windowsImageDeploy
pool:
vmImage: windows-2019
dependsOn: publishNetCore
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
itemPattern: drop/**
downloadPath: '$(Agent.BuildDirectory)'
- task: Docker@2
displayName: "Login to Docker Hub"
inputs:
command: login
containerRegistry: $(dockerConnectionName)
- task: Docker@2
displayName: Docker Build (Windows)
inputs:
command: buildAndPush
Dockerfile: $(Agent.BuildDirectory)/drop/Dockerfile-windows
repository: petabridge/lighthouse
tags: |
windows-latest
$(Build.SourceBranchName)-nanoserver
- task: Docker@2
displayName: Logout of Docker Hub
inputs:
command: logout
containerRegistry: $(dockerConnectionName)
Loading

0 comments on commit b48b1c6

Please sign in to comment.