我有一个 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
}
我的问题是当我在测试失败的情况下运行我的管道时,管道被标记为 PASSED,这是一个问题......
我还检查了 faSTLane,失败的测试不会使管道失败。
当测试未通过时,如何使我的管道失败?
快车道的 Cf 截图:
最佳答案
您需要返回一个非零值才能使该步骤失败。
尝试将此添加到 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
关于Xcode 测试失败不会失败 Github 操作管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58694624/