[repo] CI updates (#4016)

* Port some CI tweaks from contrib.

* Logging in integration tests.

* Test tweaks.

* Warning cleanup.

* Fix format.

* Comments.
This commit is contained in:
Mikel Blanchard 2022-12-15 16:08:30 -08:00 committed by GitHub
parent 9ad312af3a
commit 5b9cba7cbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 63 additions and 37 deletions

View File

@ -16,7 +16,9 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 # fetching all fetch-depth: 0 # fetching all
- uses: actions/setup-dotnet@v3.0.3
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v3.0.3
with: with:
dotnet-version: '7.0.x' dotnet-version: '7.0.x'

View File

@ -27,7 +27,8 @@ jobs:
with: with:
fetch-depth: 0 # fetching all fetch-depth: 0 # fetching all
- uses: actions/setup-dotnet@v3.0.3 - name: Setup .NET 7.0
uses: actions/setup-dotnet@v3.0.3
with: with:
dotnet-version: '7.0.x' dotnet-version: '7.0.x'

View File

@ -23,7 +23,9 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 # fetching all fetch-depth: 0 # fetching all
- uses: actions/setup-dotnet@v3.0.3
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v3.0.3
with: with:
dotnet-version: '7.0.x' dotnet-version: '7.0.x'

View File

@ -20,7 +20,7 @@ jobs:
- name: check out code - name: check out code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup .NET Core 7.0 - name: Setup .NET 7.0
uses: actions/setup-dotnet@v3.0.3 uses: actions/setup-dotnet@v3.0.3
with: with:
dotnet-version: '7.0.x' dotnet-version: '7.0.x'

View File

@ -16,7 +16,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
version: [net7.0] version: [net6.0,net7.0]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -28,7 +28,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
version: [net7.0] version: [net6.0,net7.0]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -40,7 +40,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
version: [net7.0] version: [net6.0,net7.0]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

View File

@ -23,7 +23,8 @@ jobs:
fetch-depth: 0 # fetching all fetch-depth: 0 # fetching all
ref: ${{ github.ref || 'main' }} ref: ${{ github.ref || 'main' }}
- uses: actions/setup-dotnet@v3.0.3 - name: Setup .NET 7.0
uses: actions/setup-dotnet@v3.0.3
with: with:
dotnet-version: '7.0.x' dotnet-version: '7.0.x'

View File

@ -27,8 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
build\Common.props = build\Common.props build\Common.props = build\Common.props
build\debug.snk = build\debug.snk build\debug.snk = build\debug.snk
build\docfx.cmd = build\docfx.cmd build\docfx.cmd = build\docfx.cmd
build\docker-compose.net6.0.yml = build\docker-compose.net6.0.yml
build\docker-compose.net7.0.yml = build\docker-compose.net7.0.yml build\docker-compose.net7.0.yml = build\docker-compose.net7.0.yml
build\docker-compose.netcoreapp3.1.yml = build\docker-compose.netcoreapp3.1.yml
build\finalize-publicapi.ps1 = build\finalize-publicapi.ps1 build\finalize-publicapi.ps1 = build\finalize-publicapi.ps1
build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt
build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png

View File

@ -0,0 +1,9 @@
version: '3.7'
services:
tests:
build:
args:
PUBLISH_FRAMEWORK: net6.0
TEST_SDK_VERSION: 6.0
BUILD_SDK_VERSION: 7.0

View File

@ -5,4 +5,5 @@ services:
build: build:
args: args:
PUBLISH_FRAMEWORK: net7.0 PUBLISH_FRAMEWORK: net7.0
SDK_VERSION: 7.0 TEST_SDK_VERSION: 7.0
BUILD_SDK_VERSION: 7.0

View File

@ -1,8 +0,0 @@
version: '3.7'
services:
tests:
build:
args:
PUBLISH_FRAMEWORK: netcoreapp3.1
SDK_VERSION: 3.1

View File

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"rollForward": "latestFeature", "rollForward": "latestFeature",
"version": "7.0.100" "version": "7.0.101"
} }
} }

View File

