|
| 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 nf-interpreter to test |
| 7 | + condition: ne(variables['System.PullRequest.PullRequestNumber'], '') |
| 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-RestMethod -Uri "https://api.github.com/repos/$env:Build_Repository_Name/pulls/$env:System_PullRequest_PullRequestNumber" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET |
| 20 | +
|
| 21 | + if($($pr.number) -eq "$env:System_PullRequest_PullRequestNumber") |
| 22 | + { |
| 23 | + '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 "[tested against nanoclr buildId NNN]" |
| 31 | +
|
| 32 | + if($prCommitMessage -match "\[tested against nanoclr buildId (\d+)\]") |
| 33 | + { |
| 34 | + $buildId = $matches[1] |
| 35 | + "AZDO build ID found: $buildId" | Write-Host -ForegroundColor White |
| 36 | +
|
| 37 | + echo "##vso[task.setvariable variable=NFINTERPRETER_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['DownloadNanoClrPreview'], true), |
| 50 | + ne(variables['NFINTERPRETER_BUILDID'], '') |
| 51 | + ) |
| 52 | + displayName: Download nanoCLR preview |
| 53 | + inputs: |
| 54 | + buildType: specific |
| 55 | + project: 'nf-interpreter' |
| 56 | + definition: '34' |
| 57 | + buildVersionToDownload: specific |
| 58 | + allowFailedBuilds: true |
| 59 | + pipelineId: $(NFINTERPRETER_BUILDID) |
| 60 | + artifactName: 'nanoclr_cli' |
| 61 | + targetPath: '$(Pipeline.Workspace)/nanoclr' |
| 62 | + |
| 63 | + - task: PowerShell@2 |
| 64 | + condition: >- |
| 65 | + and( |
| 66 | + succeeded(), |
| 67 | + eq(variables['DownloadNanoClrPreview'], true), |
| 68 | + ne(variables['NFINTERPRETER_BUILDID'], '') |
| 69 | + ) |
| 70 | + displayName: Set nanoCLR preview path |
| 71 | + inputs: |
| 72 | + targetType: 'inline' |
| 73 | + script: | |
| 74 | + Write-Host "##vso[task.setvariable variable=NF_MDP_NANOCLR_INSTANCE_PATH]$(Pipeline.Workspace)/nanoclr/nanoFramework.nanoCLR.dll" |
0 commit comments