From b281ecc5696ff4a74de02491004da1b7d6184c38 Mon Sep 17 00:00:00 2001 From: Christian Engelhardt Date: Mon, 11 Sep 2023 13:31:18 +0200 Subject: [PATCH] ci: add matrix tests and separate the build job --- .github/workflows/pipeline.yml | 58 +++++++++++++++++++++------------- libNOM.test/libNOM.test.csproj | 3 +- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index a028b8b..65a4896 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -8,53 +8,67 @@ on: create: jobs: - build: - name: Build and Test - runs-on: ubuntu-latest + test: + name: Test + strategy: + matrix: + framwork: [net6.0, net7.0] + os: [windows-latest, macos-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} steps: + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + dotnet-quality: ga - name: Checkout uses: actions/checkout@v3 + - name: Cache + uses: actions/cache@v3 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: ${{ runner.os }}-nuget- + - name: Unit Test + run: dotnet test libNOM.test --configuration Debug --framework ${{ matrix.framwork }} + build: + name: Build + runs-on: ubuntu-latest + steps: - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 7.0.x dotnet-quality: ga + - name: Checkout + uses: actions/checkout@v3 - name: Cache uses: actions/cache@v3 with: path: ~/.nuget/packages key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} restore-keys: ${{ runner.os }}-nuget- - - name: Dependencies - run: dotnet restore - - name: Unit Test - run: | - dotnet test libNOM.test --no-restore --configuration Debug --framework netstandard2.0 - dotnet test libNOM.test --no-restore --configuration Debug --framework netstandard2.1 - dotnet test libNOM.test --no-restore --configuration Debug --framework net6.0 - dotnet test libNOM.test --no-restore --configuration Debug --framework net7.0 - name: Pack - run: dotnet pack libNOM.map --no-restore --configuration Release + run: dotnet pack libNOM.map --configuration Release - name: Upload uses: actions/upload-artifact@v3 with: - name: libNOM.map NuGet - path: libNOM.map/bin/Release/libNOM.map.*nupkg + name: NuGet + path: | + ./.github/changelogs/ + ./libNOM.map/bin/Release/libNOM.map.*nupkg if-no-files-found: error release: name: Release runs-on: ubuntu-latest # Only if commit was tagged. if: ${{ startsWith(github.ref, 'refs/tags/') }} - needs: build + needs: [test, build] steps: - # Checkout again to access the changelog. - - name: Checkout - uses: actions/checkout@v3 - name: Download uses: actions/download-artifact@v3 with: - name: libNOM.map NuGet + name: NuGet - name: Version run: echo "nupkg_version=$((((Get-Item -Path .\libNOM.map.*.nupkg).Name -split '\.',3)[2] -split '\.',-2)[0])" >> $env:GITHUB_ENV shell: pwsh @@ -67,7 +81,7 @@ jobs: - name: Create uses: softprops/action-gh-release@v1 with: - body_path: ${{ github.workspace }}/.github/changelogs/${{ github.ref_name }}.md - files: libNOM.map.*nupkg + body_path: ./.github/changelogs/${{ github.ref_name }}.md + files: ./libNOM.map.*nupkg - name: Publish - run: dotnet nuget push ./libNOM.map.*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} + run: dotnet nuget push ./libNOM.map/bin/Release/libNOM.map.*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} diff --git a/libNOM.test/libNOM.test.csproj b/libNOM.test/libNOM.test.csproj index 49a2789..9b809c9 100644 --- a/libNOM.test/libNOM.test.csproj +++ b/libNOM.test/libNOM.test.csproj @@ -2,7 +2,8 @@ - netstandard2.0;netstandard2.1;net6.0;net7.0 + net6.0;net7.0 + true