Skip to content

Commit

Permalink
[repo] Fix the solution build in CI to fail if errors are thrown (#1487)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Dec 13, 2023
1 parent fb69335 commit 18e54f3
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 7 deletions.
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
Assert.NotEqual(originalParentSpanId, activity.ParentSpanId);
#endif
Assert.Equal("0000000000000000", activity.ParentSpanId.ToHexString());
Assert.Equal(originalTraceFlag, activity.ActivityTraceFlags);
}
Expand Down

0 comments on commit 18e54f3

Please sign in to comment.