Skip to content

Commit ea43394

Browse files
committed
Work CI-CD
- Improve conditions to run mscorlib unit test. Now will only run on demand with variable from pipeline or set with trigger message. - Add new AZDO template to checkout mscorlib. 'main' branch as default, specific PR by using pattern in PR description (Tested against nanoframework/CoreLibrary#NNNN). - Remove checkout step from run mscorlib tests and replace with template. ***NO_CI***
1 parent bb475d0 commit ea43394

File tree

2 files changed

+74
-10
lines changed

2 files changed

+74
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
name: Check_mscorlib_test
7+
displayName: Check mscorlib to test
8+
condition: ne(variables['System.PullRequest.PullRequestId'], '')
9+
inputs:
10+
failOnStderr: false
11+
targetType: "inline"
12+
script: |
13+
14+
# compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
15+
# 'encoded token' is the Base64 of the string "nfbot:personal-token"
16+
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)")))"
17+
18+
# find PR
19+
"Getting PR#$env:System_PullRequest_PullRequestNumber details..." | Write-Host -ForegroundColor White -NoNewline
20+
$pr = Invoke-WebRequest "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber" | ConvertFrom-Json
21+
22+
if($($pr.number) -eq "$env:System_PullRequest_PullRequestNumber")
23+
{
24+
'##[command] OK' | Write-Host -ForegroundColor Green
25+
}
26+
27+
# grab PR commit message
28+
$prCommitMessage = $($pr.body)
29+
30+
# look for test prompt in PR commit message
31+
# pattern is "Tested against nanoframework/CoreLibrary#NNNN"
32+
33+
if($prCommitMessage -match "Tested against nanoframework/CoreLibrary#(\d+)")
34+
{
35+
$testPR = $matches[1]
36+
"Test PR found: $testPR" | Write-Host -ForegroundColor White
37+
38+
# store github reference in variable
39+
Write-Host "##vso[task.setvariable variable=TEST_PR;isOutput=true]$testPR"
40+
}
41+
else
42+
{
43+
"No test PR found." | Write-Host -ForegroundColor White
44+
45+
# use default (main) branch for tests
46+
Write-Host "##vso[task.setvariable variable=TEST_PR;isOutput=true]"
47+
}
48+
49+
- task: PowerShell@2
50+
displayName: Checkout mscorlib
51+
condition: ne(variables['System.PullRequest.PullRequestId'], '')
52+
inputs:
53+
targetType: "inline"
54+
script: |
55+
# create directory for mscorlib, ignore if it already exists
56+
New-Item -Path $(Agent.BuildDirectory)/s -ItemType "directory" -ErrorAction SilentlyContinue
57+
# move to the build sources directory
58+
Set-Location -Path $(Agent.BuildDirectory)/s
59+
60+
if($(Check_mscorlib_test.TEST_PR) -ne "")
61+
{
62+
Write-Host "Checking out mscorlib PR: #$(Check_mscorlib_test.TEST_PR)"
63+
gh pr checkout $(Check_mscorlib_test.TEST_PR) --recurse-submodules
64+
}
65+
else
66+
{
67+
Write-Host "Checking out mscorlib main branch"
68+
gh repo clone nanoframework/CoreLibrary CoreLibrary --recurse-submodules
69+
}

azure-pipelines.yml

+5-10
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ resources:
4949
name: espressif/esp-idf
5050
endpoint: nanoframework
5151
ref: refs/tags/v5.2.3
52-
- repository: mscorlib
53-
type: github
54-
name: nanoframework/CoreLibrary
55-
endpoint: nanoframework
5652
- repository: littlefs
5753
type: github
5854
name: littlefs-project/littlefs
@@ -104,11 +100,10 @@ jobs:
104100
}
105101
106102
# check if Unit Tests for mscorlib should be run
107-
if($commit.commit.message -like "*[run mscorlib tests]*")
103+
if(($commit.commit.message -like "*[run mscorlib tests]*") -or ($commit.commit.message -match "Tested against nanoframework/CoreLibrary#(\d+)"))
108104
{
109105
echo "##vso[task.setvariable variable=RUN_MSCORLIB_TESTS;isOutput=true]true"
110106
}
111-
112107
}
113108
else
114109
{
@@ -1217,7 +1212,7 @@ jobs:
12171212
succeeded('Build_nanoCLR_CLI'),
12181213
ne(dependencies.Check_Build_Options.outputs['BuildOptions.SKIP_BUILD'], true),
12191214
or(
1220-
eq(variables['BUILD_NANOCLR_CLI__'], true),
1215+
eq(variables['RUN_MSCORLIB_TESTS__'], true)
12211216
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ALL'], true),
12221217
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_NANOCLR_CLI'], true),
12231218
eq(dependencies.Check_Build_Options.outputs['BuildOptions.RUN_MSCORLIB_TESTS'], true)
@@ -1239,9 +1234,9 @@ jobs:
12391234
steps:
12401235
- checkout: self
12411236
fetchDepth: 1
1242-
- checkout: mscorlib
1243-
fetchDepth: 100
1244-
submodules: true
1237+
path: s/nf-interpreter
1238+
1239+
- template: azure-pipelines-templates/check-mscorlib-to-test.yml
12451240

12461241
# Download nanoclr from build artifacts
12471242
- task: DownloadBuildArtifacts@1

0 commit comments

Comments
 (0)