From c915090ac091dd6970733f1a409c3163bac263e2 Mon Sep 17 00:00:00 2001 From: Lannamokia Date: Fri, 8 Aug 2025 15:20:22 +0800 Subject: [PATCH] =?UTF-8?q?ci(workflow):=20=E4=BB=85=E5=9C=A8=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6=E6=97=B6=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=B5=8B=E8=AF=95=E5=B9=B6=E5=8F=91=E5=B8=83=E7=BB=93?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加条件判断,仅当存在测试项目时才运行测试,否则跳过测试步骤并创建空目录 同时修改测试结果发布条件,仅在存在测试结果文件时执行 --- .github/workflows/build.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 775f67c..8d661d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,12 +61,19 @@ jobs: run: dotnet build VHDMounter.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore --verbosity minimal - name: Test - run: dotnet test VHDMounter.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity normal --logger trx --results-directory TestResults + run: | + if (Test-Path "*Tests*.csproj") { + dotnet test VHDMounter.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity normal --logger trx --results-directory TestResults + } else { + Write-Host "No test projects found, skipping tests" + New-Item -ItemType Directory -Force -Path TestResults + Write-Host "Created empty TestResults directory" + } continue-on-error: true - name: Publish Test Results uses: dorny/test-reporter@v1 - if: always() + if: always() && hashFiles('TestResults/*.trx') != '' with: name: Test Results path: TestResults/*.trx