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] Fix the solution build in CI to fail if errors are thrown #1487

Merged
merged 9 commits into from
Dec 13, 2023
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: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,21 @@ jobs:
OpenTelemetry.ResourceDetectors.Azure.Tests.csproj,
OpenTelemetry.ResourceDetectors.ProcessRuntime.Tests.csproj

$failedProjects = @()

ForEach ($project in $projects)
{
dotnet test $project.FullName --collect:"Code Coverage" --results-directory:"TestResults" --framework ${{ matrix.version }} --configuration Release --logger:"console;verbosity=detailed" -- RunConfiguration.DisableAppDomain=true

if ($LASTEXITCODE -ne 0)
{
$failedProjects = $failedProjects + $project
}
}

if ($failedProjects.Count -gt 0)
{
throw "dotnet test failed on '$failedProjects' project(s)"
}

- name: Install coverage tool
Expand Down
15 changes: 15 additions & 0 deletions build/Common.nonprod.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,19 @@
<DotNetCliToolReference Include="dotnet-xunit" Version="$(DotNetXUnitCliVer)" />
</ItemGroup>

<Target Name="SkipVSTestForInvalidTargetFramework" BeforeTargets="VSTest" Condition="'$(IsTestProject)' == 'true'">
<!-- Note: When running dotnet test from CLI with the framework parameter
errors will be generated for projects which do not implement the requested
target. In order to enable running tests for a given framework across a
solution/project with mixed targets (eg: dotnet test
opentelemetry-dotnet-contrib.sln -f net462) we convert this into a skip
message only. -->
<PropertyGroup Condition="$(TargetFrameworks.Contains($(TargetFramework))) != 'true'">
<_SkipTests>true</_SkipTests>
<IsTestProject>false</IsTestProject>
</PropertyGroup>

<Message Importance="high" Text="Skipping test execution for '$(TargetPath)' because it does not contain the '$(TargetFramework)' target." Condition="'$(_SkipTests)' == 'true'" />
</Target>

</Project>
1 change: 1 addition & 0 deletions build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<MSBuildTreatWarningsAsErrors>true</MSBuildTreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Label="Package versions used in this repository">
Expand Down
14 changes: 13 additions & 1 deletion examples/AspNet/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" culture="neutral" publicKeyToken="adb9793829ddae60" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Options" culture="neutral" publicKeyToken="adb9793829ddae60" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
Expand All @@ -59,7 +71,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-7.0.0.2" newVersion="7.0.0.2"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Reference Include="System.Net.Http" Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'" />
</ItemGroup>
-->
<PackageReference Include="System.Net.Http" Version="4.3.4" Condition="'$(TargetFramework)' == 'net462'" />
<PackageReference Include="System.Net.Http" Version="$(SystemNetHttp)" Condition="'$(TargetFramework)' == 'net462'" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<MinVerTagPrefix>Exporter.Stackdriver-</MinVerTagPrefix>
<IncludeSharedExceptionExtensionsSource>true</IncludeSharedExceptionExtensionsSource>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Cloud.Monitoring.V3" Version="[2.6.0,4.0)" />
<PackageReference Include="Google.Cloud.Trace.V2" Version="[2.3.0,4.0)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,23 @@

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.InMemory" Version="$(OpenTelemetryCoreLatestVersion)" />

<!-- See note below for details. -->
<PackageReference Include="System.Net.Http"
Version="$(SystemNetHttp)"
IncludeAssets="none"
GeneratePathProperty="true" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<!-- Note: There is an issue with the System.Net.Http reference in
OpenTelemetry.Exporter.Stackdriver graph. Google.Api.Gax (and friends)
require System.Net.Http v4.2.0.0. .NET Framework 4.6.2 ships v4.0.0.0. To
workaround this issue we directly reference the NuGet (which is v4.1.1.3)
with SpecificVersion=true. -->
<Reference Include="System.Net.Http">
<HintPath>$(PkgSystem_Net_Http)\lib\net46\System.Net.Http.dll</HintPath>
<SpecificVersion>True</SpecificVersion>
</Reference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ public void TestGenerateTraceIdForRootNode()
activity.Start();

Assert.NotEqual(originalTraceId, activity.TraceId);
#if NET6_0_OR_GREATER
// the net6.0 version of AWSXRayIdGenerator uses Activity.TraceIdGenerator, which does not change the parent ID
Assert.Equal(originalParentSpanId, activity.ParentSpanId);
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this silently failing up until now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so? I tried to look back at the run where it was introduced to see how it got in initially but detailed logging isn't maintained that far back.

The actual code always sets parentSpanId to default so I'm not sure how it ever ended up something other than what the root has.

Assert.NotEqual(originalParentSpanId, activity.ParentSpanId);
#endif
Assert.Equal("0000000000000000", activity.ParentSpanId.ToHexString());
Assert.Equal(originalTraceFlag, activity.ActivityTraceFlags);
}
Expand Down
Loading