Ios Github操作:尽管已安装,但未找到xcpretty

Ios Github操作:尽管已安装,但未找到xcpretty,ios,rubygems,github-actions,xcodebuild,Ios,Rubygems,Github Actions,Xcodebuild,我正试图用Github操作替换iOS项目可怕的Jenkins设置。我想我已经准备好了所有的部分,但我不明白我会失败。在我运行xcodebuild构建和测试应用程序的步骤中,我得到了一个错误,即xcpretty是一个未知命令,尽管在上一步中通过bundler安装。以下是相关文件: build-and-run.yml --- name: Build & Test on: # Run tests when a PR merges. push: branches: -

我正试图用Github操作替换iOS项目可怕的Jenkins设置。我想我已经准备好了所有的部分,但我不明白我会失败。在我运行
xcodebuild
构建和测试应用程序的步骤中,我得到了一个错误,即
xcpretty
是一个未知命令,尽管在上一步中通过bundler安装。以下是相关文件:

build-and-run.yml

---
name: Build & Test
on:
  # Run tests when a PR merges.
  push:
    branches:
      - develop

  # Run tests when PRs are created or updated.
  pull_request:
    types: [opened, synchronize, reopened]

  # Allow the workflow to be run manually.
  workflow_dispatch:

env:
  DEVELOPER_DIR: /Applications/Xcode_12.app/Contents/Developer

jobs:
  test:
    name: Build & Test
    runs-on: 'macos-latest'

    steps:
      - name: Checkout Project
        uses: actions/checkout@v2
        with:
          ref: develop

      - name: Setup Ruby
        uses: ruby/setup-ruby@v1.46.0
        with:
            ruby-version: 2.7.1

      - name: Restore Ruby Cache
        uses: actions/cache@v1
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gem-

      - name: Restore Pod Cache
        uses: actions/cache@v1
        with:
          path: Pods
          key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-pods-

      - name: Bundle Install
        run: |
          bundle config path vendor/bundle
          bundle install --without=documentation --jobs 4 --retry 3

      - name: Install Cocoapods
        run: pod install --repo-update

      - name: Show Xcode Version
        run: xcode-select -p

      - name: Show Build Settings
        run: xcodebuild -workspace ./MyApp.xcworkspace -scheme 'MyApp-Test' -destination 'platform=iOS Simulator,name=iPhone 11' -showBuildSettings

      - name: Test MyApp
        run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace MyApp.xcworkspace -scheme MyApp-Test -destination 'platform=iOS Simulator,name=iPhone 11' -enableCodeCoverage YES -derivedDataPath build/derived-data clean test | xcpretty -s

      - name: Run Danger
        env:
          DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
        run: bundle exec danger
Gemfile(我们在行动中不使用fastlane,但我现在必须将其保存在Gemfile中,以便构建不会在我们的Jenkins box上中断):

Bundle安装
步骤中,正在安装xcpretty gem:

Fetching xcpretty 0.3.0
Installing xcpretty 0.3.0
安装Cocoapods
步骤也可以正常工作(可能是因为Cocoapods是预安装的)。当到达
testmyapp
步骤时,调用会创建一个错误:

Run set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace MyApp.xcworkspace -scheme MyApp-Test -destination 'platform=iOS Simulator,name=iPhone 11' -enableCodeCoverage YES -derivedDataPath build/derived-data clean test | xcpretty -s

/Users/runner/work/_temp/9d3633bf-6dae-45d7-a303-1c68abb63d53.sh: line 1: xcpretty: command not found

然后工作流会挂起很长时间,所以我通常会取消它。你知道为什么找不到
xcpretty
吗?我的想法是,安装gem的目录不在搜索路径中,但我不确定我将如何做到这一点。我相信有一个合理的解决方案,但我很难找到它,我已经厌倦了用头撞墙。

嗨,Joshua,你找到这个问题的答案了吗?是的,我必须手动找到ruby gem安装目录的路径。这是残酷的。我想一定有比这更优雅的解决方案。
Run set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace MyApp.xcworkspace -scheme MyApp-Test -destination 'platform=iOS Simulator,name=iPhone 11' -enableCodeCoverage YES -derivedDataPath build/derived-data clean test | xcpretty -s

/Users/runner/work/_temp/9d3633bf-6dae-45d7-a303-1c68abb63d53.sh: line 1: xcpretty: command not found