From 496b6b869f40737783f9ecd10dfd70a2427b476f Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sat, 25 Oct 2025 15:29:12 -0600 Subject: [PATCH] Optimize CI workflows with single centralized build and remove redundant workflow (#4327) * Initial plan * Optimize CI workflows to share build artifacts across test jobs Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add documentation comments to workflow files Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add clarifying comments to integration-tests workflow Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor to use single centralized build workflow Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix Release build by adding AOT and SelfContained project restore Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix Release build by building Terminal.Gui first before AOT projects Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix Release build by packing Terminal.Gui and building AOT projects separately Co-authored-by: tig <585482+tig@users.noreply.github.com> * Remove redundant build-release.yml workflow Co-authored-by: tig <585482+tig@users.noreply.github.com> * Suppress Obsolete warnings (0618;0612) in build workflow Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix NoWarn parameter by quoting to prevent shell interpretation Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix NoWarn parameter syntax - use comma separator and /p: prefix Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix NoWarn parameter with URL-encoded semicolon and add documentation Co-authored-by: tig <585482+tig@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig --- .github/workflows/build-release.yml | 47 --------------- .github/workflows/build.yml | 76 +++++++++++++++++++++++++ .github/workflows/integration-tests.yml | 19 +++++-- .github/workflows/unit-tests.yml | 30 ++++++---- 4 files changed, 109 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/build-release.yml create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml deleted file mode 100644 index a95896a28..000000000 --- a/.github/workflows/build-release.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Ensure that Release Build of Solution Builds Correctly - -on: - push: - branches: [ v2_release, v2_develop ] - paths-ignore: - - '**.md' - pull_request: - branches: [ v2_release, v2_develop ] - paths-ignore: - - '**.md' - -jobs: - build_release: - # Ensure that RELEASE builds are not broken - runs-on: ubuntu-latest - steps: - - name: Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - - - name: Setup .NET Core - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.x - dotnet-quality: 'ga' - - - name: Build Release Terminal.Gui - run: dotnet build Terminal.Gui/Terminal.Gui.csproj --no-incremental --nologo --force --configuration Release - - - name: Pack Release Terminal.Gui - run: dotnet pack Terminal.Gui/Terminal.Gui.csproj --configuration Release --output ./local_packages - - - name: Restore AOT and Self-Contained projects - run: | - dotnet restore ./Examples/NativeAot/NativeAot.csproj -f - dotnet restore ./Examples/SelfContained/SelfContained.csproj -f - - - name: Restore Solution Packages - run: dotnet restore - - - name: Build Release AOT and Self-Contained - run: | - dotnet build ./Examples/NativeAot/NativeAot.csproj --configuration Release - dotnet build ./Examples/SelfContained/SelfContained.csproj --configuration Release - - - name: Build Release Solution without restore - run: dotnet build --configuration Release --no-restore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..d5f71b92d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,76 @@ +name: Build Solution + +on: + push: + branches: [ v2_release, v2_develop ] + paths-ignore: + - '**.md' + pull_request: + branches: [ v2_release, v2_develop ] + paths-ignore: + - '**.md' + workflow_call: + outputs: + artifact-name: + description: "Name of the build artifacts" + value: ${{ jobs.build.outputs.artifact-name }} + +jobs: + build: + name: Build Debug & Release + runs-on: ubuntu-latest + outputs: + artifact-name: build-artifacts + + timeout-minutes: 10 + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + dotnet-quality: 'ga' + + - name: Restore dependencies + run: dotnet restore + + # Suppress CS0618 (member is obsolete) and CS0612 (member is obsolete without message) + # Using -property: syntax with URL-encoded semicolon (%3B) to avoid shell interpretation issues + - name: Build Debug + run: dotnet build --configuration Debug --no-restore -property:NoWarn=0618%3B0612 + + - name: Build Release Terminal.Gui + run: dotnet build Terminal.Gui/Terminal.Gui.csproj --configuration Release --no-incremental --force -property:NoWarn=0618%3B0612 + + - name: Pack Release Terminal.Gui + run: dotnet pack Terminal.Gui/Terminal.Gui.csproj --configuration Release --output ./local_packages -property:NoWarn=0618%3B0612 + + - name: Restore AOT and Self-Contained projects + run: | + dotnet restore ./Examples/NativeAot/NativeAot.csproj -f + dotnet restore ./Examples/SelfContained/SelfContained.csproj -f + + - name: Restore Solution Packages + run: dotnet restore + + - name: Build Release AOT and Self-Contained + run: | + dotnet build ./Examples/NativeAot/NativeAot.csproj --configuration Release -property:NoWarn=0618%3B0612 + dotnet build ./Examples/SelfContained/SelfContained.csproj --configuration Release -property:NoWarn=0618%3B0612 + + - name: Build Release Solution + run: dotnet build --configuration Release --no-restore -property:NoWarn=0618%3B0612 + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: | + **/bin/Debug/** + **/obj/Debug/** + **/bin/Release/** + **/obj/Release/** + retention-days: 1 diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index cee722df7..ae2da454b 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -11,9 +11,14 @@ on: - '**.md' jobs: - build_and_test_debug: + # Call the build workflow to build the solution once + build: + uses: ./.github/workflows/build.yml + integration_tests: + name: Integration Tests runs-on: ${{ matrix.os }} + needs: build strategy: # Turn off fail-fast to let all runners run even if there are errors fail-fast: true @@ -32,12 +37,14 @@ jobs: dotnet-version: 8.x dotnet-quality: 'ga' - - name: Install dependencies - run: | - dotnet restore + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: . - - name: Build IntegrationTests - run: dotnet build Tests/IntegrationTests --configuration Debug --no-restore + - name: Restore NuGet packages + run: dotnet restore - name: Set VSTEST_DUMP_PATH shell: bash diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f3d03ed8d..07a7e00d5 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -11,9 +11,14 @@ on: - '**.md' jobs: + # Call the build workflow to build the solution once + build: + uses: ./.github/workflows/build.yml + non_parallel_unittests: name: Non-Parallel Unit Tests runs-on: ${{ matrix.os }} + needs: build strategy: # Turn off fail-fast to let all runners run even if there are errors fail-fast: true @@ -32,12 +37,14 @@ jobs: dotnet-version: 8.x dotnet-quality: 'ga' - - name: Install dependencies - run: | - dotnet restore + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: . - - name: Build Solution Debug - run: dotnet build --configuration Debug --no-restore + - name: Restore NuGet packages + run: dotnet restore # Test # Note: The --blame and VSTEST_DUMP_PATH stuff is needed to diagnose the test runner crashing on ubuntu/mac @@ -66,6 +73,7 @@ jobs: parallel_unittests: name: Parallel Unit Tests runs-on: ${{ matrix.os }} + needs: build strategy: # Turn off fail-fast to let all runners run even if there are errors fail-fast: true @@ -84,12 +92,14 @@ jobs: dotnet-version: 8.x dotnet-quality: 'ga' - - name: Install dependencies - run: | - dotnet restore + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: . - - name: Build Solution Debug - run: dotnet build --configuration Debug --no-restore + - name: Restore NuGet packages + run: dotnet restore # Test # Note: The --blame and VSTEST_DUMP_PATH stuff is needed to diagnose the test runner crashing on ubuntu/mac