refactor: consolidate .NET Framework testing into unified script #202
This file contains hidden or 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: .NET Core | |
| on: | |
| release: | |
| types: [published] | |
| push: | |
| branches: | |
| - "*" | |
| tags-ignore: | |
| - "*" | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| CORE_SLN: ./src/Imageflow.dncore.sln | |
| FULL_SLN: ./src/Imageflow.dnfull.sln | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-13 | |
| - os: ubuntu-latest | |
| test_aot: false | |
| rid: linux-x64 | |
| - os: ubuntu-latest | |
| SystemTextJsonVersion: 8.0.1 | |
| - os: windows-latest | |
| pack: true | |
| docs: true | |
| coverage: true | |
| test_legacy: true | |
| test_aot: false | |
| rid: win-x64 | |
| - os: windows-11-arm | |
| test_aot: false | |
| rid: win-arm64 | |
| - os: macos-14 | |
| test_aot: false | |
| rid: osx-arm64 | |
| - os: ubuntu-22.04-arm | |
| test_aot: false | |
| rid: linux-arm64 | |
| runs-on: ${{matrix.os}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
| - name: Setup .NET 6,8,9 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-quality: 'preview' | |
| dotnet-version: | | |
| 6 | |
| 8 | |
| 9 | |
| 10 | |
| - uses: nowsprinting/[email protected] | |
| id: version | |
| with: | |
| prefix: "v" | |
| - name: For releases only - set TAGGED_VERSION and ARTIFACT_VERSION | |
| run: | | |
| echo "TAGGED_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV | |
| echo "ARTIFACT_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV | |
| echo Set version to ${{ steps.version.outputs.full_without_prefix }} | |
| shell: bash | |
| if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release' | |
| - name: Set ARTIFACT_VERSION to commit-${{ github.sha }} for non-release builds | |
| run: | | |
| echo "ARTIFACT_VERSION=commit-${{ github.sha }}" >> $GITHUB_ENV | |
| echo Set ARTIFACT_VERSION to commit-${{ github.sha }} | |
| shell: bash | |
| if: steps.version.outputs.is_valid == 'false' || github.event_name != 'release' | |
| - run: | | |
| dotnet clean ${{ env.CORE_SLN }} --configuration Release | |
| dotnet nuget locals all --clear | |
| if: github.event_name == 'release' | |
| - name: Test with ${{ matrix.SystemTextJsonVersion }} and ${{ matrix.RecyclableMemoryStreamVersion }} | |
| if: matrix.SystemTextJsonVersion != null && matrix.RecyclableMemoryStreamVersion != null | |
| run: | | |
| dotnet test ${{ env.CORE_SLN }} -p:SystemTextJsonVersion=${{ matrix.SystemTextJsonVersion }} -p:RecyclableMemoryStreamVersion=${{ matrix.RecyclableMemoryStreamVersion }} -c Release | |
| - name: Install dependencies | |
| run: dotnet restore ${{ env.CORE_SLN }} --force-evaluate | |
| - name: Build all modern dotnet projects | |
| run: dotnet build ${{ env.CORE_SLN }} --maxcpucount:1 -c Release | |
| - name: Test, relying on projects to only conditionally enable net48 TFMs on windows | |
| if: matrix.coverage == false | |
| run: | | |
| dotnet test ${{ env.CORE_SLN }} -c Release | |
| - name: Test with coverage | |
| if: matrix.coverage | |
| run: | | |
| dotnet test ${{ env.CORE_SLN }} -c Release --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover | |
| - uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }} | |
| path: TestResults/ | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| if: matrix.coverage | |
| with: | |
| files: ./**/coverage.opencover.xml | |
| token: ${{ secrets.CODECOV_TOKEN }} # replace with your Codecov token | |
| fail_ci_if_error: false | |
| # - uses: actions/upload-artifact@v3 | |
| # if: failure() | |
| # with: | |
| # name: TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }} | |
| # path: TestResults/ | |
| - name: Pack | |
| run: | | |
| dotnet pack ./src/Imageflow/Imageflow.Net.csproj -c Release --include-source -o NuGetPackages/Release/ | |
| dotnet pack ./src/Imageflow.AllPlatforms/Imageflow.AllPlatforms.csproj -c Release --include-source -o NuGetPackages/Release/ | |
| if: matrix.pack | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| id: nuget-artifact-upload-step | |
| if: matrix.pack | |
| with: | |
| name: NuGetPackages | |
| path: | | |
| NuGetPackages/Release/*.nupkg | |
| NuGetPackages/Release/*.snupkg | |
| - name: Add msbuild to PATH | |
| uses: microsoft/[email protected] | |
| if: matrix.os == 'windows-latest' && matrix.test_legacy | |
| - name: Test win_x86 | |
| if: matrix.test_legacy | |
| run: | | |
| dotnet test ${{ env.CORE_SLN }} -c Release --arch x86 | |
| - name: Build and test .NET Framework projects | |
| if: matrix.test_legacy | |
| shell: pwsh | |
| run: | | |
| ./test_dotnet_framework.ps1 -Solution "${{ env.FULL_SLN }}" -SkipPack | |
| - name: Test use in an AOT web app | |
| if: matrix.test_aot | |
| shell: pwsh | |
| run: ./tests/Imageflow.TestWebAOT/test.ps1 ${{ matrix.rid }} | |
| publish: | |
| needs: build | |
| if: github.event_name == 'release' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: nowsprinting/check-version-format-action@v3 | |
| id: version | |
| with: | |
| prefix: "v" | |
| # Download nuget artifacts from the test job into a folder called NuGetPackages | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release' | |
| with: | |
| name: NuGetPackages | |
| path: NuGetPackages | |
| - name: Publish NuGet packages to Nuget.org | |
| if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release' | |
| run: | | |
| dotnet nuget push NuGetPackages/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json |