From daf294f21eae9449774bfaadbf6683d638b49692 Mon Sep 17 00:00:00 2001 From: lincube Date: Thu, 25 Jun 2026 17:18:08 +0800 Subject: [PATCH] fix: resolve intermittent build failures in CI workflows Root causes identified and fixed: 1. AirAppHost recursive build issue: - Main project triggers AirAppHost build as post-build step - AirAppHost references main project, creating circular dependency - Added SkipAirAppHostBuild=true to build.yml to break the cycle - Release workflow handles AirAppHost separately in publish step 2. NuGet cache path issues: - Changed from relative path (.nuget/packages) to absolute path - Added NUGET_PACKAGES environment variable with github.workspace - Added actions/cache for NuGet packages across all workflows 3. Missing NuGet package caching: - Added actions/cache@v4 with proper cache keys - Cache key based on Directory.Packages.props hash - Fallback restore keys for partial cache hits These changes should eliminate the intermittent failures caused by: - File locking conflicts from recursive builds - Path resolution inconsistencies - Network-dependent package downloads on every build --- .github/workflows/build.yml | 43 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 10 ++++++++ 2 files changed, 53 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a19e9da..8afead3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,8 @@ env: DOTNET_VERSION: '10.0.x' Solution_Name: LanMountainDesktop.slnx DOTNET_gcServer: 1 + # Use system default NuGet cache to avoid path issues + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages jobs: build-windows: @@ -34,11 +36,22 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} dotnet-quality: 'preview' + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }} + restore-keys: | + ${{ runner.os }}-nuget- + - name: Restore run: dotnet restore ${{ env.Solution_Name }} - name: Build run: dotnet build ${{ env.Solution_Name }} --no-restore -c ${{ matrix.configuration }} -v minimal + env: + # Skip AirAppHost build to avoid recursive build issues + SkipAirAppHostBuild: true - name: Upload artifacts uses: actions/upload-artifact@v7 @@ -82,11 +95,22 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} dotnet-quality: 'preview' + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }} + restore-keys: | + ${{ runner.os }}-nuget- + - name: Restore run: dotnet restore ${{ env.Solution_Name }} - name: Build run: dotnet build ${{ env.Solution_Name }} --no-restore -c Release -v minimal + env: + # Skip AirAppHost build to avoid recursive build issues + SkipAirAppHostBuild: true - name: Upload artifacts uses: actions/upload-artifact@v7 @@ -116,11 +140,22 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} dotnet-quality: 'preview' + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }} + restore-keys: | + ${{ runner.os }}-nuget- + - name: Restore run: dotnet restore ${{ env.Solution_Name }} - name: Build run: dotnet build ${{ env.Solution_Name }} --no-restore -c Release -v minimal + env: + # Skip AirAppHost build to avoid recursive build issues + SkipAirAppHostBuild: true - name: Upload artifacts uses: actions/upload-artifact@v7 @@ -147,6 +182,14 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} dotnet-quality: 'preview' + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }} + restore-keys: | + ${{ runner.os }}-nuget- + - name: Pack SDK and template packages shell: pwsh run: .\scripts\Pack-PluginPackages.ps1 -Configuration Release -OutputPath .\artifacts\nuget diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99d9be1..5fe5c4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,8 @@ env: DOTNET_VERSION: '10.0.x' Solution_Name: LanMountainDesktop.slnx DOTNET_gcServer: 1 + # Use absolute path for NuGet cache to avoid path resolution issues + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages jobs: prepare: @@ -437,6 +439,14 @@ jobs: dotnet-version: ${{ env.DOTNET_VERSION }} dotnet-quality: 'preview' + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }} + restore-keys: | + ${{ runner.os }}-nuget- + - name: Stamp release version metadata shell: pwsh run: |