|
| 1 | +steps: |
| 2 | +- task: DownloadPipelineArtifact@2 |
| 3 | + displayName: 'Download BotBuilderDLLs from Artifacts' |
| 4 | + inputs: |
| 5 | + artifactName: 'BotBuilderDLLs-Debug-Windows-netcoreapp31' |
| 6 | + targetPath: '$(System.ArtifactsDirectory)/OutputDlls' |
| 7 | + |
| 8 | +- task: DownloadPipelineArtifact@2 |
| 9 | + displayName: 'Download ContractDlls from Artifacts' |
| 10 | + inputs: |
| 11 | + artifactName: 'ContractDlls' |
| 12 | + targetPath: '$(System.ArtifactsDirectory)/ContractDlls' |
| 13 | + |
| 14 | +- powershell: | |
| 15 | + Write-Host "The following API compatibility issues are suppressed:"; |
| 16 | + Get-Content "ApiCompatBaseline.txt"; |
| 17 | + displayName: 'Show API compat issue suppressions in ApiCompatBaseline.txt' |
| 18 | + continueOnError: true |
| 19 | + |
| 20 | +- task: SOUTHWORKS.binaries-comparer.custom-build-release-task.binaries-comparer@0 |
| 21 | + displayName: 'Compare Binaries' |
| 22 | + inputs: |
| 23 | + contractsRootFolder: '$(System.ArtifactsDirectory)/ContractDlls' |
| 24 | + contractsFileName: '$(PackageName).dll' |
| 25 | + implFolder: '$(System.ArtifactsDirectory)/OutputDlls' |
| 26 | + failOnIssue: false |
| 27 | + resolveFx: false |
| 28 | + generateLog: true |
| 29 | + outputFilename: '$(PackageName).$(ApiContractVersion).CompatResults.txt' |
| 30 | + outputFolder: '$(Build.ArtifactStagingDirectory)' |
| 31 | + useBaseline: true |
| 32 | + baselineFile: ApiCompatBaseline.txt |
| 33 | + continueOnError: false |
| 34 | + |
| 35 | +- powershell: | |
| 36 | + $filePath = "$(Build.ArtifactStagingDirectory)\$(PackageName).$(ApiContractVersion).CompatResults.txt" |
| 37 | + $nugetLink = "compared against [version $(ApiContractVersion)](https://www.nuget.org/packages/$(PackageName)/$(ApiContractVersion))."; |
| 38 | + Write-Host "Compatibility Check:"; |
| 39 | +
|
| 40 | + if (-not (Test-Path $filePath)) { |
| 41 | + $content = "The binary compatibility report for library '$(PackageName)' wasn't generated. This may have happened because the NuGet library '$(PackageName)' for version '$(ApiContractVersion)' was unavailable or a connectivity issue." |
| 42 | + New-Item -Path '$(Build.ArtifactStagingDirectory)' -Name '$(PackageName).$(ApiContractVersion).CompatResults.txt' -ItemType "file" -Value $content |
| 43 | + $content; |
| 44 | + Write-Host "##vso[task.complete result=Failed;]"; |
| 45 | + return; |
| 46 | + } |
| 47 | +
|
| 48 | + $baseline = Get-Content $filePath -Raw; |
| 49 | + Write-Host "`n[Compare binaries task]"; |
| 50 | + Write-Host "`nOriginal result:"; |
| 51 | + $baseline; |
| 52 | +
|
| 53 | + # When the Api Compat task has Binary compatibility issues, this process will filter out the Classes |
| 54 | + # and then validates if still exists remaining issues. |
| 55 | + if ($baseline.ToString().Trim().StartsWith(':x:')) { |
| 56 | + Write-Host "`n[Class exclusion]"; |
| 57 | + $excludeClasses = "$($env:ApiCompatExcludeClasses)".Trim().Split(',') | Where-Object { ($_.Trim().Length -gt 0) } | ForEach-Object { $_.Trim() }; |
| 58 | + |
| 59 | + if ($excludeClasses) { |
| 60 | + Write-Host "`nList of classes to exclude:"; |
| 61 | + $excludeClasses | ForEach-Object { " - " + $_ } |
| 62 | + } |
| 63 | + else { |
| 64 | + Write-Host "`nThere are no classes to exclude."; |
| 65 | + } |
| 66 | + |
| 67 | + $content = ($baseline -split '<details\>|<\/details\>'); |
| 68 | + $header = $content[0].SubString($content[0].IndexOf('Binary') - 1).Trim(); |
| 69 | + $issues = $content[1].Trim(); |
| 70 | + $issues = ($issues -replace '```', '').Split([Environment]::NewLine); |
| 71 | +
|
| 72 | + # Filter out issues based on Class name. |
| 73 | + $issues = @( |
| 74 | + $issues | Where-Object { |
| 75 | + $line = $_; |
| 76 | + if (-not $line.Trim()) { |
| 77 | + return $false; |
| 78 | + } |
| 79 | + if ($excludeClasses) { |
| 80 | + foreach ($class in $excludeClasses) { |
| 81 | + $pattern = "'$class"; |
| 82 | + if ($line -match $pattern) { |
| 83 | + return $false; |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + return $true; |
| 88 | + } | ForEach-Object { $_.Trim() } |
| 89 | + ) |
| 90 | +
|
| 91 | + # Creates new file content. |
| 92 | + if ($issues) { |
| 93 | + $newFile = @(); |
| 94 | + $newfile += ":x: $($issues.Length) $header $nugetLink"; |
| 95 | + $newFile += '<details>'; |
| 96 | + $newFile += ""; |
| 97 | + $newFile += '```'; |
| 98 | + $newfile += $issues; |
| 99 | + $newFile += '```'; |
| 100 | + $newFile += ""; |
| 101 | + $newFile += '</details>'; |
| 102 | + |
| 103 | + $newFile = $newFile -join [Environment]::NewLine; |
| 104 | + Write-Host "##vso[task.complete result=Failed;]"; |
| 105 | + } |
| 106 | + else { |
| 107 | + $newFile = ":heavy_check_mark: No Binary Compatibility issues for **$(PackageName)** $nugetLink"; |
| 108 | + } |
| 109 | +
|
| 110 | + $baseline = $newFile; |
| 111 | + [system.io.file]::WriteAllText($filePath, $baseline); |
| 112 | + Write-Host "`nProcessed result:"; |
| 113 | + $baseline; |
| 114 | + } |
| 115 | + displayName: 'Compatibility Check' |
| 116 | + continueOnError: false |
| 117 | + condition: succeededOrFailed() |
| 118 | + |
| 119 | +- task: PublishBuildArtifacts@1 |
| 120 | + displayName: 'Publish Compat Results artifact' |
| 121 | + inputs: |
| 122 | + ArtifactName: '$(PackageName).$(ApiContractVersion).CompatResults' |
| 123 | + condition: succeededOrFailed() |
| 124 | + |
| 125 | +- script: | |
| 126 | + dir .. /s |
| 127 | + displayName: 'Dir workspace' |
| 128 | + continueOnError: true |
| 129 | + condition: succeededOrFailed() |
0 commit comments