@ -2,8 +2,10 @@
# This should be run from the root of the repo: # This should be run from the root of the repo:
# docker build --file test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Dockerfile # docker build --file test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Dockerfile
ARG SDK_VERSION=7.0 ARG BUILD_SDK_VERSION=7.0
FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION} AS build ARG TEST_SDK_VERSION=7.0
FROM mcr.microsoft.com/dotnet/sdk:${BUILD_SDK_VERSION} AS build
ARG PUBLISH_CONFIGURATION=Release ARG PUBLISH_CONFIGURATION=Release
ARG PUBLISH_FRAMEWORK=net7.0 ARG PUBLISH_FRAMEWORK=net7.0
WORKDIR /repo WORKDIR /repo
@ -11,7 +13,7 @@ COPY . ./
WORKDIR "/repo/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests" WORKDIR "/repo/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests"
RUN dotnet publish "OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj" -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /drop -p:IntegrationBuild=true -p:TARGET_FRAMEWORK=${PUBLISH_FRAMEWORK} RUN dotnet publish "OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj" -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /drop -p:IntegrationBuild=true -p:TARGET_FRAMEWORK=${PUBLISH_FRAMEWORK}
FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION} AS final FROM mcr.microsoft.com/dotnet/sdk:${TEST_SDK_VERSION} AS final
WORKDIR /test WORKDIR /test
COPY --from=build /drop . COPY --from=build /drop .
ENTRYPOINT ["dotnet", "vstest", "OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.dll", "--logger:console;verbosity=detailed"] ENTRYPOINT ["dotnet", "vstest", "OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.dll", "--logger:console;verbosity=detailed"]

View File

@ -2,8 +2,10 @@
# This should be run from the root of the repo: # This should be run from the root of the repo:
# docker build --file test/OpenTelemetry.Instrumentation.SqlClient.Tests/Dockerfile . # docker build --file test/OpenTelemetry.Instrumentation.SqlClient.Tests/Dockerfile .
ARG SDK_VERSION=7.0 ARG BUILD_SDK_VERSION=7.0
FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION} AS build ARG TEST_SDK_VERSION=7.0
FROM mcr.microsoft.com/dotnet/sdk:${BUILD_SDK_VERSION} AS build
ARG PUBLISH_CONFIGURATION=Release ARG PUBLISH_CONFIGURATION=Release
ARG PUBLISH_FRAMEWORK=net7.0 ARG PUBLISH_FRAMEWORK=net7.0
WORKDIR /repo WORKDIR /repo
@ -12,9 +14,9 @@ RUN ls -la /repo
WORKDIR "/repo/test/OpenTelemetry.Instrumentation.SqlClient.Tests" WORKDIR "/repo/test/OpenTelemetry.Instrumentation.SqlClient.Tests"
RUN dotnet publish "OpenTelemetry.Instrumentation.SqlClient.Tests.csproj" -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /drop -p:IntegrationBuild=true -p:TARGET_FRAMEWORK=${PUBLISH_FRAMEWORK} RUN dotnet publish "OpenTelemetry.Instrumentation.SqlClient.Tests.csproj" -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /drop -p:IntegrationBuild=true -p:TARGET_FRAMEWORK=${PUBLISH_FRAMEWORK}
FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION} AS final FROM mcr.microsoft.com/dotnet/sdk:${TEST_SDK_VERSION} AS final
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait
RUN chmod +x /wait RUN chmod +x /wait
WORKDIR /test WORKDIR /test
COPY --from=build /drop . COPY --from=build /drop .
ENTRYPOINT ["dotnet", "vstest", "OpenTelemetry.Instrumentation.SqlClient.Tests.dll"] ENTRYPOINT ["dotnet", "vstest", "OpenTelemetry.Instrumentation.SqlClient.Tests.dll", "--logger:console;verbosity=detailed"]

View File

