ci(workflow): 仅在存在测试文件时运行测试并发布结果
添加条件判断,仅当存在测试项目时才运行测试,否则跳过测试步骤并创建空目录 同时修改测试结果发布条件,仅在存在测试结果文件时执行
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user