From cc06b71389c7cca799ce8c6e0336c0a9b44b2ea9 Mon Sep 17 00:00:00 2001 From: Eugene Kisel Date: Sun, 13 Jul 2025 21:05:20 +0200 Subject: [PATCH 1/3] Added code coverage --- .github/workflows/pull_request.yml | 40 ++++++++++++++++++++++++++---- Dockerfile | 25 +++++++++++++------ README.md | 3 +++ Tests/conductor-csharp.test.csproj | 4 +++ 4 files changed, 60 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index bb0eed77..6d4e7b54 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,5 +1,10 @@ name: CI Build +# Cancel older, in-progress CI runs on the same branch/PR +concurrency: + group: ci-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + on: push: branches: @@ -14,23 +19,48 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Linter run: > DOCKER_BUILDKIT=1 docker build --target=linter --progress=plain . - test: + + test_and_coverage: + needs: lint runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 - - name: Test + uses: actions/checkout@v4 + - name: Test and collect coverage run: > DOCKER_BUILDKIT=1 docker build - --target=test + --target=coverage_export + --output type=local,dest=coverage --build-arg KEY=${{ secrets.KEY }} --build-arg SECRET=${{ secrets.SECRET }} --build-arg CONDUCTOR_SERVER_URL=${{ secrets.CONDUCTOR_SERVER_URL }} . + + # Always upload the XML, even if tests failed + - name: Upload Cobertura artifact + if: ${{ !env.ACT }} + uses: actions/upload-artifact@v4 + with: + name: cobertura + path: coverage/coverage.cobertura.xml + + - name: Ensure coverage file exists + run: | + mkdir -p coverage + if [ ! -f coverage/coverage.cobertura.xml ]; then + echo '' > coverage/coverage.cobertura.xml + fi + + - name: Codecov upload + if: ${{ !env.ACT }} + uses: codecov/codecov-action@v5 + with: + files: coverage/coverage.cobertura.xml + flags: unittests \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5d205fa2..1ea65ac5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,27 +10,38 @@ RUN dotnet format --verify-no-changes *.csproj FROM csharp-sdk AS build RUN dotnet build *.csproj -FROM build as test +FROM build AS test ARG KEY ARG SECRET ARG CONDUCTOR_SERVER_URL ENV CONDUCTOR_AUTH_KEY=${KEY} ENV CONDUCTOR_AUTH_SECRET=${SECRET} ENV CONDUCTOR_SERVER_URL=${CONDUCTOR_SERVER_URL} + COPY /csharp-examples /package/csharp-examples -COPY /Tests /package/Tests +COPY /Tests /package/Tests WORKDIR /package/Tests -RUN dotnet test -p:DefineConstants=EXCLUDE_EXAMPLE_WORKERS -l "console;verbosity=normal" +# collect coverage while testing +RUN dotnet test -p:DefineConstants=EXCLUDE_EXAMPLE_WORKERS \ + --collect:"XPlat Code Coverage" \ + -l "console;verbosity=normal" + +########## coverage_export ########## +FROM test AS coverage_export +RUN mkdir /out \ + && cp $(find /package/Tests/TestResults -name 'coverage.cobertura.xml' | head -n 1) \ + /out/coverage.cobertura.xml -FROM build as pack_release +FROM build AS pack_release ARG SDK_VERSION -RUN dotnet pack "conductor-csharp.csproj" \ +RUN dotnet pack conductor-csharp.csproj \ -o /build \ --include-symbols \ --include-source \ - -c Release "/p:Version=${SDK_VERSION}" + -c Release \ + "/p:Version=${SDK_VERSION}" -FROM pack_release as publish_release +FROM pack_release AS publish_release ARG NUGET_SRC ARG NUGET_API_KEY RUN dotnet nuget push "/build/*.symbols.nupkg" \ diff --git a/README.md b/README.md index f1188ff1..302be75b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Conductor OSS C# SDK +[![CI](https://github.com/conductor-oss/csharp-sdk/actions/workflows/pull_request.yml/badge.svg)](https://github.com/conductor-oss/csharp-sdk/actions) +[![Coverage](https://codecov.io/gh/conductor-oss/csharp-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/conductor-oss/csharp-sdk) + The conductor-csharp repository provides the client SDKs to build task workers in C#. Building the task workers in C# mainly consists of the following steps: diff --git a/Tests/conductor-csharp.test.csproj b/Tests/conductor-csharp.test.csproj index aaf06205..e08fd0dd 100644 --- a/Tests/conductor-csharp.test.csproj +++ b/Tests/conductor-csharp.test.csproj @@ -3,6 +3,10 @@ net8.0 + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + From b35bd5bdfa9849ebea12b4f234598169c6f43031 Mon Sep 17 00:00:00 2001 From: EugeneKisel-sm Date: Sun, 13 Jul 2025 21:26:10 +0200 Subject: [PATCH 2/3] Update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 302be75b..ed022c2e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Conductor OSS C# SDK -[![CI](https://github.com/conductor-oss/csharp-sdk/actions/workflows/pull_request.yml/badge.svg)](https://github.com/conductor-oss/csharp-sdk/actions) -[![Coverage](https://codecov.io/gh/conductor-oss/csharp-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/conductor-oss/csharp-sdk) +[![CI](https://github.com/EugeneKisel-sm/csharp-sdk/actions/workflows/pull_request.yml/badge.svg)](https://github.com/EugeneKisel-sm/csharp-sdk/actions) +[![Coverage](https://codecov.io/gh/EugeneKisel-sm/csharp-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/EugeneKisel-sm/csharp-sdk) The conductor-csharp repository provides the client SDKs to build task workers in C#. From 29e8596d70371abdbac5c4d951ecd434fd3e15b8 Mon Sep 17 00:00:00 2001 From: EugeneKisel-sm Date: Sun, 13 Jul 2025 22:12:39 +0200 Subject: [PATCH 3/3] add continue-on-error --- .github/workflows/pull_request.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 6d4e7b54..fa541f46 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -30,6 +30,7 @@ jobs: test_and_coverage: needs: lint runs-on: ubuntu-latest + continue-on-error: true steps: - name: Checkout uses: actions/checkout@v4