@ -2,14 +2,16 @@
# This should be run from the root of the repo: # This should be run from the root of the repo:
# docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile . # docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile .
ARG SDK_VERSION=7.0 ARG BUILD_SDK_VERSION=7.0
ARG TEST_SDK_VERSION=7.0
FROM ubuntu AS w3c FROM ubuntu AS w3c
#Install git #Install git
WORKDIR /w3c WORKDIR /w3c
RUN apt-get update && apt-get install -y git RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/w3c/trace-context.git RUN git clone https://github.com/w3c/trace-context.git
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build FROM mcr.microsoft.com/dotnet/sdk:${BUILD_SDK_VERSION} AS build
ARG PUBLISH_CONFIGURATION=Release ARG PUBLISH_CONFIGURATION=Release
ARG PUBLISH_FRAMEWORK=net7.0 ARG PUBLISH_FRAMEWORK=net7.0
WORKDIR /repo WORKDIR /repo
@ -17,7 +19,7 @@ COPY . ./
WORKDIR "/repo/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests" WORKDIR "/repo/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests"
RUN dotnet publish "OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj" -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /drop -p:IntegrationBuild=true -p:TARGET_FRAMEWORK=${PUBLISH_FRAMEWORK} RUN dotnet publish "OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj" -c "${PUBLISH_CONFIGURATION}" -f "${PUBLISH_FRAMEWORK}" -o /drop -p:IntegrationBuild=true -p:TARGET_FRAMEWORK=${PUBLISH_FRAMEWORK}
FROM mcr.microsoft.com/dotnet/sdk:${SDK_VERSION} AS final FROM mcr.microsoft.com/dotnet/sdk:${TEST_SDK_VERSION} AS final
WORKDIR /test WORKDIR /test
COPY --from=build /drop . COPY --from=build /drop .
COPY --from=w3c /w3c . COPY --from=w3c /w3c .
@ -27,4 +29,4 @@ RUN apt-get update \
&& ln -s /usr/bin/python3 python \ && ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip \ && pip3 install --upgrade pip \
&& pip3 install aiohttp && pip3 install aiohttp
ENTRYPOINT ["dotnet", "vstest", "OpenTelemetry.Instrumentation.W3cTraceContext.Tests.dll"] ENTRYPOINT ["dotnet", "vstest", "OpenTelemetry.Instrumentation.W3cTraceContext.Tests.dll", "--logger:console;verbosity=detailed"]

View File

@ -13,8 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// </copyright> // </copyright>
using System.Diagnostics; using System.Diagnostics;
using System.Net.Http;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@ -34,6 +34,7 @@ namespace OpenTelemetry.Instrumentation.W3cTraceContext.Tests
opentelemetry>docker-compose --file=test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/docker-compose.yml --project-directory=. up --exit-code-from=tests --build opentelemetry>docker-compose --file=test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/docker-compose.yml --project-directory=. up --exit-code-from=tests --build
*/ */
private const string W3cTraceContextEnvVarName = "OTEL_W3CTRACECONTEXT"; private const string W3cTraceContextEnvVarName = "OTEL_W3CTRACECONTEXT";
private static readonly Version AspNetCoreHostingVersion = typeof(Microsoft.AspNetCore.Hosting.Builder.IApplicationBuilderFactory).Assembly.GetName().Version;
private readonly HttpClient httpClient = new HttpClient(); private readonly HttpClient httpClient = new HttpClient();
private readonly ITestOutputHelper output; private readonly ITestOutputHelper output;
@ -59,7 +60,7 @@ namespace OpenTelemetry.Instrumentation.W3cTraceContext.Tests
// disabling due to failing dotnet-format // disabling due to failing dotnet-format
// TODO: investigate why dotnet-format fails. // TODO: investigate why dotnet-format fails.
#pragma warning disable SA1008 // Opening parenthesis should be spaced correctly #pragma warning disable SA1008 // Opening parenthesis should be spaced correctly
app.MapPost("/", async([FromBody]Data[] data) => app.MapPost("/", async([FromBody] Data[] data) =>
{ {
var result = string.Empty; var result = string.Empty;
if (data != null) if (data != null)
@ -90,14 +91,25 @@ namespace OpenTelemetry.Instrumentation.W3cTraceContext.Tests
string result = RunCommand("python", "trace-context/test/test.py http://localhost:5000/"); string result = RunCommand("python", "trace-context/test/test.py http://localhost:5000/");
// Assert // Assert
// Assert on the last line
// TODO: Investigate failures:
// 1) harness sends a request with an invalid tracestate header with duplicated keys ... FAIL
// 2) harness sends an invalid traceparent with illegal characters in trace_flags ... FAIL
string lastLine = ParseLastLine(result); string lastLine = ParseLastLine(result);
this.output.WriteLine("result:" + result); this.output.WriteLine("result:" + result);
// Assert on the last line
// TODO: Investigate failures on .NET6 vs .NET7. To see the details
// run the tests with console logger (done automatically by the CI
// jobs).
if (AspNetCoreHostingVersion.Major <= 6)
{
Assert.StartsWith("FAILED (failures=5)", lastLine);
}
else
{
Assert.StartsWith("FAILED (failures=3)", lastLine); Assert.StartsWith("FAILED (failures=3)", lastLine);
} }
}
private static string RunCommand(string command, string args) private static string RunCommand(string command, string args)
{ {