Use docker for testing AOT compilation and container scenarios #389
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: CI | |
on: | |
workflow_dispatch: | |
inputs: | |
build_configuration: | |
type: choice | |
description: Build configuration | |
options: | |
- Debug | |
- Release | |
required: true | |
default: 'Debug' | |
run_build: | |
type: boolean | |
description: Run build | |
required: true | |
default: true | |
run_tests: | |
type: boolean | |
description: Run tests | |
required: true | |
default: true | |
run_docker: | |
type: boolean | |
description: Run docker tests | |
required: true | |
default: true | |
generate_assets: | |
type: boolean | |
description: Generate assets from test runs | |
required: true | |
default: false | |
publish_testresults: | |
type: boolean | |
description: Publish test results | |
required: true | |
default: true | |
run_sonarcloud: | |
type: boolean | |
description: Run SonarCloud | |
required: true | |
default: true | |
push: | |
branches: | |
- 'master' | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
build: | |
name: Build | |
runs-on: windows-latest | |
if: (github.event_name != 'workflow_dispatch' && true || inputs.run_build) == true | |
permissions: | |
id-token: write | |
contents: read | |
attestations: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@main | |
with: | |
msbuild-architecture: x64 | |
- name: Setup .NET 6 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 6.x | |
- name: Setup .NET 7 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 7.x | |
- name: Setup .NET 8 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 8.x | |
- name: Setup .NET workload android | |
run: dotnet workload install android | |
- name: Setup .NET workload maui-android | |
run: dotnet workload install maui-android | |
- name: Setup .NET workload ios | |
run: dotnet workload install ios | |
- name: Setup .NET workload maui-ios | |
run: dotnet workload install maui-ios | |
- name: Setup .NET workload maccatalyst | |
run: dotnet workload install maccatalyst | |
- name: Setup .NET workload maui-maccatalyst | |
run: dotnet workload install maui-maccatalyst | |
- name: Setup .NET workload maui-windows | |
run: dotnet workload install maui-windows | |
- name: Setup .NET workload wasm-tools | |
run: dotnet workload install wasm-tools | |
- name: Setup JDK 17 | |
uses: actions/setup-java@main | |
with: | |
java-version: 17 | |
java-package: jdk | |
distribution: 'zulu' | |
- name: Setup Android SDK 29 | |
run: C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-29" | |
- name: Setup Windows 11 SDK (10.0.26100.0) | |
uses: GuillaumeFalourd/setup-windows10-sdk-action@main | |
with: | |
sdk-version: 26100 | |
- name: Restore | |
run: msbuild src/PDFtoImage.Build.slnf /t:restore | |
- name: Build | |
run: msbuild src/PDFtoImage.Build.slnf /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} /p:VersionSuffix=ci /p:RestorePackages=false | |
- name: Pack | |
run: msbuild src/PDFtoImage/PDFtoImage.csproj /t:pack /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} /p:VersionSuffix=ci /p:RestorePackages=false | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@main | |
with: | |
subject-path: src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.nupkg | |
- name: Publish libraries | |
uses: actions/upload-artifact@main | |
with: | |
name: Library assemblies | |
path: | | |
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} | |
!**/*.nupkg | |
!**/*.snupkg | |
if-no-files-found: error | |
- name: Publish NuGet packages | |
uses: actions/upload-artifact@main | |
with: | |
name: NuGet packages | |
path: | | |
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.nupkg | |
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.snupkg | |
if-no-files-found: error | |
- name: Publish tests | |
uses: actions/upload-artifact@main | |
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true | |
with: | |
name: Test assemblies | |
path: src/Tests/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} | |
if-no-files-found: error | |
retention-days: 1 | |
compression-level: 9 | |
- name: Publish test project MonoConsole | |
uses: actions/upload-artifact@main | |
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true | |
with: | |
name: MonoConsole | |
path: src/FrameworkTests/MonoConsole/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} | |
if-no-files-found: error | |
retention-days: 1 | |
test: | |
name: Test (${{ matrix.os }}) | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-2019, windows-2022, ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, macos-14] | |
runs-on: ${{ matrix.os }} | |
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true | |
steps: | |
- name: Setup Mono | |
if: runner.os == 'Windows' | |
run: choco install mono -y && Add-Content $env:GITHUB_PATH "C:\Program Files\Mono\bin" | |
- name: Setup .NET 6 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 6.x | |
- name: Setup .NET 7 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 7.x | |
- name: Setup .NET 8 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 8.x | |
- name: Download test project MonoConsole | |
uses: actions/download-artifact@main | |
with: | |
name: MonoConsole | |
path: MonoConsole | |
- name: Mono (.NET Framework 4.6.2) | |
if: success() || failure() | |
run: mono MonoConsole/net462/PDFtoImage.FrameworkTests.MonoConsole.exe | |
- name: Mono (.NET Framework 4.7.1) | |
if: success() || failure() | |
run: mono MonoConsole/net471/PDFtoImage.FrameworkTests.MonoConsole.exe | |
- name: Mono (.NET Framework 4.8.1) | |
if: success() || failure() | |
run: mono MonoConsole/net481/PDFtoImage.FrameworkTests.MonoConsole.exe | |
- name: Download test assemblies | |
if: success() || failure() | |
uses: actions/download-artifact@main | |
with: | |
name: Test assemblies | |
- name: .NET Framework 4.6.2 | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: dotnet test net462/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net462/SaveOutputInGeneratedFolder.runsettings' || '' }} | |
- name: .NET Framework 4.7.1 | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: dotnet test net471/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net471/SaveOutputInGeneratedFolder.runsettings' || '' }} | |
- name: .NET Framework 4.8.1 | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: dotnet test net481/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net481/SaveOutputInGeneratedFolder.runsettings' || '' }} | |
- name: .NET 6 | |
if: success() || failure() | |
run: dotnet test net6.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net6.0/SaveOutputInGeneratedFolder.runsettings' || '' }} | |
- name: .NET 7 | |
if: success() || failure() | |
run: dotnet test net7.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net7.0/SaveOutputInGeneratedFolder.runsettings' || '' }} | |
- name: .NET 8 | |
if: success() || failure() | |
run: dotnet test net8.0/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net8.0/SaveOutputInGeneratedFolder.runsettings' || '' }} | |
- name: Upload test results | |
if: success() || failure() | |
uses: actions/upload-artifact@main | |
with: | |
name: Test results (${{ matrix.os }}) | |
path: ./**/*.trx | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Upload generated assets | |
if: (success() || failure()) && (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true | |
uses: actions/upload-artifact@main | |
with: | |
name: Generated assets (${{ matrix.os }}) | |
path: ./**/Assets/Generated | |
if-no-files-found: error | |
retention-days: 1 | |
docker: | |
name: Docker (${{ matrix.os }}) | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest, ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_docker) == true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: console (linux) | |
if: runner.os == 'Linux' && (success() || failure()) | |
run: docker build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/linux.dockerfile . && docker run --rm -t console | |
- name: console (linux-chiseled) | |
if: runner.os == 'Linux' && (success() || failure()) | |
run: docker build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/linux-chiseled.dockerfile . && docker run --rm -t console | |
- name: console (linux-aot) | |
if: runner.os == 'Linux' && (success() || failure()) | |
run: docker build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/linux-aot.dockerfile . && docker run --rm -t console | |
- name: console (linux-aot-chiseled) | |
if: runner.os == 'Linux' && (success() || failure()) | |
run: docker build -t console -f src/FrameworkTests/AotConsole/Dockerfiles/linux-aot-chiseled.dockerfile . && docker run --rm -t console | |
- name: console (servercore) | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: xcopy /y "src\FrameworkTests\AotConsole\Dockerfiles\windows-servercore.dockerfile" . && docker build -t console -f windows-servercore.dockerfile . && docker run --rm -t console | |
- name: console (servercore-aot) | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: xcopy /y "src\FrameworkTests\AotConsole\Dockerfiles\windows-servercore-aot.dockerfile" . && docker build -t console -f windows-servercore-aot.dockerfile . && docker run --rm -t console | |
- name: console (nanoserver) | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: xcopy /y "src\FrameworkTests\AotConsole\Dockerfiles\windows-nanoserver.dockerfile" . && docker build -t console -f windows-nanoserver.dockerfile . && docker run --rm -t console | |
- name: console (nanoserver-aot) | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: xcopy /y "src\FrameworkTests\AotConsole\Dockerfiles\windows-nanoserver-aot.dockerfile" . && docker build -t console -f windows-nanoserver-aot.dockerfile . && docker run --rm -t console | |
- name: docker system prune | |
if: success() || failure() | |
run: docker system prune -a -f | |
- name: unittests (linux) | |
if: runner.os == 'Linux' && (success() || failure()) | |
run: docker build -t unittests --build-arg TARGET_FRAMEWORK=net8.0 -f src/Tests/Dockerfiles/linux.dockerfile . && docker run --rm --mount type=bind,source=${{ github.workspace }}/src/Tests,target=/app/TestResults -t unittests | |
- name: unittests (servercore) | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: xcopy /y "src\Tests\Dockerfiles\windows-servercore.dockerfile" . && docker build -t unittests --build-arg TARGET_FRAMEWORK=net8.0 -f windows-servercore.dockerfile . && docker run --rm --mount type=bind,source=${{ github.workspace }}/src/Tests,target=/app/TestResults -t unittests | |
- name: unittests (nanoserver) | |
if: runner.os == 'Windows' && (success() || failure()) | |
run: xcopy /y "src\Tests\Dockerfiles\windows-nanoserver.dockerfile" . && docker build -t unittests --build-arg TARGET_FRAMEWORK=net8.0 -f windows-nanoserver.dockerfile . && docker run --rm --mount type=bind,source=${{ github.workspace }}/src/Tests,target=/app/TestResults -t unittests | |
- name: Upload test results | |
if: success() || failure() | |
uses: actions/upload-artifact@main | |
with: | |
name: Test results (${{ matrix.os }}; docker) | |
path: ./**/*.trx | |
if-no-files-found: error | |
retention-days: 1 | |
publish-test-results: | |
name: Publish tests results | |
needs: [test, docker] | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
pull-requests: write | |
concurrency: | |
group: "publish-test-results" | |
cancel-in-progress: false | |
if: (success() || failure()) && (github.event_name != 'workflow_dispatch' && true || inputs.publish_testresults) == true | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@main | |
with: | |
pattern: Test results (*) | |
merge-multiple: true | |
path: artifacts | |
- name: Publish test results | |
uses: EnricoMi/publish-unit-test-result-action@master | |
with: | |
files: artifacts/**/*.trx | |
check_name: Test results | |
compare_to_earlier_commit: false | |
action_fail_on_inconclusive: true | |
json_file: test-results.json | |
- name: Upload test results to GitHub Gist | |
if: github.repository == 'sungaila/PDFtoImage' && github.ref == 'refs/heads/master' && success() | |
uses: exuanbo/actions-deploy-gist@main | |
with: | |
token: ${{ secrets.GIST_TOKEN }} | |
gist_id: 003e8ab2211221897e4b3c0e564ed7b6 | |
gist_description: ${{ github.repository }} test results as JSON | |
gist_file_name: ${{ github.repository_owner }}_${{ github.event.repository.name }}_test-results.json | |
file_path: test-results.json | |
file_type: text | |
sonarcloud: | |
name: SonarCloud | |
runs-on: windows-latest | |
if: (github.repository == 'sungaila/PDFtoImage' && success()) && (github.event_name != 'workflow_dispatch' && true || inputs.run_sonarcloud) == true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@main | |
with: | |
msbuild-architecture: x64 | |
- name: Setup .NET 6 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 6.x | |
- name: Setup .NET 7 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 7.x | |
- name: Setup .NET 8 | |
uses: actions/setup-dotnet@main | |
with: | |
dotnet-version: 8.x | |
- name: Setup dotnet-coverage | |
run: dotnet tool install --global dotnet-coverage | |
- name: Setup .NET workload android | |
run: dotnet workload install android | |
- name: Setup JDK 17 | |
uses: actions/setup-java@main | |
with: | |
java-version: 17 | |
java-package: jdk | |
distribution: 'zulu' | |
- name: Setup Android SDK 29 | |
run: C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-29" | |
- name: Cache SonarCloud packages | |
uses: actions/cache@main | |
with: | |
path: ~\sonar\cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache SonarCloud scanner | |
id: cache-sonar-scanner | |
uses: actions/cache@main | |
with: | |
path: .\.sonar\scanner | |
key: ${{ runner.os }}-sonar-scanner | |
restore-keys: ${{ runner.os }}-sonar-scanner | |
- name: Install SonarCloud scanner | |
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
shell: powershell | |
run: | | |
New-Item -Path .\.sonar\scanner -ItemType Directory | |
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | |
- name: Analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: powershell | |
run: | | |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"sungaila_PDFtoImage" /o:"sungaila" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml | |
dotnet restore src/PDFtoImage.SonarCloud.slnf | |
msbuild src/PDFtoImage.SonarCloud.slnf /p:Configuration=${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} | |
dotnet-coverage collect "dotnet test src/PDFtoImage.SonarCloud.slnf --verbosity detailed" -f xml -o "coverage.xml" | |
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |