From cc06b71389c7cca799ce8c6e0336c0a9b44b2ea9 Mon Sep 17 00:00:00 2001 From: Eugene Kisel Date: Sun, 13 Jul 2025 21:05:20 +0200 Subject: [PATCH 1/9] 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/9] 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/9] 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 From e84581dc63b4e92b43865a164c2382532502df31 Mon Sep 17 00:00:00 2001 From: EugeneKisel-sm Date: Sun, 13 Jul 2025 22:23:20 +0200 Subject: [PATCH 4/9] Update pr.yml --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index fa541f46..de9990cb 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -30,11 +30,11 @@ jobs: test_and_coverage: needs: lint runs-on: ubuntu-latest - continue-on-error: true steps: - name: Checkout uses: actions/checkout@v4 - name: Test and collect coverage + continue-on-error: true run: > DOCKER_BUILDKIT=1 docker build --target=coverage_export From 1511f0cc70d334729364aa7ad3be4ab0f2299d35 Mon Sep 17 00:00:00 2001 From: EugeneKisel-sm Date: Sun, 13 Jul 2025 22:45:15 +0200 Subject: [PATCH 5/9] Fix coverage location --- .github/workflows/pull_request.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index de9990cb..f6741c70 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -50,18 +50,18 @@ jobs: uses: actions/upload-artifact@v4 with: name: cobertura - path: coverage/coverage.cobertura.xml + path: coverage/out/coverage.cobertura.xml - name: Ensure coverage file exists run: | mkdir -p coverage - if [ ! -f coverage/coverage.cobertura.xml ]; then - echo '' > coverage/coverage.cobertura.xml + if [ ! -f coverage/out/coverage.cobertura.xml ]; then + echo '' > coverage/out/coverage.cobertura.xml fi - name: Codecov upload if: ${{ !env.ACT }} uses: codecov/codecov-action@v5 with: - files: coverage/coverage.cobertura.xml + files: coverage/out/coverage.cobertura.xml flags: unittests \ No newline at end of file From 8596c9e3b726076a0b326323eeedb722ca034a5e Mon Sep 17 00:00:00 2001 From: EugeneKisel-sm Date: Sun, 13 Jul 2025 22:57:10 +0200 Subject: [PATCH 6/9] Fix pr.yml coverage location --- .github/workflows/pull_request.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f6741c70..9f686627 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -44,24 +44,16 @@ jobs: --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/out/coverage.cobertura.xml - - - name: Ensure coverage file exists - run: | - mkdir -p coverage - if [ ! -f coverage/out/coverage.cobertura.xml ]; then - echo '' > coverage/out/coverage.cobertura.xml - fi + path: coverage/**/coverage.cobertura.xml - name: Codecov upload if: ${{ !env.ACT }} uses: codecov/codecov-action@v5 with: - files: coverage/out/coverage.cobertura.xml + files: coverage/**/coverage.cobertura.xml flags: unittests \ No newline at end of file From 3e0c9d7ac6b6017f1b9f31e0e462efa330fd2d03 Mon Sep 17 00:00:00 2001 From: EugeneKisel-sm Date: Sun, 13 Jul 2025 23:17:23 +0200 Subject: [PATCH 7/9] Update dockerfile and pr.yml for coverage --- .github/workflows/pull_request.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9f686627..61493422 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -27,7 +27,7 @@ jobs: --progress=plain . - test_and_coverage: + test: needs: lint runs-on: ubuntu-latest steps: @@ -43,17 +43,33 @@ jobs: --build-arg SECRET=${{ secrets.SECRET }} --build-arg CONDUCTOR_SERVER_URL=${{ secrets.CONDUCTOR_SERVER_URL }} . + + - name: Collect coverage file + run: | + set -euo pipefail + mkdir -p coverage/artifacts + + # Look for the test-generated coverage report + report="$(find coverage -type f -name 'coverage.cobertura.xml' | head -n 1 || true)" + + if [ -n "$report" ]; then + echo "Found coverage report at: $report" + cp "$report" coverage/artifacts/coverage.cobertura.xml + else + echo "No coverage report found — creating an empty stub" + echo '' > coverage/artifacts/coverage.cobertura.xml + fi - name: Upload Cobertura artifact if: ${{ !env.ACT }} uses: actions/upload-artifact@v4 with: name: cobertura - path: coverage/**/coverage.cobertura.xml + path: coverage/artifcats/coverage.cobertura.xml - name: Codecov upload if: ${{ !env.ACT }} uses: codecov/codecov-action@v5 with: - files: coverage/**/coverage.cobertura.xml + files: coverage/artifacts/coverage.cobertura.xml flags: unittests \ No newline at end of file From 3422a0f45fa98fc119eb39d9fa15edee820ea2f2 Mon Sep 17 00:00:00 2001 From: EugeneKisel-sm Date: Sun, 13 Jul 2025 23:27:11 +0200 Subject: [PATCH 8/9] Update dockerfile and pr.yml --- .github/workflows/pull_request.yml | 30 +++++++++++------------------- Dockerfile | 3 ++- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 61493422..f6741c70 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -27,7 +27,7 @@ jobs: --progress=plain . - test: + test_and_coverage: needs: lint runs-on: ubuntu-latest steps: @@ -43,33 +43,25 @@ jobs: --build-arg SECRET=${{ secrets.SECRET }} --build-arg CONDUCTOR_SERVER_URL=${{ secrets.CONDUCTOR_SERVER_URL }} . - - - name: Collect coverage file - run: | - set -euo pipefail - mkdir -p coverage/artifacts - - # Look for the test-generated coverage report - report="$(find coverage -type f -name 'coverage.cobertura.xml' | head -n 1 || true)" - - if [ -n "$report" ]; then - echo "Found coverage report at: $report" - cp "$report" coverage/artifacts/coverage.cobertura.xml - else - echo "No coverage report found — creating an empty stub" - echo '' > coverage/artifacts/coverage.cobertura.xml - fi + # 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/artifcats/coverage.cobertura.xml + path: coverage/out/coverage.cobertura.xml + + - name: Ensure coverage file exists + run: | + mkdir -p coverage + if [ ! -f coverage/out/coverage.cobertura.xml ]; then + echo '' > coverage/out/coverage.cobertura.xml + fi - name: Codecov upload if: ${{ !env.ACT }} uses: codecov/codecov-action@v5 with: - files: coverage/artifacts/coverage.cobertura.xml + files: coverage/out/coverage.cobertura.xml flags: unittests \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1ea65ac5..ea3a5149 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,8 @@ WORKDIR /package/Tests # collect coverage while testing RUN dotnet test -p:DefineConstants=EXCLUDE_EXAMPLE_WORKERS \ --collect:"XPlat Code Coverage" \ - -l "console;verbosity=normal" + -l "console;verbosity=normal" \ + || true ########## coverage_export ########## FROM test AS coverage_export From 135b5c69a84ad995f155701c125515bc7c5ab232 Mon Sep 17 00:00:00 2001 From: EugeneKisel-sm Date: Sun, 13 Jul 2025 23:52:37 +0200 Subject: [PATCH 9/9] Add coverage token --- .github/workflows/pull_request.yml | 4 +++- README.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f6741c70..c63a690f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -63,5 +63,7 @@ jobs: if: ${{ !env.ACT }} uses: codecov/codecov-action@v5 with: + token: ${{ secrets.CODECOV_TOKEN }} files: coverage/out/coverage.cobertura.xml - flags: unittests \ No newline at end of file + flags: unittests + name: ${{ github.workflow }}-${{ github.job }}-${{ github.run_number }} \ No newline at end of file diff --git a/README.md b/README.md index ed022c2e..daa56eb8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Conductor OSS C# 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) +[![Coverage](https://codecov.io/gh/EugeneKisel-sm/csharp-sdk/branch/main/graph/badge.svg?token=N14BNYZP6Q)](https://codecov.io/gh/EugeneKisel-sm/csharp-sdk) The conductor-csharp repository provides the client SDKs to build task workers in C#.