test: Using github matrix to run mock tests #821
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: test-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Test API | |
strategy: | |
fail-fast: false | |
matrix: | |
language: | |
- lang: C# | |
dir: csharp/ArmoniK.Api.Client.Test | |
cmd: dotnet test | |
- lang: C++ | |
dir: cpp | |
cmd: echo "Test C++" | |
- lang: Python | |
dir: python | |
cmd: pytest tests --cov=armonik --cov-config=.coveragerc --cov-report=term-missing | |
include: | |
- lang: C# | |
dir: csharp/ArmoniK.Api.Client.Test | |
cmd: dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx" | |
dotnet: | |
version: '' | |
framework: net4.7 | |
platform: | |
os: ubuntu-latest | |
runtime: linux-x64 | |
handler: '' | |
name: C#-net4.7-ubuntu | |
- lang: C# | |
dir: csharp/ArmoniK.Api.Client.Test | |
cmd: dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx" | |
dotnet: | |
version: '' | |
framework: net4.8 | |
platform: | |
os: windows-2019 | |
runtime: windows-x64 | |
handler: '' | |
name: C#-net4.8-windows-2019 | |
- lang: C# | |
dir: csharp/ArmoniK.Api.Client.Test | |
cmd: dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx" | |
dotnet: | |
version: 6.0 | |
framework: net6.0 | |
platform: | |
os: ubuntu-latest | |
runtime: linux-x64 | |
handler: '' | |
name: C#-net6.0-ubuntu | |
- lang: C# | |
dir: csharp/ArmoniK.Api.Client.Test | |
cmd: dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx" | |
dotnet: | |
version: 8.0 | |
framework: net8.0 | |
platform: | |
os: windows-2022 | |
runtime: windows-x64 | |
handler: GrpcWebHandler | |
name: C#-net8.0-windows-2022 | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate certs | |
working-directory: packages/csharp/ | |
shell: bash | |
run: | | |
mkdir certs | |
cd certs | |
../../../scripts/certs.sh | |
- name: Install certs | |
if: ${{ matrix.platform.os == 'ubuntu-latest' }} | |
working-directory: packages/csharp/certs | |
run: | | |
sudo apt install ca-certificates | |
sudo mkdir -p /usr/local/share/ca-certificates/ | |
sudo cp server2-ca.pem /usr/local/share/ca-certificates/ca.crt | |
sudo update-ca-certificates | |
- name: Install certs | |
if: ${{ contains(matrix.platform.os, 'windows') }} | |
working-directory: packages/csharp/certs | |
run: | | |
certutil -addstore -f "ROOT" server2-ca.pem | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4 | |
if: ${{ matrix.dotnet.version }} != "" | |
with: | |
dotnet-version: ${{ matrix.dotnet.version }} | |
- name: Print language | |
run: | | |
echo "Current language: ${{ matrix.language[1].lang }}" | |
- name: pip update and add build package | |
if: ${{ matrix.lang == 'Python' }} | |
working-directory: packages/python | |
run: bash proto2python.sh ~/pyvenv | |
- name: Install python dependencies | |
if: ${{ matrix.lang == 'Python' }} | |
run: pip install "$(echo pkg/armonik*.whl)[tests]" | |
- name: Build C++ package | |
if: ${{ matrix.lang == 'C++' }} | |
working-directory: packages/cpp | |
run: | | |
./tools/run_test.sh | |
- name: Build Mock server | |
working-directory: packages/csharp/ArmoniK.Api.Mock | |
shell: bash | |
run: | | |
dotnet publish -o ../out | |
[ -e ../out/ArmoniK.Api.Mock.exe ] || ln -s ArmoniK.Api.Mock ../out/ArmoniK.Api.Mock.exe | |
- name: noTLS | |
working-directory: packages/csharp/ | |
shell: bash | |
run: | | |
export Grpc__Port=5000 | |
export Http__Port=4999 | |
export Grpc__Endpoint=http://localhost:5000 | |
../../scripts/mock_test.sh ${{ matrix.language.dir }} '${{ matrix.language.cmd }}' | |
- name: TLS secure | |
working-directory: packages/csharp/ | |
shell: bash | |
run: | | |
export Grpc__Port=5001 | |
export Http__Port=5001 | |
export Http__Cert=certs/server1.pem | |
export Http__Key=certs/server1.key | |
export Grpc__Endpoint=https://localhost:5001 | |
export Grpc__CaCert=certs/server1-ca.pem | |
../../scripts/mock_test.sh ${{ matrix.language.dir }} '${{ matrix.language.cmd }} -f ${{ matrix.dotnet.framework }} --logger "trx;LogFileName=test-results.trx"' | |
- name: TLS store | |
working-directory: packages/csharp/ | |
shell: bash | |
run: | | |
export Grpc__Port=5002 | |
export Http__Port=5002 | |
export Http__Cert=certs/server2.pem | |
export Http__Key=certs/server2.key | |
export Grpc__Endpoint=https://localhost:5002 | |
../../scripts/mock_test.sh ${{ matrix.language.dir }} '${{ matrix.language.cmd }} -f ${{ matrix.dotnet.framework }} --logger "trx;LogFileName=test-results.trx"' | |
- name: mTLS secure | |
working-directory: packages/csharp/ | |
shell: bash | |
run: | | |
export Grpc__Port=5003 | |
export Http__Port=5003 | |
export Http__Cert=certs/server1.pem | |
export Http__Key=certs/server1.key | |
export Http__ClientCert=certs/client-ca.pem | |
export Grpc__Endpoint=https://localhost:5003 | |
export Grpc__CaCert=certs/server1-ca.pem | |
export Grpc__ClientCert=certs/client.pem | |
export Grpc__ClientKey=certs/client.key | |
../../scripts/mock_test.sh ${{ matrix.language.dir }} '${{ matrix.language.cmd }} -f ${{ matrix.dotnet.framework }} --logger "trx;LogFileName=test-results.trx"' | |
- name: mTLS store | |
working-directory: packages/csharp/ | |
shell: bash | |
run: | | |
export Grpc__Port=5004 | |
export Http__Port=5004 | |
export Http__Cert=certs/server2.pem | |
export Http__Key=certs/server2.key | |
export Http__ClientCert=certs/client-ca.pem | |
export Grpc__Endpoint=https://localhost:5004 | |
export Grpc__ClientCert=certs/client.pem | |
export Grpc__ClientKey=certs/client.key | |
../../scripts/mock_test.sh ${{ matrix.language.dir }} '${{ matrix.language.cmd }} -f ${{ matrix.dotnet.framework }} --logger "trx;LogFileName=test-results.trx"' | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: ${{ matrix.lang == 'C#' && always() }} | |
with: | |
name: ConnectivityTests ${{ matrix.platform.os }} ${{ matrix.dotnet.framework }} ${{ matrix.handler }} | |
path: ./packages/csharp/ArmoniK.Api.Client.Test/TestResults/test-results.trx | |
reporter: dotnet-trx | |
cpp: | |
strategy: | |
fail-fast: false | |
matrix: | |
endpoint: | |
- mock_env: | |
Grpc__Port: 5000 | |
Http__Port: 4999 | |
test_env: | |
Grpc__Endpoint: http://localhost:5000 | |
Http__Endpoint: http://localhost:4999 | |
- mock_env: | |
Grpc__Port: 5001 | |
Http__Port: 5001 | |
Http__Cert: ../cpp/certs/server1.pem | |
Http__Key: ../cpp/certs/server1.key | |
test_env: | |
Grpc__Endpoint: https://localhost:5001 | |
Grpc__SSLValidation: enable | |
Grpc__CaCert: /app/source/certs/server1-ca.pem | |
- mock_env: | |
Grpc__Port: 5002 | |
Http__Port: 5002 | |
Http__Cert: ../cpp/certs/server2.pem | |
Http__Key: ../cpp/certs/server2.key | |
test_env: | |
Grpc__Endpoint: https://localhost:5002 | |
Grpc__SSLValidation: enable | |
- mock_env: | |
Grpc__Port: 5003 | |
Http__Port: 5003 | |
Http__Cert: ../cpp/certs/server1.pem | |
Http__Key: ../cpp/certs/server1.key | |
Http__ClientCert: ../cpp/certs/client-ca.pem | |
test_env: | |
Grpc__Endpoint: https://localhost:5003 | |
Grpc__SSLValidation: enable | |
Grpc__mTLS: true | |
Grpc__CaCert: /app/source/certs/server1-ca.pem | |
Grpc__ClientCert: /app/source/certs/client.pem | |
Grpc__ClientKey: /app/source/certs/client.key | |
- mock_env: | |
Grpc__Port: 5004 | |
Http__Port: 5004 | |
Http__Cert: ../cpp/certs/server2.pem | |
Http__Key: ../cpp/certs/server2.key | |
Http__ClientCert: ../cpp/certs/client-ca.pem | |
test_env: | |
Grpc__Endpoint: https://localhost:5004 | |
Grpc__SSLValidation: enable | |
Grpc__mTLS: true | |
Grpc__ClientCert: /app/source/certs/client.pem | |
Grpc__ClientKey: /app/source/certs/client.key | |
name: Test C++ | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Generate certs | |
working-directory: packages/cpp/ | |
shell: bash | |
run: | | |
mkdir certs | |
cd certs | |
../../../scripts/certs.sh | |
- name: Install certs | |
working-directory: packages/cpp/certs | |
run: | | |
sudo apt install ca-certificates | |
sudo mkdir -p /usr/local/share/ca-certificates/ | |
sudo cp server2-ca.pem /usr/local/share/ca-certificates/ca.crt | |
sudo update-ca-certificates | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4 | |
with: | |
dotnet-version: 8.x | |
- name: Build Mock server | |
working-directory: packages/csharp/ArmoniK.Api.Mock | |
shell: bash | |
run: | | |
dotnet publish -o ../out | |
[ -e ../out/ArmoniK.Api.Mock.exe ] || ln -s ArmoniK.Api.Mock ../out/ArmoniK.Api.Mock.exe | |
- name: Run Mock servers | |
working-directory: packages/csharp/ | |
shell: bash | |
env: ${{ matrix.endpoint.mock_env }} | |
run: | | |
export CertFolder="$PWD/../cpp/certs" | |
./out/ArmoniK.Api.Mock.exe > mock.log 2>&1 & | |
echo "server_pid=$!" >> $GITHUB_ENV | |
sleep 5 | |
- name: Build Test | |
working-directory: packages/cpp | |
run: | | |
./tools/run_test.sh | |
- name: Run Test | |
env: ${{ matrix.endpoint.test_env }} | |
run: | | |
echo "$PWD/packages/cpp/certs" | |
docker run --rm -t --network host -v "$PWD/packages/cpp/certs:/app/source/certs" -v "/usr/local/share/ca-certificates/:/usr/local/share/ca-certificates" \ | |
-e Grpc__EndPoint="$Grpc__Endpoint" \ | |
-e Http__EndPoint="${Http__Endpoint:-$Grpc__Endpoint}" \ | |
${Grpc__SSLValidation:+-e Grpc__SSLValidation="$Grpc__SSLValidation"} \ | |
${Grpc__CaCert:+-e Grpc__CaCert="$Grpc__CaCert"} \ | |
${Grpc__mTLS:+-e Grpc__mTLS="$Grpc__mTLS"} \ | |
${Grpc__ClientCert:+-e Grpc__ClientCert="$Grpc__ClientCert"} \ | |
${Grpc__ClientKey:+-e Grpc__ClientKey="$Grpc__ClientKey"} \ | |
"armonik-api-cpp:0.1.0" | |
- name: Stop Mock Server | |
if: always() | |
working-directory: packages/csharp/ | |
run: | | |
kill $server_pid || true | |
cat mock.log |