|
| 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 | + # move to the build sources directory |
| 39 | + Set-Location -Path $(Agent.BuildDirectory)/s/CoreLibrary |
| 40 | +
|
| 41 | + # need to call this first to setup authentication |
| 42 | + gh auth setup-git |
| 43 | +
|
| 44 | + # gh auth status |
| 45 | + |
| 46 | + Write-Host "Checking out mscorlib PR: #$testPR" |
| 47 | + gh pr checkout $testPR |
| 48 | + } |
| 49 | + else |
| 50 | + { |
| 51 | + "No test PR found. Using main branch" | Write-Host -ForegroundColor White |
| 52 | + } |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: $(GitHubToken) |
0 commit comments