Skip to content

Commit c113215

Browse files
committed
Work CI-CD
- Add template and steps to use specific MDP for mscorlib build.
1 parent 795d4a5 commit c113215

File tree

2 files changed

+106
-2
lines changed

2 files changed

+106
-2
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright (c) .NET Foundation and Contributors
2+
# See LICENSE file in the project root for full license information.
3+
4+
steps:
5+
- task: PowerShell@2
6+
displayName: Check MDP for build
7+
condition: ne(variables['System.PullRequest.PullRequestId'], '')
8+
inputs:
9+
failOnStderr: false
10+
targetType: "inline"
11+
script: |
12+
13+
# compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
14+
# 'encoded token' is the Base64 of the string "nfbot:personal-token"
15+
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)")))"
16+
17+
# find PR
18+
"Getting PR#$env:System_PullRequest_PullRequestNumber details..." | Write-Host -ForegroundColor White -NoNewline
19+
$pr = Invoke-WebRequest "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber" | ConvertFrom-Json
20+
21+
if($($pr.number) -eq "$env:System_PullRequest_PullRequestNumber")
22+
{
23+
'##[command] OK' | Write-Host -ForegroundColor Green
24+
}
25+
26+
# grab PR commit message
27+
$prCommitMessage = $($pr.body)
28+
29+
# look for test prompt in PR commit message
30+
# pattern is "[build with MDP buildId NNN]"
31+
32+
if($prCommitMessage -match "\[build with MDP buildId (\d+)\]")
33+
{
34+
$buildId = $matches[1]
35+
"AZDO build ID found: $buildId" | Write-Host -ForegroundColor White
36+
37+
echo "##vso[task.setvariable variable=MDP_BUILDID]$buildId"
38+
}
39+
else
40+
{
41+
"No build ID found" | Write-Host -ForegroundColor Red
42+
}
43+
env:
44+
GITHUB_TOKEN: $(GitHubToken)
45+
46+
- task: DownloadPipelineArtifact@2
47+
condition: >-
48+
and(
49+
eq(variables['DownloadMDP'], true),
50+
ne(variables['MDP_BUILDID'], '')
51+
)
52+
displayName: Download MDP
53+
inputs:
54+
buildType: specific
55+
project: 'metadata-processor'
56+
definition: '43'
57+
buildVersionToDownload: specific
58+
allowFailedBuilds: true
59+
pipelineId: $(MDP_BUILDID)
60+
artifactName: 'deployables'
61+
targetPath: '$(Pipeline.Workspace)/mdp'
62+
itemPattern: '*.MsBuildTask.dll'
63+
64+
- task: PowerShell@2
65+
condition: >-
66+
and(
67+
succeeded(),
68+
eq(variables['DownloadNanoClrPreview'], true),
69+
ne(variables['MDP_BUILDID'], '')
70+
)
71+
displayName: Set MDP path
72+
inputs:
73+
targetType: 'inline'
74+
script: |
75+
Write-Host "##vso[task.setvariable variable=NF_MDP_MSBUILDTASK_PATH]$(Pipeline.Workspace)/mdp/nanoFramework.Tools.MetadataProcessor.MsBuildTask.dll"

azure-pipelines.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ jobs:
9292
{
9393
Write-Host "##[command] **This is a PR build**"
9494
95+
# compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
96+
# 'encoded token' is the Base64 of the string "nfbot:personal-token"
97+
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)")))"
98+
9599
$commit = Invoke-RestMethod -Uri "https://api.github.com/repos/nanoframework/nf-interpreter/commits/$(Build.SourceVersion)" -ContentType "application/json" -Method GET
96100
97101
if( ($commit.commit.author.name -eq "nfbot") -and ($commit.commit.message -like "*[version update]*") )
@@ -104,12 +108,34 @@ jobs:
104108
echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]false"
105109
}
106110
111+
# find PR
112+
"Getting PR#$env:System_PullRequest_PullRequestNumber details..." | Write-Host -ForegroundColor White -NoNewline
113+
$pr = Invoke-WebRequest "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber" | ConvertFrom-Json
114+
115+
if($($pr.number) -eq "$env:System_PullRequest_PullRequestNumber")
116+
{
117+
'##[command] OK' | Write-Host -ForegroundColor Green
118+
}
119+
120+
# grab PR commit message
121+
$prCommitMessage = $($pr.body)
122+
123+
# debug output
124+
# echo "=====`r`n$($prCommitMessage)`r`n====="
125+
107126
# check if Unit Tests for mscorlib should be run
108-
if(($commit.commit.message -like "*[run mscorlib tests]*") -or ($commit.commit.message -match "Tested against nanoframework/CoreLibrary#(\d+)"))
127+
if(($prCommitMessage -like "*[run mscorlib tests]*") -or ($prCommitMessage -match "Tested against nanoframework/CoreLibrary#(\d+)"))
109128
{
110-
Write-Host "##[command] **mscorlib tests are to be runned**"
129+
Write-Host "##[command] >> mscorlib tests are to be runned"
111130
echo "##vso[task.setvariable variable=RUN_MSCORLIB_TESTS;isOutput=true]true"
112131
}
132+
133+
# check if should use specific MDP for mscorlib
134+
if($prCommitMessage -match "\[build with MDP buildId (\d+)\]")
135+
{
136+
Write-Host "##[command] >> Using specific MDP for mscorlib build"
137+
echo "##vso[task.setvariable variable=USE_SPECIFIC_MDP;isOutput=true]true"
138+
}
113139
}
114140
else
115141
{
@@ -1241,6 +1267,7 @@ jobs:
12411267
12421268
dependsOn:
12431269
- Build_nanoCLR_CLI
1270+
- Check_Build_Options
12441271

12451272
pool:
12461273
vmImage: "windows-latest"
@@ -1250,6 +1277,7 @@ jobs:
12501277
solution: "nanoFramework.CoreLibrary.sln"
12511278
buildPlatform: "Any CPU"
12521279
buildConfiguration: "Release"
1280+
DownloadMDP: $[ dependencies.Check_Build_Options.outputs['BuildOptions.USE_SPECIFIC_MDP'] ]
12531281

12541282
steps:
12551283
- checkout: self
@@ -1260,6 +1288,7 @@ jobs:
12601288
persistCredentials: true
12611289

12621290
- template: azure-pipelines-templates/check-mscorlib-to-test.yml
1291+
- template: azure-pipelines-templates/check-mdp-for-build.yml
12631292

12641293
# Download nanoclr from build artifacts
12651294
- task: DownloadBuildArtifacts@1

0 commit comments

Comments
 (0)