Skip to content

Commit

Permalink
API compatibility validation improvements, PowerFx (#707)
Browse files Browse the repository at this point in the history
- Add file ApiCompatBaseline.txt to compensate for a false compatibility
issue report.
- Download all PowerFx packages together for both the contract and the
implementation. Putting the dependent packages together gets more
accurate API validating. (dotnet/arcade#9725).
- Add task 'Publish compat results to Artifacts'. This makes results
more accessible to forks, as they are not published to forked PRs.
- Tweak var names and display names for readability.
  • Loading branch information
BruceHaley authored Oct 4, 2022
1 parent cf03abf commit eaf4d9e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 12 deletions.
2 changes: 2 additions & 0 deletions ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ApiCompat falsely reports the following issue for Microsoft.PowerFx.Core:
CannotChangeAttribute : Attribute 'Microsoft.AppMagic.Transport.TransportTypeAttribute' on 'Microsoft.PowerFx.Syntax.Span' changed from '[TransportTypeAttribute(0, true, null, null, false)]' in the contract to '[TransportTypeAttribute(TransportKind.ByValue, true, null, null, false)]' in the implementation.
28 changes: 18 additions & 10 deletions src/build/yaml/ci-api-validation-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ parameters:

steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download $(PackageName).dll from Artifacts'
displayName: 'Download OutputDlls from Artifacts'
inputs:
artifactName: 'OutputDlls-$(BuildConfiguration)'
patterns: '$(PackageName).dll'
targetPath: '$(System.ArtifactsDirectory)/Artifacts'
targetPath: '$(System.ArtifactsDirectory)/OutputDlls'

- task: NuGetCommand@2
displayName: 'NuGet install $(PackageName) v ${{ parameters.ContractVersion }}'
- task: DownloadPipelineArtifact@2
displayName: 'Download ContractDlls from Artifacts'
inputs:
command: custom
arguments: 'install $(PackageName) -Version ${{ parameters.ContractVersion }} -OutputDirectory $(System.DefaultWorkingDirectory)\DownloadedNuGet'
artifactName: 'ContractDlls'
targetPath: '$(System.ArtifactsDirectory)/ContractDlls'

- powershell: |
Write-Host "The following API compatibility issues are suppressed:";
Get-Content "ApiCompatBaseline.txt";
displayName: 'Show API compat issue suppression list in ApiCompatBaseline.txt'
continueOnError: true

- task: SOUTHWORKS.binaries-comparer.custom-build-release-task.binaries-comparer@0
displayName: 'Compare binaries'
inputs:
contractsRootFolder: 'DownloadedNuGet\$(PackageName).${{ parameters.ContractVersion }}\lib\netstandard2.0'
contractsRootFolder: '$(System.ArtifactsDirectory)/ContractDlls'
contractsFileName: '$(PackageName).dll'
implFolder: '$(System.ArtifactsDirectory)/Artifacts'
implFolder: '$(System.ArtifactsDirectory)/OutputDlls'
failOnIssue: false
resolveFx: false
generateLog: true
outputFilename: '$(PackageName).${{ parameters.ContractVersion }}.CompatResults.txt'
outputFolder: '$(Build.ArtifactStagingDirectory)'
useBaseline: false
useBaseline: true
baselineFile: ApiCompatBaseline.txt
continueOnError: true

- powershell: |
$filePath = "$(Build.ArtifactStagingDirectory)\$(PackageName).${{ parameters.ContractVersion }}.CompatResults.txt"
Expand All @@ -39,6 +46,7 @@ steps:
$content = "The binary compatibility report for library '$(PackageName)' wasn't generated. This may have happened because the NuGet library '$(PackageName)' for version '$(ContractVersion)' was unavailable or a connectivity issue."
New-Item -Path '$(Build.ArtifactStagingDirectory)' -Name '$(PackageName).${{ parameters.ContractVersion }}.CompatResults.txt' -ItemType "file" -Value $content
$content;
Write-Host "##vso[task.complete result=Failed;]";
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/build/yaml/feed-setup-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ steps:
New-Item -Path $file -ItemType "file" -Value $content -Force;
'-------------'; get-content "$file"; '===================';
displayName: Create nuget.config for SDK feed
displayName: SDK feed setup
43 changes: 42 additions & 1 deletion src/build/yaml/powerfx-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,47 @@ stages:
condition: and(succeeded(), ne(variables['System.PullRequest.IsFork'], 'True'))
continueOnError: true

- powershell: |
# Set up tokens for private sources
$file = "$(Build.SourcesDirectory)\nuget.config";
$ErrorActionPreference = 'SilentlyContinue';
nuget sources update -ConfigFile "$file" -Name "SDK_Dotnet_V4_org" -username "ContractDlls" -password "$(System.AccessToken)";
nuget sources update -ConfigFile "$file" -Name "PowerFx" -username "ContractDlls" -password "$(System.AccessToken)";
$ErrorActionPreference = 'Continue';
'-------------'; get-content "$file"; '===================';
$PackageNames = "$(PackagesToValidate)";
$ApiContractVersion = "$(GetContract.ContractVersion)";
$TempContractInstallDirectory = ".\TempContractInstallDir";
$OutputDirectory = ".\ContractDlls";
Write-Host "`nDownloading packages version $ApiContractVersion.";
New-Item -ItemType directory -Path $OutputDirectory -Force | Out-Null;
$Names = $PackageNames.Split(',');
foreach ($Name in $Names) {
"---- $Name ------------------";
nuget install $Name -Version $ApiContractVersion -OutputDirectory $TempContractInstallDirectory -DirectDownload -NonInteractive;
if ($LASTEXITCODE -eq 0) {
Copy-Item "$TempContractInstallDirectory\$Name.$ApiContractVersion\lib\netstandard2.0\$Name.dll" $OutputDirectory;
}
else {
Write-Host "##vso[task.complete result=Failed;]";
}
}
displayName: 'Download Contract DLLs to ContractDlls folder'
continueOnError: true
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'ContractDlls'
targetPath: ContractDlls
displayName: 'Push to ContractDlls in Artifacts'
continueOnError: true

- powershell: |
$multiconfig = '{';
$env:PackagesToValidate.Split(",") | ForEach {
Expand Down Expand Up @@ -184,7 +225,7 @@ stages:
contractVersion: $[ dependencies.generate_multiconfig_var.outputs['GetContract.ContractVersion'] ]

steps:
- checkout: none
- checkout: self

- template: feed-setup-step.yml
parameters:
Expand Down

0 comments on commit eaf4d9e

Please sign in to comment.