Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Repo] Attempting to stabilize the API Compatibility CI job #3766

Merged
merged 9 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions build/Common.prod.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@

<ItemGroup Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
<PackageReference Include="Microsoft.DotNet.ApiCompat" Version="6.0.0-beta.21308.1" PrivateAssets="All" />
<ResolvedMatchingContract Include="..\LastMajorVersionBinaries\$(AssemblyName)\$(OTelPreviousStableVer)\lib\$(TargetFramework)\$(AssemblyName).dll" />
<ResolvedMatchingContract Include="$(RepoRoot)\build\LastMajorVersionBinaries\$(AssemblyName)\$(OTelPreviousStableVer)\lib\$(TargetFramework)\$(AssemblyName).dll" />
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
<Exec Command="powershell -ExecutionPolicy Unrestricted -File &quot;$(RepoRoot)\build\PreBuild.ps1&quot; -package $(AssemblyName) -version &quot;$(OTelPreviousStableVer)&quot;" />
<Target Name="PreBuild" BeforeTargets="DispatchToInnerBuilds;ValidateApiCompatForSrc" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
<!-- Note: DispatchToInnerBuilds is called for projects with multiple
targets defined to spawn a build process for each target framework being
compiled. Executing BEFORE that step means this runs once for a project
instead of in parallel for each target framework defined. If we ever have a
project with only a single target, this will NOT run and an alternative
solution will be needed. -->
<Exec Command="powershell -ExecutionPolicy Unrestricted -File &quot;$(RepoRoot)\build\PreBuild.ps1&quot; -package $(AssemblyName) -version &quot;$(OTelPreviousStableVer)&quot; -workDir &quot;$(RepoRoot)\build\LastMajorVersionBinaries&quot;" />
</Target>

<Target Name="FindContractDependencyPaths" BeforeTargets="ValidateApiCompatForSrc" AfterTargets="ResolveAssemblyReferences" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
Expand Down
17 changes: 11 additions & 6 deletions build/PreBuild.ps1
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
param([string]$package, [string]$version)
param(
[string]$package,
[string]$version,
[string]$workDir = ".\LastMajorVersionBinaries"
)

$workDir = "..\LastMajorVersionBinaries"
if (-Not (Test-Path $workDir))
{
Write-Host "Working directory for previous package versions not found, creating..."
Write-Host "Working directory for compatibility check packages '$workDir' not found, creating..."
New-Item -Path $workDir -ItemType "directory" | Out-Null
}

if (Test-Path -Path "$workDir\$package.$version.zip")
{
Write-Debug "Previous package version already downloaded"
Write-Debug "Previous package $package@$version already downloaded for compatibility check"
}
else
{
Write-Host "Retrieving $package @$version for compatibility check"
Write-Host "Retrieving package $package@$version for compatibility check"
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/$package/$version -Outfile "$workDir\$package.$version.zip"
}

if (Test-Path -Path "$workDir\$package\$version\lib")
{
Write-Debug "Previous package version already extracted"
Write-Debug "Previous package $package@$version already extracted to '$workDir\$package\$version\lib'"
}
else
{
Write-Host "Extracting package $package@$version from '$workDir\$package.$version.zip' to '$workDir\$package\$version' for compatibility check"
Expand-Archive -LiteralPath "$workDir\$package.$version.zip" -DestinationPath "$workDir\$package\$version" -Force
}