Xcode测试失败不会使Github操作管道失败

我有一个Github action管道:

name: default

on: [push]

jobs:
  build:

    runs-on: macOS-latest

    steps:
    - uses: actions/checkout@v1
    - name: Cocoapod Install
      run: pod install
    - name: Force xcode 11
      run: sudo xcode-select -switch /Applications/Xcode_11.1.app
    - name: Test
      run: ./pipelines.sh test
    - name: Save report
      uses: actions/upload-artifact@v1
      with:
        name: test_report
        path: ./Test

还有一个脚本Shell:

function test
{
    xcodebuild \
       -workspace MyApp.xcworkspace \
       -scheme DEBUG\ -\ MyApp \
       -destination 'platform=iOS Simulator,name=iPhone 11' \
       test
}

我的问题是,当我在测试失败的情况下运行管道时,该管道被标记为“通过”,这是一个问题...

我也检查过快速通道,测试失败不会使管道失败。

当测试未通过时,如何将管道设置为失败?

快速通道的CF屏幕截图:

Xcode测试失败不会使Github操作管道失败

sunjianfeng1 回答:Xcode测试失败不会使Github操作管道失败

您需要返回非零值以使步骤失败。 尝试将其添加到xcodebuild命令中。

xcodebuild -... || exit 1

除了以下问题,还有其他解决方案。 How to get the return value of xcodebuild?

更新:根据您希望后续步骤完成的评论,可以执行以下操作。

更改脚本以设置包含xcodebuild命令结果的输出。

    xcodebuild \
       -workspace MyApp.xcworkspace \
       -scheme DEBUG\ -\ MyApp \
       -destination 'platform=iOS Simulator,name=iPhone 11' \
       test
    echo "::set-output name=result::$?"

在执行此脚本的步骤中添加id

    - name: Test
      id: xcodebuild
      run: ./pipelines.sh test

在工作流程结束时,您可以检查测试是否未通过并导致工作流程失败。

      - name: Check Tests Passed
        if: steps.xcodebuild.outputs.result != 0
        run: exit 1
本文链接:https://www.f2er.com/3166326.html

大家都在问