diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index bb0eed7..294142f 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -1,5 +1,9 @@
name: CI Build
+concurrency:
+ group: ci-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
on:
push:
branches:
@@ -14,23 +18,50 @@ 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
+ continue-on-error: true
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 }}
.
+
+ - 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
+
+ - name: Codecov upload
+ if: ${{ !env.ACT }}
+ uses: codecov/codecov-action@v5
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ files: coverage/out/coverage.cobertura.xml
+ flags: unittests
+ name: ${{ github.workflow }}-${{ github.job }}-${{ github.run_number }}
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 5d205fa..4e8255f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,27 +10,37 @@ 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"
+RUN dotnet test -p:DefineConstants=EXCLUDE_EXAMPLE_WORKERS \
+ --collect:"XPlat Code Coverage" \
+ -l "console;verbosity=normal" \
+ || true
+
+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 f1188ff..d893681 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
# Conductor OSS C# SDK
+[](https://github.com/conductor-oss/csharp-sdk/actions)
+[](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 aaf0620..e08fd0d 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
+