Version number from build also gets set on the csproj files (#2560) #1890
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: Build and Test Runtimes, Unit Tests, Generated Code Projects | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [master, main] | |
| workflow_dispatch: | |
| jobs: | |
| Build-and-Test: | |
| strategy: | |
| matrix: | |
| # We used to have ubuntu-latest here, but it can't build iOS, and it's easier to just use macos | |
| os: [windows-latest, macos-15] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup .NET SDKs | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| # On main: full cache (restore + save). On PRs: restore only, no save. | |
| # PR branch caches are scoped to that branch and never reused, so saving | |
| # the 3.6 GB cache on PRs is wasted upload time. | |
| - name: Cache .NET workloads (main only) | |
| id: cache-workloads | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| C:\Program Files\dotnet\metadata | |
| C:\Program Files\dotnet\packs | |
| C:\Program Files\dotnet\sdk-manifests | |
| /usr/local/share/dotnet/metadata | |
| /usr/local/share/dotnet/packs | |
| /usr/local/share/dotnet/sdk-manifests | |
| key: workloads-${{ runner.os }}-${{ hashFiles('.github/workflows/build-and-test.yaml') }} | |
| - name: Restore cached .NET workloads (PRs) | |
| id: cache-workloads-restore | |
| if: github.ref != 'refs/heads/main' | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| C:\Program Files\dotnet\metadata | |
| C:\Program Files\dotnet\packs | |
| C:\Program Files\dotnet\sdk-manifests | |
| /usr/local/share/dotnet/metadata | |
| /usr/local/share/dotnet/packs | |
| /usr/local/share/dotnet/sdk-manifests | |
| key: workloads-${{ runner.os }}-${{ hashFiles('.github/workflows/build-and-test.yaml') }} | |
| - name: Install workloads | |
| if: steps.cache-workloads.outputs.cache-hit != 'true' && steps.cache-workloads-restore.outputs.cache-hit != 'true' | |
| run: dotnet workload install wasm-tools-net9 ios android maui | |
| # Workload caching IS used above and saves ~2 minutes per run. | |
| # I tried caching both NuGet packages and also cache on the actions/setup-dotnet@v4 | |
| # In both cases the caching slowed down the total execution time. | |
| # Actually on further testing, it does seem like the NuGet cache can speed up the Windows | |
| # build by around 20-30 seconds. However, the script for it is a little confusing and it's | |
| # not a huge savings. Let's keep it simple and not use NuGet caching. | |
| # On push to main, the only purpose is to seed the workload cache. | |
| # If the cache already exists, skip the entire build and test. | |
| - name: Build Gum (Windows Only) | |
| if: (github.event_name != 'push' || steps.cache-workloads.outputs.cache-hit != 'true') && runner.os == 'Windows' | |
| run: | | |
| dotnet restore "Gum.sln" | |
| dotnet build "Gum.sln" --configuration Release --no-restore --verbosity minimal -p:WarningLevel=0 | |
| # IncludeAndroid=true forces KniGum's net9.0-android TFM to be included so CI | |
| # actually validates the #if ANDROID code compiles. KniGum uses opt-in for Android | |
| # (see KniGum.csproj); without this flag Android regressions would slip past CI and | |
| # only surface when packing the Gum.KNI nupkg. | |
| - name: Build AllLibraries | |
| if: github.event_name != 'push' || steps.cache-workloads.outputs.cache-hit != 'true' | |
| run: | | |
| dotnet restore "AllLibraries.sln" -p:IncludeAndroid=true | |
| dotnet build "AllLibraries.sln" --configuration Release --no-restore --verbosity minimal -p:WarningLevel=0 -p:IncludeAndroid=true | |
| - name: Build Generated Code Projects (Windows Only) | |
| if: (github.event_name != 'push' || steps.cache-workloads.outputs.cache-hit != 'true') && runner.os == 'Windows' | |
| run: | | |
| dotnet restore "Tests/CodeGen_Maui_FullCodegen/CodeGen_Maui_FullCodegen.sln" | |
| dotnet build "Tests/CodeGen_Maui_FullCodegen/CodeGen_Maui_FullCodegen.sln" --configuration Debug --no-restore --verbosity minimal -p:WarningLevel=0 -p:TargetFrameworks=net9.0-windows10.0.19041.0 | |
| dotnet restore "Tests/CodeGen_MonoGame_ByReference/CodeGen_MonoGame_ByReference.sln" | |
| dotnet build "Tests/CodeGen_MonoGame_ByReference/CodeGen_MonoGame_ByReference.sln" --configuration Debug --no-restore --verbosity minimal -p:WarningLevel=0 | |
| dotnet restore "Tests/CodeGen_MonoGameForms_ByReference/CodeGenProject.sln" | |
| dotnet build "Tests/CodeGen_MonoGameForms_ByReference/CodeGenProject.sln" --configuration Debug --no-restore --verbosity minimal -p:WarningLevel=0 | |
| dotnet restore "Tests/CodeGen_MonoGameForms_FullCodegen/CodeGen_MonoGameForms_FullCodegen.sln" | |
| dotnet build "Tests/CodeGen_MonoGameForms_FullCodegen/CodeGen_MonoGameForms_FullCodegen.sln" --configuration Debug --no-restore --verbosity minimal -p:WarningLevel=0 | |
| - name: MonoGameGum.Tests | |
| if: github.event_name != 'push' || steps.cache-workloads.outputs.cache-hit != 'true' | |
| run: dotnet test "MonoGameGum.Tests" --configuration Release --no-build --logger "trx" --results-directory "TestResults" | |
| continue-on-error: true | |
| - name: SokolGum.Tests | |
| if: github.event_name != 'push' || steps.cache-workloads.outputs.cache-hit != 'true' | |
| run: dotnet test "Tests/SokolGum.Tests" --configuration Release --no-build --logger "trx" --results-directory "TestResults" | |
| continue-on-error: true | |
| - name: GumToolUnitTests (Windows Only) | |
| if: (github.event_name != 'push' || steps.cache-workloads.outputs.cache-hit != 'true') && runner.os == 'Windows' | |
| run: dotnet test "Tool/Tests/GumToolUnitTests" --configuration Release --no-build --logger "trx" --results-directory "TestResults" | |
| continue-on-error: true | |
| - name: Publish Test Results | |
| if: github.event_name != 'push' || steps.cache-workloads.outputs.cache-hit != 'true' | |
| uses: dorny/test-reporter@v2 | |
| with: | |
| name: Tests ${{ matrix.os }} | |
| path: "TestResults/*.trx" | |
| reporter: dotnet-trx | |
| fail-on-error: true |