From 2fcfe60620b27fe485634c648a5e19c19753ee63 Mon Sep 17 00:00:00 2001 From: Dennis Dyall Date: Tue, 30 Apr 2024 13:19:14 +0200 Subject: [PATCH] Runnng matrix strategy to test all platforms --- .github/workflows/test-and-cover.yml | 40 +++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-and-cover.yml b/.github/workflows/test-and-cover.yml index 3109c3b5..4f6338e7 100644 --- a/.github/workflows/test-and-cover.yml +++ b/.github/workflows/test-and-cover.yml @@ -30,6 +30,7 @@ on: push: branches: - main + - develop paths: - '**.h' - '**.c' @@ -40,7 +41,11 @@ on: jobs: test: - runs-on: windows-2019 + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 @@ -50,16 +55,34 @@ jobs: - name: Add local NuGet repository run: dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Yubico/index.json" + - name: Install OpenSSL and link for macOS + if: matrix.os == 'macos-latest' + run: | + brew install openssl + sudo mkdir /usr/local/lib + sudo ln -s $(brew --prefix)/opt/openssl@3/lib/libcrypto.3.dylib /usr/local/lib/libcrypto.3.dylib + sudo ln -s $(brew --prefix)/opt/openssl@3/lib/libssl.3.dylib /usr/local/lib/libssl.3.dylib + + - name: Install PCSC and link libUdev for Ubuntu + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update && sudo apt-get install pcscd -yq + sudo ln -s /usr/lib/x86_64-linux-gnu/libudev.so.1 /usr/lib/libudev.so + + - name: Restore dotnet dependencies + run: | + dotnet restore + - name: Test Yubico.YubiKey - run: dotnet test --configuration Release --nologo --logger trx --collect:"XPlat Code Coverage" Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj --settings coverlet.runsettings.xml + run: dotnet test --no-restore --nologo --logger trx --collect:"XPlat Code Coverage" Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj --settings coverlet.runsettings.xml - name: Test Yubico.Core - run: dotnet test --configuration Release --nologo --logger trx --collect:"XPlat Code Coverage" Yubico.Core/tests/Yubico.Core.UnitTests.csproj --settings coverlet.runsettings.xml + run: dotnet test --no-restore --nologo --logger trx --collect:"XPlat Code Coverage" Yubico.Core/tests/Yubico.Core.UnitTests.csproj --settings coverlet.runsettings.xml - name: Upload Test Result Files uses: actions/upload-artifact@v4 with: - name: TestResults + name: TestResults-${{ matrix.os }} if-no-files-found: error path: '**/TestResults/*' @@ -68,9 +91,6 @@ jobs: needs: test steps: - uses: actions/download-artifact@v4 - with: - name: TestResults - path: ${{ github.workspace }} - name: Combine Coverage Reports # This is because one report is produced per project, and we want one result for all of them. uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4 @@ -110,6 +130,7 @@ jobs: contents: read checks: write needs: coverage + if: github.event_name == 'pull_request' steps: - name: Download coverage results uses: actions/download-artifact@v4 @@ -121,7 +142,6 @@ jobs: - name: Add Coverage PR Comment uses: marocchino/sticky-pull-request-comment@v2.9.0 - if: github.event_name == 'pull_request' with: recreate: true path: code-coverage-results.md @@ -133,12 +153,14 @@ jobs: contents: read checks: write needs: test + if: github.event_name == 'pull_request' steps: - uses: actions/download-artifact@v4 + - name: run ls recursively run: ls -R + - name: Add Test Results PR Comment uses: EnricoMi/publish-unit-test-result-action@v2.16.1 - if: always() with: trx_files: "${{ github.workspace }}/**/*.trx" \ No newline at end of file