Skip to content

ci: Add TLS support for Mock #13

ci: Add TLS support for Mock

ci: Add TLS support for Mock #13

Workflow file for this run

name: Tests
on:
pull_request:
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
jobs:
certs:
name: Generate certificates
runs-on: ubuntu-latest
outputs:
client-ca_key: ${{ steps.certs.outputs.client-ca_key }}
client-ca_pem: ${{ steps.certs.outputs.client-ca_pem }}
client_key: ${{ steps.certs.outputs.client_key }}
client_pem: ${{ steps.certs.outputs.client_pem }}
server-ca_key: ${{ steps.certs.outputs.server-ca_key }}
server-ca_pem: ${{ steps.certs.outputs.server-ca_pem }}
server_key: ${{ steps.certs.outputs.server_key }}
server_pem: ${{ steps.certs.outputs.server_pem }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Generate certificates
id: certs
run: |
mkdir certs
cd certs
../scripts/certs.sh
for file in *; do
echo "${file//./_}<<EOF"
cat "$file"
echo "EOF"
done >> "$GITHUB_OUTPUT"
csharp:
name: Test C#
needs:
- certs
strategy:
fail-fast: false
matrix:
dotnet:
- version: ""
framework: "net4.7"
- version: ""
framework: "net4.8"
- version: "6.0"
framework: "net6.0"
- version: "8.0"
framework: "net8.0"
platform:
- os: ubuntu-latest
runtime: linux-x64
- os: windows-latest
runtime: windows-x64
exclude:
- dotnet:
version: ""
framework: "net4.7"
platform:
os: ubuntu-latest
runtime: linux-x64
- dotnet:
version: ""
framework: "net4.8"
platform:
os: ubuntu-latest
runtime: linux-x64
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Install certs
working-directory: packages/csharp/
shell: bash
run: |
mkdir certs
cd certs
cat > client-ca.key <<EOF
${{ needs.certs.outputs.client-ca_key }}
EOF
cat > client-ca.pem <<EOF
${{ needs.certs.outputs.client-ca_pem }}
EOF
cat > client.key <<EOF
${{ needs.certs.outputs.client_key }}
EOF
cat > client.pem <<EOF
${{ needs.certs.outputs.client_pem }}
EOF
cat > server-ca.key <<EOF
${{ needs.certs.outputs.server-ca_key }}
EOF
cat > server-ca.pem <<EOF
${{ needs.certs.outputs.server-ca_pem }}
EOF
cat > server.key <<EOF
${{ needs.certs.outputs.server_key }}
EOF
cat > server.pem <<EOF
${{ needs.certs.outputs.server_pem }}
EOF
- name: Install .NET Core
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4
if: ${{ matrix.dotnet.version }} != ""
with:
dotnet-version: ${{ matrix.dotnet.version }}
- name: Test
working-directory: packages/csharp/
shell: bash
run: |
export CertFolder="$PWD/certs"
dotnet run --project ArmoniK.Api.Mock -- \
grpc:port=5000 http:port=4999 \
& notls_pid=$!
sleep 5
dotnet run --project ArmoniK.Api.Mock -- \
grpc:port=5001 http:port=5001 \
http:cert="$CertFolder/server.pem" http:key="$CertFolder/server.key" \
& tls_pid=$!
sleep 5
dotnet run --project ArmoniK.Api.Mock -- \
grpc:port=5002 http:port=5002 \
http:cert="$CertFolder/server.pem" http:key="$CertFolder/server.key" http:clientcert="$CertFolder/client-ca.pem" \
& mtls_pid=$!
sleep 5
cd ArmoniK.Api.Client.Test
dotnet test --runtime ${{ matrix.platform.runtime }} -f ${{ matrix.dotnet.framework }} --logger "trx;LogFileName=test-results.trx"; ret=$?
kill $notls_pid $tls_pid $mtls_pid
exit $ret
- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: ConnectivityTests ${{ matrix.platform.runtime }} ${{ matrix.dotnet.framework }}
path: ./packages/csharp/ArmoniK.Api.Client.Test/TestResults/test-results.trx
reporter: dotnet-trx