2022-02-18 01:53:19 +03:00
|
|
|
# Copyright (c) .NET Foundation and Contributors
|
|
|
|
# See LICENSE file in the project root for full license information.
|
|
|
|
|
2021-02-25 20:58:22 +03:00
|
|
|
trigger:
|
|
|
|
branches:
|
2022-02-03 12:29:38 +03:00
|
|
|
include:
|
|
|
|
- main
|
|
|
|
- develop
|
|
|
|
- release-*
|
2021-02-25 20:58:22 +03:00
|
|
|
paths:
|
2022-02-03 12:29:38 +03:00
|
|
|
exclude:
|
2022-02-18 01:53:19 +03:00
|
|
|
- .github_changelog_generator
|
2022-02-03 12:29:38 +03:00
|
|
|
- .gitignore
|
2022-02-18 01:53:19 +03:00
|
|
|
- CHANGELOG.md
|
|
|
|
- CODE_OF_CONDUCT.md
|
2022-02-03 12:29:38 +03:00
|
|
|
- LICENSE.md
|
|
|
|
- README.md
|
|
|
|
- NuGet.Config
|
2022-02-18 01:53:19 +03:00
|
|
|
- assets/*
|
|
|
|
- config/*
|
|
|
|
- .github/*
|
2022-10-28 13:21:38 +03:00
|
|
|
|
2021-02-25 20:58:22 +03:00
|
|
|
# PR always trigger build
|
2021-11-24 23:09:08 +03:00
|
|
|
pr:
|
|
|
|
autoCancel: true
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
# add nf-tools repo to resources (for Azure Pipelines templates)
|
|
|
|
resources:
|
|
|
|
repositories:
|
|
|
|
- repository: templates
|
|
|
|
type: github
|
|
|
|
name: nanoframework/nf-tools
|
|
|
|
endpoint: nanoframework
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
##############################
|
|
|
|
- job: Get_Build_Flags
|
|
|
|
pool:
|
2022-02-03 12:29:38 +03:00
|
|
|
vmImage: 'windows-latest'
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- checkout: self
|
|
|
|
fetchDepth: 1
|
|
|
|
|
|
|
|
# get commit message
|
|
|
|
- powershell: |
|
|
|
|
|
|
|
|
# default to false
|
|
|
|
$update = $false
|
|
|
|
|
|
|
|
if($env:Build_Reason -eq 'PullRequest')
|
|
|
|
{
|
|
|
|
# PR build, nothing interesting in commit message
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# build is not from a PR
|
|
|
|
|
|
|
|
# get commit ID
|
|
|
|
$commitId = git rev-parse HEAD
|
|
|
|
|
|
|
|
# get PR associate with commit
|
|
|
|
$prUrl = "https://api.github.com/repos/nanoframework/nanoFramework.TestFramework/commits/$commitId/pulls"
|
|
|
|
$commit = Invoke-RestMethod -Uri $prUrl -ContentType "application/json" -Headers @{"Accept"="application/vnd.github.groot-preview+json"} -Method GET
|
|
|
|
|
|
|
|
if($commit -ne $null)
|
|
|
|
{
|
|
|
|
# there is a PR, check labels
|
|
|
|
$updateDependents = $commit.labels | where {$_.Name -eq 'CI: Update Dependents'}
|
|
|
|
if($updateDependents -ne $null)
|
|
|
|
{
|
|
|
|
$update = $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# set variable to foward to jobs
|
|
|
|
echo "##vso[task.setvariable variable=RUN_UPDATE_DEPENDENTS;isOutput=true]$update"
|
|
|
|
name: GetPRLabels
|
|
|
|
displayName: Check build labels
|
|
|
|
|
|
|
|
#########################################################
|
|
|
|
# build
|
|
|
|
- job: Build_Test_Framework
|
2023-04-03 16:04:52 +03:00
|
|
|
condition: eq(variables['UPDATE_DEPENDENTS'], 'false')
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
dependsOn:
|
|
|
|
- Get_Build_Flags
|
|
|
|
|
|
|
|
pool:
|
2022-02-03 12:29:38 +03:00
|
|
|
vmImage: 'windows-latest'
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
variables:
|
2024-01-29 18:23:52 +03:00
|
|
|
- group: sign-client-credentials
|
|
|
|
- name: DOTNET_NOLOGO
|
|
|
|
value: true
|
|
|
|
- name: buildPlatform
|
|
|
|
value: 'Any CPU'
|
|
|
|
- name: buildConfiguration
|
|
|
|
value: 'Release'
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- checkout: self
|
|
|
|
|
|
|
|
- script: |
|
|
|
|
git config --global user.email "nanoframework@outlook.com"
|
|
|
|
git config --global user.name "nfbot"
|
|
|
|
displayName: Setup git identity
|
|
|
|
|
2021-06-01 13:39:50 +03:00
|
|
|
- template: azure-pipelines-templates/install-nuget.yml@templates
|
2021-02-25 20:58:22 +03:00
|
|
|
|
2022-11-07 13:09:36 +03:00
|
|
|
- task: InstallNanoMSBuildComponents@1
|
2021-02-25 20:58:22 +03:00
|
|
|
condition: ne( variables['StartReleaseCandidate'], true )
|
|
|
|
displayName: Install nanoFramework MSBuild components
|
2022-03-18 03:13:34 +03:00
|
|
|
|
2022-10-29 11:24:04 +03:00
|
|
|
- task: Cache@2
|
|
|
|
displayName: Cache NuGet packages
|
|
|
|
condition: >-
|
|
|
|
and(
|
|
|
|
succeeded(),
|
2023-04-03 14:33:36 +03:00
|
|
|
eq(variables['StartReleaseCandidate'], false)
|
2022-10-29 11:24:04 +03:00
|
|
|
)
|
|
|
|
continueOnError: true
|
|
|
|
inputs:
|
|
|
|
key: 'nuget | **/packages.lock.json'
|
|
|
|
path: $(UserProfile)/.nuget/packages
|
|
|
|
|
2021-02-25 20:58:22 +03:00
|
|
|
- task: NuGetCommand@2
|
|
|
|
displayName: NuGet restore Test Adapter
|
2022-12-22 18:17:46 +03:00
|
|
|
condition: succeeded()
|
2022-10-29 11:04:54 +03:00
|
|
|
retryCountOnTaskFailure: 2
|
2021-02-25 20:58:22 +03:00
|
|
|
inputs:
|
|
|
|
restoreSolution: 'nanoFramework.TestAdapter.sln'
|
|
|
|
feedsToUse: config
|
|
|
|
nugetConfigPath: 'NuGet.config'
|
|
|
|
|
|
|
|
- task: NuGetCommand@2
|
|
|
|
displayName: NuGet restore Test Framework
|
2022-12-22 18:17:46 +03:00
|
|
|
condition: succeeded()
|
2022-10-29 11:04:54 +03:00
|
|
|
retryCountOnTaskFailure: 2
|
2021-02-25 20:58:22 +03:00
|
|
|
inputs:
|
|
|
|
restoreSolution: 'nanoFramework.TestFramework.sln'
|
|
|
|
feedsToUse: config
|
|
|
|
nugetConfigPath: 'NuGet.config'
|
|
|
|
|
|
|
|
- task: VSBuild@1
|
|
|
|
displayName: Build Test Adapter
|
2022-12-22 18:17:46 +03:00
|
|
|
condition: succeeded()
|
2021-02-25 20:58:22 +03:00
|
|
|
inputs:
|
|
|
|
solution: 'nanoFramework.TestAdapter.sln'
|
|
|
|
platform: '$(buildPlatform)'
|
|
|
|
msbuildArgs: '/p:PublicRelease=true'
|
|
|
|
configuration: '$(buildConfiguration)'
|
|
|
|
|
|
|
|
- task: VSBuild@1
|
|
|
|
displayName: Build Test Framework
|
2022-12-22 18:17:46 +03:00
|
|
|
condition: succeeded()
|
2021-02-25 20:58:22 +03:00
|
|
|
inputs:
|
|
|
|
solution: 'nanoFramework.TestFramework.sln'
|
|
|
|
platform: '$(buildPlatform)'
|
|
|
|
msbuildArgs: '/p:PublicRelease=true'
|
2021-06-07 20:10:19 +03:00
|
|
|
configuration: '$(buildConfiguration)'
|
2022-03-30 15:02:34 +03:00
|
|
|
msbuildArchitecture: 'x64'
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
# - task: VisualStudioTestPlatformInstaller@1
|
|
|
|
# condition: succeeded()
|
|
|
|
# displayName: 'Visual Studio Test Platform Installer'
|
|
|
|
# inputs:
|
|
|
|
# versionSelector: latestStable
|
|
|
|
|
|
|
|
# - task: VSTest@2
|
|
|
|
# condition: succeeded()
|
|
|
|
# displayName: 'Running tests'
|
|
|
|
# inputs:
|
|
|
|
# testSelector: 'testAssemblies'
|
|
|
|
# testAssemblyVer2: |
|
|
|
|
# **\*Tests*.dll
|
|
|
|
# !**\*TestAdapter*.dll
|
|
|
|
# !**\*TestFramework*.dll
|
|
|
|
# !**\obj\**
|
|
|
|
# searchFolder: '$(System.DefaultWorkingDirectory)'
|
|
|
|
# platform: '$(BuildPlatform)'
|
|
|
|
# configuration: '$(BuildConfiguration)'
|
|
|
|
# diagnosticsEnabled: true
|
|
|
|
# vsTestVersion: toolsInstaller
|
|
|
|
# codeCoverageEnabled: true
|
|
|
|
|
|
|
|
# update could build number (only possible if this is not a PR from a fork)
|
|
|
|
- task: PowerShell@2
|
2022-05-13 09:35:21 +03:00
|
|
|
condition: succeeded()
|
2021-02-25 20:58:22 +03:00
|
|
|
displayName: Update cloud build number
|
|
|
|
inputs:
|
|
|
|
targetType: 'inline'
|
|
|
|
script: Write-Host "$("##vso[build.updatebuildnumber]")$env:NBGV_NuGetPackageVersion"
|
|
|
|
|
|
|
|
- task: NuGetCommand@2
|
|
|
|
condition: succeeded()
|
|
|
|
displayName: Pack NuGet with Test Framework
|
|
|
|
inputs:
|
|
|
|
command: 'custom'
|
|
|
|
arguments: 'pack source\package.nuspec -Version $(NBGV_NuGetPackageVersion) -properties commit="$(Build.SourceVersion)"'
|
|
|
|
|
|
|
|
- task: CopyFiles@1
|
|
|
|
condition: succeeded()
|
|
|
|
displayName: Collecting NuGet package artifact
|
|
|
|
inputs:
|
|
|
|
sourceFolder: $(Build.SourcesDirectory)
|
|
|
|
Contents: |
|
|
|
|
**\nanoFramework.TestFramework*.nupkg
|
|
|
|
TargetFolder: '$(Build.ArtifactStagingDirectory)'
|
|
|
|
flattenFolders: true
|
|
|
|
|
|
|
|
- task: DotNetCoreCLI@2
|
|
|
|
displayName: Install SignTool tool
|
2022-12-22 18:17:46 +03:00
|
|
|
condition: >-
|
|
|
|
and(
|
|
|
|
succeeded(),
|
|
|
|
eq(variables['System.PullRequest.PullRequestId'], '')
|
|
|
|
)
|
2021-02-25 20:58:22 +03:00
|
|
|
inputs:
|
|
|
|
command: custom
|
|
|
|
custom: tool
|
2024-01-29 18:23:52 +03:00
|
|
|
arguments: install --tool-path . sign --version 0.9.1-beta.23530.1
|
|
|
|
|
2024-03-20 14:25:04 +03:00
|
|
|
- pwsh: |
|
|
|
|
.\sign code azure-key-vault `
|
|
|
|
"**/*.nupkg" `
|
|
|
|
--base-directory "$(Build.ArtifactStagingDirectory)" `
|
|
|
|
--file-list "$(Build.Repository.LocalPath)\config\filelist.txt" `
|
2024-03-21 04:43:06 +03:00
|
|
|
--description "Test Framework" `
|
2024-03-20 14:25:04 +03:00
|
|
|
--description-url "https://github.com/$env:Build_Repository_Name" `
|
|
|
|
--azure-key-vault-tenant-id "$(SignTenantId)" `
|
|
|
|
--azure-key-vault-client-id "$(SignClientId)" `
|
|
|
|
--azure-key-vault-client-secret "$(SignClientSecret)" `
|
|
|
|
--azure-key-vault-certificate "$(SignKeyVaultCertificate)" `
|
|
|
|
--azure-key-vault-url "$(SignKeyVaultUrl)" `
|
|
|
|
--timestamp-url http://timestamp.digicert.com
|
|
|
|
displayName: Sign packages
|
|
|
|
continueOnError: true
|
|
|
|
condition: >-
|
|
|
|
and(
|
|
|
|
succeeded(),
|
|
|
|
eq(variables['System.PullRequest.PullRequestId'], '')
|
|
|
|
)
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
# publish artifacts (only possible if this is not a PR originated on a fork)
|
|
|
|
- task: PublishBuildArtifacts@1
|
2022-12-22 18:17:46 +03:00
|
|
|
condition: >-
|
|
|
|
and(
|
|
|
|
succeeded(),
|
|
|
|
ne(variables['system.pullrequest.isfork'], true)
|
|
|
|
)
|
2021-02-25 20:58:22 +03:00
|
|
|
displayName: Publish deployables artifacts
|
|
|
|
inputs:
|
|
|
|
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
|
|
|
ArtifactName: deployables
|
|
|
|
ArtifactType: Container
|
|
|
|
|
|
|
|
# push NuGet packages to Azure Artifacts feed (always happens except on PR builds)
|
|
|
|
- task: NuGetCommand@2
|
|
|
|
displayName: Push NuGet packages to Azure Artifacts
|
2022-12-22 18:17:46 +03:00
|
|
|
condition: >-
|
|
|
|
and(
|
|
|
|
succeeded(),
|
|
|
|
eq(variables['System.PullRequest.PullRequestId'], '')
|
|
|
|
)
|
2021-02-25 20:58:22 +03:00
|
|
|
continueOnError: true
|
|
|
|
inputs:
|
|
|
|
command: push
|
|
|
|
nuGetFeedType: external
|
|
|
|
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
|
|
|
|
publishFeedCredentials: 'AzureArtifacts-$(System.TeamProject)'
|
|
|
|
allowPackageConflicts: true
|
|
|
|
|
|
|
|
# push NuGet class lib package to NuGet (always happens except on PR builds)
|
|
|
|
- task: NuGetCommand@2
|
2022-12-22 18:17:46 +03:00
|
|
|
condition: >-
|
|
|
|
and(
|
|
|
|
succeeded(),
|
|
|
|
eq(variables['System.PullRequest.PullRequestId'], '')
|
|
|
|
)
|
2021-02-25 20:58:22 +03:00
|
|
|
continueOnError: true
|
|
|
|
displayName: Push NuGet packages to NuGet
|
|
|
|
inputs:
|
|
|
|
command: push
|
|
|
|
nuGetFeedType: external
|
|
|
|
allowPackageConflicts: true
|
|
|
|
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
|
|
|
|
publishFeedCredentials: 'NuGet-$(System.TeamProject)'
|
|
|
|
|
2022-05-11 17:08:26 +03:00
|
|
|
# create or update GitHub release
|
2022-02-03 12:29:38 +03:00
|
|
|
- task: GithubRelease@1
|
|
|
|
condition: >-
|
|
|
|
and(
|
|
|
|
succeeded(),
|
|
|
|
eq(variables['System.PullRequest.PullRequestId'], ''),
|
2022-05-27 15:45:30 +03:00
|
|
|
startsWith(variables['Build.SourceBranch'], 'refs/heads/main'),
|
2022-05-11 17:08:26 +03:00
|
|
|
eq(variables['UPDATE_DEPENDENTS'], 'false')
|
2022-02-03 12:29:38 +03:00
|
|
|
)
|
2022-05-11 17:08:26 +03:00
|
|
|
displayName: Create/Update GitHub release
|
2022-02-03 12:29:38 +03:00
|
|
|
inputs:
|
|
|
|
action: edit
|
|
|
|
gitHubConnection: 'github.com_nano-$(System.TeamProject)'
|
|
|
|
tagSource: userSpecifiedTag
|
2022-05-27 15:45:30 +03:00
|
|
|
tag: v$(NBGV_NuGetPackageVersion)
|
|
|
|
title: '.NET nanoFramework Unit Test Framework v$(NBGV_NuGetPackageVersion)'
|
2022-02-03 12:29:38 +03:00
|
|
|
releaseNotesSource: inline
|
|
|
|
releaseNotesInline: ''
|
|
|
|
assets: '$(Build.ArtifactStagingDirectory)/*.nupkg'
|
|
|
|
assetUploadMode: replace
|
|
|
|
isPreRelease: false
|
|
|
|
addChangeLog: true
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
##############################
|
|
|
|
- job: Update_Dependents
|
2022-02-03 12:29:38 +03:00
|
|
|
condition: >-
|
|
|
|
and(
|
2023-04-03 16:04:52 +03:00
|
|
|
succeeded('Get_Build_Flags'),
|
2022-02-03 12:29:38 +03:00
|
|
|
or(
|
|
|
|
eq(dependencies.Get_Build_Flags.outputs['GetPRLabels.RUN_UPDATE_DEPENDENTS'], 'true'),
|
|
|
|
eq(variables['UPDATE_DEPENDENTS'], 'true')
|
|
|
|
),
|
2022-05-13 09:35:21 +03:00
|
|
|
eq(variables['System.PullRequest.PullRequestId'], '')
|
2022-02-03 12:29:38 +03:00
|
|
|
)
|
2021-02-25 20:58:22 +03:00
|
|
|
dependsOn:
|
|
|
|
- Get_Build_Flags
|
2021-02-25 21:09:57 +03:00
|
|
|
- Build_Test_Framework
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
pool:
|
2022-02-03 12:29:38 +03:00
|
|
|
vmImage: 'windows-latest'
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- checkout: self
|
|
|
|
|
2021-06-01 13:39:50 +03:00
|
|
|
- template: azure-pipelines-templates/install-nuget.yml@templates
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
- script: nbgv cloud -a -c
|
|
|
|
condition: succeeded()
|
|
|
|
displayName: Set build number
|
2022-12-28 14:44:23 +03:00
|
|
|
|
|
|
|
# wait for 15min to allow the 1st batch to get updated
|
|
|
|
# only if this wasn't triggered by the pipeline
|
|
|
|
- powershell: Start-Sleep -Seconds (15*60)
|
|
|
|
displayName: Wait for 15min
|
|
|
|
condition: eq(variables['UPDATE_DEPENDENTS'], 'false')
|
2021-02-25 20:58:22 +03:00
|
|
|
|
2021-03-24 20:35:21 +03:00
|
|
|
# update dependents
|
2021-02-25 20:58:22 +03:00
|
|
|
- task: PowerShell@2
|
2021-03-24 20:35:21 +03:00
|
|
|
displayName: Update dependents
|
2021-02-25 20:58:22 +03:00
|
|
|
inputs:
|
|
|
|
targetType: filePath
|
2021-03-24 20:35:21 +03:00
|
|
|
filePath: azure-pipelines/update-dependents.ps1
|
2021-02-25 20:58:22 +03:00
|
|
|
env:
|
|
|
|
MY_GITHUB_TOKEN: $(GitHubToken)
|
|
|
|
|
|
|
|
##################################
|
|
|
|
# report build failure to Discord
|
|
|
|
- job: Report_Build_Failure
|
|
|
|
dependsOn:
|
2021-02-25 21:09:57 +03:00
|
|
|
- Build_Test_Framework
|
2023-04-03 16:04:52 +03:00
|
|
|
- Update_Dependents
|
2023-04-03 14:07:14 +03:00
|
|
|
condition: >-
|
2023-04-03 16:04:52 +03:00
|
|
|
or(
|
|
|
|
failed('Update_Dependents'),
|
2023-04-03 14:07:14 +03:00
|
|
|
failed('Build_Test_Framework')
|
|
|
|
)
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
pool:
|
2022-02-03 12:29:38 +03:00
|
|
|
vmImage: 'windows-latest'
|
2021-02-25 20:58:22 +03:00
|
|
|
|
|
|
|
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: ''
|