From 11cc6bfbc955f7ce16b3b1b19511f7dfb25d249d Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Tue, 18 Dec 2018 16:50:19 -0800 Subject: [PATCH] Migrate PR build to Azure Pipelines --- .vscode/settings.json | 7 +++ .vsts-ci.yml | 51 +++++-------------- appveyor.yml | 34 ------------- azure-pipelines.yml | 27 ++++++++++ inc/build.yml | 43 ++++++++++++++++ nuget.config | 10 ++++ tools/Publish-Release.ps1 | 100 -------------------------------------- 7 files changed, 99 insertions(+), 173 deletions(-) create mode 100644 .vscode/settings.json delete mode 100644 appveyor.yml create mode 100644 azure-pipelines.yml create mode 100644 inc/build.yml create mode 100644 nuget.config delete mode 100644 tools/Publish-Release.ps1 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6cd20d8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "files.associations": { + "inc/build.yml": "azure-pipelines", + ".vsts-ci.yml": "azure-pipelines", + "azure-pipelines.yml": "azure-pipelines" + } +} \ No newline at end of file diff --git a/.vsts-ci.yml b/.vsts-ci.yml index 5ca7e90..cfbf8a7 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -1,3 +1,6 @@ +# Copyright (C) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. See LICENSE.txt in the project root for license information. + queue: name: MicroBuildV2Pool timeoutInMinutes: 120 @@ -6,55 +9,25 @@ queue: - visualstudio - vstest -variables: - solution: '**\*.sln' - steps: -- task: NuGetInstaller@0 - inputs: - solution: $(solution) - versionSpec: 4.1.0 - -- task: MicroBuildSigningPlugin@1 +- task: ms-vseng.MicroBuildTasks.30666190-6959-11e5-9f96-f56098202fef.MicroBuildSigningPlugin@1 + displayName: Install signing plugin inputs: signType: $(SignType) esrpSigning: true -- task: VSBuild@1 - inputs: - solution: $(solution) - vsVersion: 14.0 - configuration: $(BuildConfiguration) - platform: $(BuildPlatform) - maximumCpuCount: true - -- task: VSTest@2 - inputs: - testAssemblyVer2: | - **\*test*.dll - !**\obj\** - searchFolder: $(Build.SourcesDirectory)\bin\$(BuildConfiguration) - vsTestVersion: 14.0 - runInParallel: true - codeCoverageEnabled: true - platform: $(BuildPlatform) - configuration: $(BuildConfiguration) - -- task: CopyFiles@2 - inputs: - SourceFolder: $(Build.SourcesDirectory) - Contents: | - bin\$(BuildConfiguration)\** - tools\** - TargetFolder: $(Build.ArtifactStagingDirectory)\out +- template: inc/build.yml + parameters: + BuildConfiguration: $(BuildConfiguration) + BuildPlatform: $(BuildPlatform) - task: PublishBuildArtifacts@1 + displayName: Publish build inputs: PathtoPublish: $(Build.ArtifactStagingDirectory)\out ArtifactName: drop publishLocation: Container -- task: MicroBuildCleanup@1 +- task: ms-vseng.MicroBuildTasks.521a94ea-9e68-468a-8167-6dcf361ea776.MicroBuildCleanup@1 + displayName: Clean up condition: succeededOrFailed() - -# vim: set ai et st=2 sts=2 sw=2: diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5adaec7..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,34 +0,0 @@ -configuration: - - Debug - - Release - -environment: - TreatWarningsAsErrors: true - -branches: - only: - - master - - develop - -skip_tags: true - -notifications: - - provider: GitHubPullRequest - on_build_success: true - on_build_failure: true - -cache: - - packages -> **\packages.config - -before_build: - - nuget restore - -test: - assemblies: - - '**\bin\$(configuration)\*.test.dll' - -artifacts: - - path: bin\$(configuration) - type: zip - -# vim: set ai et st=2 sts=2 sw=2: diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..2df64d3 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,27 @@ +# Copyright (C) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. See LICENSE.txt in the project root for license information. + +trigger: none + +pr: + branches: + include: + - master + - develop + paths: + exclude: + - CONTRIBUTING.md + - README.md + +pool: + vmImage: vs2017-win2016 + +variables: + BuildConfiguration: Release + BuildPlatform: x86 + +steps: +- template: inc/build.yml + parameters: + BuildConfiguration: $(BuildConfiguration) + BuildPlatform: $(BuildPlatform) diff --git a/inc/build.yml b/inc/build.yml new file mode 100644 index 0000000..4cd2ff2 --- /dev/null +++ b/inc/build.yml @@ -0,0 +1,43 @@ +# Copyright (C) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. See LICENSE.txt in the project root for license information. + +parameters: + BuildConfiguration: Release + BuildPlatform: x86 + TreatWarningsAsErrors: true + +steps: +- task: NuGetToolInstaller@0 + displayName: Install nuget + inputs: + versionSpec: '4.1.0' + +- task: NuGetCommand@2 + displayName: Restore packages + inputs: + restoreSolution: '**\*.sln' + feedsToUse: config + nugetConfigPath: nuget.config + +- task: VSBuild@1 + displayName: Build + inputs: + configuration: ${{ parameters.BuildConfiguration }} + platform: ${{ parameters.BuildPlatform }} + maximumCpuCount: true + +- task: VSTest@2 + displayName: Test + inputs: + configuration: ${{ parameters.BuildConfiguration }} + platform: ${{ parameters.BuildPlatform }} + testAssemblyVer2: | + bin\$(BuildConfiguration)\*.test.dll + runInParallel: true + codeCoverageEnabled: true + +- task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: bin\${{ parameters.BuildConfiguration }} + ArtifactName: drop + publishLocation: Container diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..1bbf58d --- /dev/null +++ b/nuget.config @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tools/Publish-Release.ps1 b/tools/Publish-Release.ps1 deleted file mode 100644 index 945103c..0000000 --- a/tools/Publish-Release.ps1 +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright (C) Microsoft Corporation. All rights reserved. -# Licensed under the MIT license. See LICENSE.txt in the project root for license information. - -[CmdletBinding()] -param ( - [Parameter(Mandatory = $true)] - [string] $Token, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] $Owner = 'Microsoft', - - [Parameter(Mandatory = $true)] - [string] $Repository, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] $Tag = $env:BUILD_BUILDNUMBER, - - [Parameter()] - [string] $Commit = $env:BUILD_SOURCEVERSION, - - [Parameter()] - [string] $Name, - - [Parameter()] - [string] $Description, - - [Parameter()] - [switch] $Draft, - - [Parameter()] - [switch] $Prerelease, - - [Parameter(Mandatory = $true)] - [string] $Path, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] $ContentType = 'application/octet-stream', - - [Parameter()] - [string] $ContentName, - - [Parameter()] - [string] $ContentLabel -) - -$ErrorActionPreference = 'Stop' - -if (-not $Tag) { - throw '$Tag is required (default value not available)' -} - -$uri = "https://api.github.com/repos/$Owner/$Repository/releases" -$values = @{ - tag_name = $Tag - draft = $Draft.ToBool() - prerelease = $Prerelease.ToBool() -} - -if ($Commit) { - $values.target_commitish = $Commit -} - -if ($Name) { - $values.name = $Name -} - -if ($Description) { - $values.body = $Description -} - -$request = ConvertTo-Json $values -$headers = @{ - Authorization = "token $Token" - Accept = 'application/vnd.github.v3+json' -} - -$release = Invoke-RestMethod -Uri $uri -Method Post -Body $request -Headers $headers -$upload_url = $release.upload_url -replace '\{\?.*$', '' - -Write-Verbose "Release '$($release.id)' created; upload URI: $upload_url" - -$Path = Resolve-Path $Path | Convert-Path - -$headers.Add('Content-Type', $ContentType) -if (-not $ContentName) { - $ContentName = [System.IO.Path]::GetFileName($Path) -} - -$uri = $upload_url + "?name=$ContentName" -if ($ContentLabel) { - $uri += "&label=$ContentLabel" -} - -$asset = Invoke-RestMethod -Uri $uri -Method Post -InFile $Path -Headers $headers -if ($asset.state -eq 'uploaded') { - Write-Verbose "Successfully uploaded: $($asset.browser_download_url)" -}