From a19d9e076f1c405e0334a755e64389b4a224ff24 Mon Sep 17 00:00:00 2001 From: Tim Hess Date: Mon, 14 Jun 2021 11:20:20 -0500 Subject: [PATCH] Using Microsoft.DotNet.ApiCompat (#2075) --- .github/workflows/apicompatibility.yml | 21 +++++++++++++++++++++ .gitignore | 2 ++ NuGet.config | 1 + OpenTelemetry.sln | 4 +++- build/Common.prod.props | 7 +++++++ build/Common.props | 1 + build/PreBuild.ps1 | 26 ++++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/apicompatibility.yml create mode 100644 build/PreBuild.ps1 diff --git a/.github/workflows/apicompatibility.yml b/.github/workflows/apicompatibility.yml new file mode 100644 index 0000000000..108a465b12 --- /dev/null +++ b/.github/workflows/apicompatibility.yml @@ -0,0 +1,21 @@ +name: API Compatibility + +on: + pull_request: + branches: [ main, metrics ] + paths-ignore: + - '**.md' + +jobs: + build-test: + runs-on: windows-latest + env: + CheckAPICompatibility: true + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore diff --git a/.gitignore b/.gitignore index 439e441439..c7ffd293a6 100644 --- a/.gitignore +++ b/.gitignore @@ -340,3 +340,5 @@ ASALocalRun/ # SonarQube folder /.sonarqube + +/src/LastMajorVersionBinaries diff --git a/NuGet.config b/NuGet.config index bb984e4c44..6c0da1e868 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,6 +3,7 @@ + diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln index 71e1aeff36..8656ae8599 100644 --- a/OpenTelemetry.sln +++ b/OpenTelemetry.sln @@ -33,6 +33,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E build\OpenTelemetry.prod.loose.ruleset = build\OpenTelemetry.prod.loose.ruleset build\OpenTelemetry.prod.ruleset = build\OpenTelemetry.prod.ruleset build\OpenTelemetry.test.ruleset = build\OpenTelemetry.test.ruleset + build\PreBuild.ps1 = build\PreBuild.ps1 build\process-codecoverage.ps1 = build\process-codecoverage.ps1 build\RELEASING.md = build\RELEASING.md build\stylecop.json = build\stylecop.json @@ -100,6 +101,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEM EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{E69578EB-B456-4062-A645-877CD964528B}" ProjectSection(SolutionItems) = preProject + .github\workflows\apicompatibility.yml = .github\workflows\apicompatibility.yml .github\workflows\code-coverage.yml = .github\workflows\code-coverage.yml .github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml .github\workflows\docfx.yml = .github\workflows\docfx.yml @@ -199,7 +201,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.5.0", "t EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "exception-reporting", "docs\trace\exception-reporting\exception-reporting.csproj", "{08D29501-F0A3-468F-B18D-BD1821A72383}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "customizing-the-sdk", "docs\trace\customizing-the-sdk\customizing-the-sdk.csproj", "{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "customizing-the-sdk", "docs\trace\customizing-the-sdk\customizing-the-sdk.csproj", "{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/build/Common.prod.props b/build/Common.prod.props index 2d77e1a187..c88612ce4e 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -10,6 +10,13 @@ All + + + + + + + $(MSBuildThisFileDirectory)/OpenTelemetry.prod.ruleset diff --git a/build/Common.props b/build/Common.props index 5c9505ed4e..d273eebea0 100644 --- a/build/Common.props +++ b/build/Common.props @@ -38,6 +38,7 @@ [1.0.0,2.0) [12.0.2,13.0) [0.12.1,0.13) + 1.0.1 [2.1.58,3.0) [1.1.118,2.0) 1.4.0 diff --git a/build/PreBuild.ps1 b/build/PreBuild.ps1 new file mode 100644 index 0000000000..847c4d52c7 --- /dev/null +++ b/build/PreBuild.ps1 @@ -0,0 +1,26 @@ +param([string]$package, [string]$version) + +$workDir = "..\LastMajorVersionBinaries" +if (-Not (Test-Path $workDir)) +{ + Write-Host "Working directory for previous package versions 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" +} +else +{ + Write-Host "Retrieving $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" +} +else +{ + Expand-Archive -LiteralPath "$workDir\$package.$version.zip" -DestinationPath "$workDir\$package\$version" -Force +}