-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Migrate AZDO pipeline yaml to latest format.
- Loading branch information
1 parent
a632b87
commit 79e34f2
Showing
1 changed file
with
27 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,339 +34,30 @@ resources: | |
name: nanoframework/nf-tools | ||
endpoint: nanoframework | ||
|
||
jobs: | ||
|
||
############################## | ||
- job: Check_Build_Options | ||
pool: | ||
vmImage: 'windows-latest' | ||
|
||
steps: | ||
|
||
- checkout: self | ||
|
||
# check what changed | ||
- powershell: | | ||
git config --global user.email "nfbot" | ||
git config --global user.name "[email protected]" | ||
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$(GitHubToken)"))))" | ||
if($env:System_PullRequest_PullRequestId -ne $null) | ||
{ | ||
# get files changed in PR, if this is a PR | ||
$commit = Invoke-RestMethod -Uri "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber/files" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET | ||
# filter removed files | ||
$files = $commit.where{$_.status -ne 'removed'} | ||
} | ||
else | ||
{ | ||
# get files changed in the commit, if this is NOT a PR | ||
$commit = Invoke-RestMethod -Uri "https://api.github.com/repos/$env:Build_Repository_Name/commits/$(Build.SourceVersion)" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET | ||
# filter removed files | ||
$files = $commit.files.where{$_.status -ne 'removed'} | ||
} | ||
# get file names only | ||
$files = $files | % {$_.filename} | ||
Write-host "Files changed:" | ||
$files | % { Write-host $_ } | ||
Write-host "" | ||
# set default values | ||
echo "##vso[task.setvariable variable=BUILD_NANO_LIB;isOutput=true]false" | ||
echo "##vso[task.setvariable variable=BUILD_HELPER;isOutput=true]false" | ||
if( (($files.where{$_.Contains('nanoFramework.Serialization.Helper')}).Count -gt 0) -or (($files.where{$_.Contains('Serialization.Shared')}).Count -gt 0) -or (($files.where{$_.Contains('Tests/HelperTests')}).Count -gt 0) -or (($files.where{$_.Contains('Tests/UnitTests.Shared')}).Count -gt 0)) | ||
{ | ||
# files at nanoFramework.Serialization.Helper or shared folder | ||
echo "##vso[task.setvariable variable=BUILD_HELPER;isOutput=true]true" | ||
Write-host "Building Helper Library " | ||
} | ||
if( (($files.where{$_.Contains('nanoFramework.System.Runtime.Serialization')}).Count -gt 0) -or (($files.where{$_.Contains('Serialization.Shared')}).Count -gt 0) -or (($files.where{$_.Contains('Tests/SerializationTests')}).Count -gt 0) -or (($files.where{$_.Contains('Tests/UnitTests.Shared')}).Count -gt 0)) | ||
{ | ||
# files at class lib or shared folder | ||
echo "##vso[task.setvariable variable=BUILD_NANO_LIB;isOutput=true]true" | ||
Write-host "Building nano Library" | ||
} | ||
name: TargetsToBuild | ||
displayName: Check what to build | ||
condition: >- | ||
and( | ||
eq(variables['BUILD_HELPER__'], 'false'), | ||
eq(variables['BUILD_NANO_LIB__'], 'false') | ||
) | ||
############## | ||
- job: Build_Helper | ||
condition: >- | ||
or( | ||
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_HELPER'], true), | ||
eq(variables['BUILD_HELPER__'], 'true') | ||
) | ||
dependsOn: | ||
Check_Build_Options | ||
|
||
pool: | ||
vmImage: 'windows-latest' | ||
|
||
variables: | ||
DOTNET_NOLOGO: true | ||
BuildPlatform: 'Any CPU' | ||
BuildConfiguration: 'Release' | ||
|
||
steps: | ||
|
||
- checkout: self | ||
|
||
- task: DotNetCoreCLI@2 | ||
displayName: Restore NuGet packages | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
inputs: | ||
command: restore | ||
verbosityRestore: minimal | ||
projects: $(System.DefaultWorkingDirectory)/nanoFramework.Serialization.Helper.sln | ||
feedsToUse: 'select' | ||
|
||
- task: SonarCloudPrepare@1 | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
displayName: 'Prepare analysis on SonarCloud' | ||
inputs: | ||
SonarCloud: 'sonarcloud-$(System.TeamProject)' | ||
organization: 'nanoframework' | ||
scannerMode: 'MSBuild' | ||
projectKey: 'nanoframework_System.Runtime.Serialization.Helper' | ||
extraProperties: | | ||
sonar.exclusions=**/obj/**,**/*.dll | ||
sonar.cs.vscoveragexml.reportsPaths=$(Agent.TempDirectory)/**/**.coverage | ||
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/**.trx | ||
- task: VSBuild@1 | ||
displayName: Build solution | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
inputs: | ||
solution: $(System.DefaultWorkingDirectory)/nanoFramework.Serialization.Helper.sln | ||
platform: '$(BuildPlatform)' | ||
configuration: '$(BuildConfiguration)' | ||
msbuildArgs: '/p:PublicRelease=true' | ||
maximumCpuCount: true | ||
|
||
- task: CopyFiles@1 | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
displayName: Collecting deployable artifacts | ||
inputs: | ||
sourceFolder: $(System.DefaultWorkingDirectory)/nanoFramework.Serialization.Helper/bin/Release | ||
Contents: | | ||
*.nupkg | ||
*.snupkg | ||
TargetFolder: '$(Build.ArtifactStagingDirectory)' | ||
flattenFolders: true | ||
|
||
- task: VisualStudioTestPlatformInstaller@1 | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
displayName: 'Visual Studio Test Platform Installer' | ||
inputs: | ||
versionSelector: latestStable | ||
|
||
- task: VSTest@2 | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
displayName: 'Running Unit Tests' | ||
continueOnError: false | ||
inputs: | ||
testSelector: 'testAssemblies' | ||
testAssemblyVer2: | | ||
**\*Tests*.dll | ||
!**\obj\** | ||
searchFolder: '$(System.DefaultWorkingDirectory)/Tests/HelperTests' | ||
platform: '$(BuildPlatform)' | ||
configuration: '$(BuildConfiguration)' | ||
diagnosticsEnabled: true | ||
vsTestVersion: toolsInstaller | ||
codeCoverageEnabled: true | ||
runSettingsFile: '$(System.DefaultWorkingDirectory)/helper.runsettings' | ||
|
||
- task: SonarCloudAnalyze@1 | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
displayName: 'Run Code Analysis' | ||
continueOnError: true | ||
|
||
- task: SonarCloudPublish@1 | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
displayName: 'Publish Quality Gate Result' | ||
continueOnError: true | ||
|
||
- task: DotNetCoreCLI@2 | ||
displayName: Install SignTool tool | ||
condition: >- | ||
and( | ||
succeeded(), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
inputs: | ||
command: custom | ||
custom: tool | ||
arguments: install --tool-path . SignClient | ||
|
||
- pwsh: | | ||
.\SignClient "Sign" ` | ||
--baseDirectory "$(Build.ArtifactStagingDirectory)" ` | ||
--input "**/*.nupkg" ` | ||
--config "$(Build.Repository.LocalPath)\config\SignClient.json" ` | ||
--filelist "$(Build.Repository.LocalPath)\config\filelist.txt" ` | ||
--user "$(SignClientUser)" ` | ||
--secret '$(SignClientSecret)' ` | ||
--name "Binary Formatter Helper" ` | ||
--description "Binary Formatter Helper" ` | ||
--descriptionUrl "https://github.com/$env:Build_Repository_Name" | ||
displayName: Sign packages | ||
continueOnError: true | ||
condition: >- | ||
and( | ||
succeeded(), | ||
eq(variables['System.PullRequest.PullRequestId'], ''), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
- task: PublishBuildArtifacts@1 | ||
displayName: Publish deployables artifacts | ||
condition: >- | ||
and( | ||
succeeded(), | ||
eq(variables['System.PullRequest.PullRequestId'], ''), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
inputs: | ||
PathtoPublish: '$(Build.ArtifactStagingDirectory)' | ||
ArtifactName: deployables | ||
ArtifactType: Container | ||
|
||
- task: NuGetCommand@2 | ||
condition: >- | ||
and( | ||
succeeded(), | ||
eq(variables['System.PullRequest.PullRequestId'], ''), | ||
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) | ||
) | ||
continueOnError: true | ||
displayName: Push NuGet packages to NuGet | ||
inputs: | ||
command: push | ||
nuGetFeedType: external | ||
allowPackageConflicts: true | ||
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg' | ||
includeSymbols: true | ||
publishFeedCredentials: 'NuGet-$(System.TeamProject)' | ||
|
||
- task: GithubRelease@1 | ||
condition: >- | ||
and( | ||
succeeded(), | ||
eq(variables['System.PullRequest.PullRequestId'], ''), | ||
startsWith(variables['Build.SourceBranch'], 'refs/heads/main'), | ||
not(contains(variables['Build.SourceBranch'], 'preview')) | ||
) | ||
displayName: Create/Update GitHub release | ||
inputs: | ||
action: edit | ||
gitHubConnection: 'github.com_nano-$(System.TeamProject)' | ||
tagSource: userSpecifiedTag | ||
tag: v$(NBGV_NUGETPACKAGEVERSION) | ||
title: '.NET nanoFramework Binary Formatter Helper v$(NBGV_NUGETPACKAGEVERSION)' | ||
assets: '$(Build.ArtifactStagingDirectory)/*.nupkg' | ||
isPreRelease: false | ||
addChangeLog: true | ||
|
||
############## | ||
- job: Build_ClassLib | ||
condition: >- | ||
or( | ||
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_NANO_LIB'], true), | ||
eq(variables['BUILD_NANO_LIB__'], 'true') | ||
) | ||
dependsOn: | ||
Check_Build_Options | ||
|
||
pool: | ||
vmImage: 'windows-latest' | ||
|
||
variables: | ||
DOTNET_NOLOGO: true | ||
solution: 'nanoFramework.System.Runtime.Serialization.sln' | ||
buildPlatform: 'Any CPU' | ||
buildConfiguration: 'Release' | ||
nugetPackageName: 'nanoFramework.System.Runtime.Serialization' | ||
nugetConfigPath: '$(System.DefaultWorkingDirectory)/NuGet.Config' | ||
|
||
steps: | ||
|
||
# step from template @ nf-tools repo | ||
# all build, update and publish steps | ||
- template: azure-pipelines-templates/class-lib-build.yml@templates | ||
parameters: | ||
sonarCloudProject: 'nanoframework_System.Runtime.Serialization' | ||
|
||
################################## | ||
# report build failure to Discord | ||
- job: Report_Build_Failure | ||
dependsOn: | ||
- Build_Helper | ||
- Build_ClassLib | ||
condition: >- | ||
or( | ||
failed('Build_Helper'), | ||
failed('Build_ClassLib') | ||
) | ||
pool: | ||
vmImage: 'windows-latest' | ||
|
||
steps: | ||
|
||
- checkout: self | ||
fetchDepth: 1 | ||
|
||
# step from template @ nf-tools repo | ||
- template: azure-pipelines-templates/discord-webhook.yml@templates | ||
parameters: | ||
status: 'failure' | ||
webhookUrl: '$(DiscordWebhook)' | ||
message: '' | ||
pool: | ||
vmImage: 'windows-latest' | ||
|
||
variables: | ||
DOTNET_NOLOGO: true | ||
solution: 'nanoFramework.System.Runtime.Serialization.sln' | ||
buildPlatform: 'Any CPU' | ||
buildConfiguration: 'Release' | ||
nugetPackageName: 'nanoFramework.System.Runtime.Serialization' | ||
|
||
steps: | ||
|
||
# step from template @ nf-tools repo | ||
# all build, update and publish steps | ||
- template: azure-pipelines-templates/class-lib-build.yml@templates | ||
parameters: | ||
sonarCloudProject: 'nanoframework_System.Runtime.Serialization' | ||
runUnitTests: true | ||
unitTestRunsettings: '$(System.DefaultWorkingDirectory)\.runsettings' | ||
|
||
# step from template @ nf-tools repo | ||
# report error | ||
- template: azure-pipelines-templates/discord-webhook-task.yml@templates | ||
parameters: | ||
status: 'failure' | ||
webhookUrl: '$(DiscordWebhook)' | ||
message: '' |