|
| 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 | + } |
0 commit comments