Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastlane run_tests fails when attempting to get runtimes #21893

Closed
4 tasks done
dnedrow opened this issue Feb 26, 2024 · 0 comments · Fixed by #21894
Closed
4 tasks done

Fastlane run_tests fails when attempting to get runtimes #21893

dnedrow opened this issue Feb 26, 2024 · 0 comments · Fixed by #21894

Comments

@dnedrow
Copy link
Contributor

dnedrow commented Feb 26, 2024

New Issue Checklist

Issue Description

When run_tests executes, it attempts to get a list of installed runtimes in json format. This fails with Xcode 14.n and 15.n.
The reason is that the following command is used to get the list of runtimes:
xcrun simctl list runtimes -j.
I'm unsure if this worked in older versions of Xcode, but it no longer does. The output modifier must come BEFORE runtimes in the command, e.g. xcrun simctl list -j runtimes
The error is in line 16 of device_manager.rb.

Command executed
Complete output when running fastlane, including the stack trace and command used
 [REPLACE THIS WITH YOUR INFORMATION] 

Environment

✅ fastlane environment ✅

Stack

Key Value
OS 14.4
Ruby 3.2.2
Bundler? true
Git git version 2.43.0
Installation Source ~/.rvm/gems/ruby-3.2.2/bin/fastlane
Host macOS 14.4 (23E5205c)
Ruby Lib Dir ~/.rvm/rubies/ruby-3.2.2/lib
OpenSSL Version OpenSSL 3.1.4 24 Oct 2023
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 15.3
Swift Version 5.10

System Locale

Variable Value
LANG en_US.UTF-8
LC_ALL en_US.UTF-8
LANGUAGE

fastlane files:

`./fastlane/Fastfile`
require "base64"

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out.
#
#     https://docs.fastlane.tools/plugins/available-plugins

opt_out_usage
update_fastlane

default_platform(:ios)

# Get output of command
# blah = with_captured_output(sh "date")
def with_captured_stdout
  original_stdout = $stdout
  $stdout = StringIO.new
  yield
  $stdout.string
ensure
  $stdout = original_stdout
end

platform :ios do
  before_all do |lane|
    lanes_to_say_foo = [:BuildAndDistribute]
    setup_ci if ENV['CI']
    GITHUB_TOKEN = ENV['GITHUB_TOKEN']
    HAS_PACKAGES_CACHE_HIT = ENV["HAS_PACKAGES_CACHE_HIT"]
    MATCH_PASSWORD = ENV["MATCH_PASSWORD"]
    PATH = ENV['PATH']
    SCHEME = ENV['SCHEME']
    SENTRY_TOKEN = ENV['SENTRY_TOKEN']
    TOOLCHAIN = ENV['TOOLCHAIN']
    XCODE_VER = ENV['XCODE_VER']

    REPORT_EXTENSION = {
      "html" => "html",
      "markdown" => "md",
      "json" => "json",
    }
  end

  after_all do |lane|
  end

  lane :shield do
    version = get_version_number(
      xcodeproj: "ConsumerMobile.xcodeproj",
      target: "#{SCHEME}"
    )

    # Get the badge based on version and scheme
    sh("/usr/bin/curl -o ../shield.svg https://img.shields.io/badge/#{version}-debug-orange?logo=githubactions&labelColor=white")
    sh("rsvg-convert -w 167 ../shield.svg > ../shield.png")

    add_badge(
      custom: "shield.png",
      glob: "/sources/#{SCHEME}*/**/*.appiconset/*.{png,PNG}"
    )

    # add_badge(
    #   glob: "/sources/**/*.appiconset/*.{png,PNG}",
    #   shield: "https://img.shields.io/badge/#{version}-ad_hoc-orange",
    #   no_badge: true,
    #   shield_gravity: "SouthEast"
    # )
  end

  desc "Build with the AdHoc Signature"
  lane :build_application do
    install_saucectl
    # increment_build_number(xcodeproj: "ConsumerMobile.xcodeproj")
    XCODE_VER = ENV['XCODE_VER']
    TSTAMP = ENV['TIME_STAMP']
    OUTPUT_DIR = "./build/#{SCHEME}/release"
    sh("echo OUTPUT_DIR=#{OUTPUT_DIR} >> $GITHUB_ENV")
    # OUTPUT_NAME = "#{SCHEME}-#{TSTAMP}.ipa"
    OUTPUT_NAME = "automation-#{SCHEME}-ios.ipa"
    sh("echo OUTPUT_NAME=#{OUTPUT_NAME} >> $GITHUB_ENV")
    packages_path = "#{File.expand_path("..", Dir.pwd)}/packages_cache"
    xcodes(version: "#{XCODE_VER}", select_for_current_build_only: true)
    shield
    match(type: "adhoc", readonly: true)
    gym(
      scheme: "#{SCHEME}",
      workspace: "ConsumerMobile.xcworkspace",
      output_directory: "#{OUTPUT_DIR}",
      output_name: "#{OUTPUT_NAME}",
      export_method: "ad-hoc",
      export_options: "./fastlane/#{SCHEME}/adhoc-export-options.plist",
      export_xcargs: "-allowProvisioningUpdates",
      cloned_source_packages_path: packages_path,
      skip_package_dependencies_resolution: ENV["HAS_PACKAGES_CACHE_HIT"],
      xcargs: "-skipPackagePluginValidation -skipMacroValidation"
    )
    @app_id = sauce_upload(platform: "ios",
                           app: "#{OUTPUT_NAME}",
                           file: lane_context[SharedValues::IPA_OUTPUT_PATH],
                           region: "us",
                           sauce_username: ENV['SAUCE_USERNAME'],
                           sauce_access_key: ENV['SAUCE_ACCESS_KEY'],
                           app_description: ENV["SAUCE_APP_DESCRIPTION"])
    sh("echo SAUCE_APP_ID_#{SCHEME}=#{@app_id} >> $GITHUB_ENV")
  end

  desc "Build with the AppStore Signature"
  lane :build_signed_application do
    install_saucectl
    # increment_build_number(xcodeproj: "ConsumerMobile.xcodeproj")
    XCODE_VER = ENV['XCODE_VER']
    TSTAMP = ENV['TIME_STAMP']

    # Setup a few utility variables and export them back to Actions
    OUTPUT_DIR = "./build/#{SCHEME}/release"
    sh("echo OUTPUT_DIR=#{OUTPUT_DIR} >> $GITHUB_ENV")
    OUTPUT_NAME = "#{SCHEME}-#{TSTAMP}.ipa"
    sh("echo OUTPUT_NAME=#{OUTPUT_NAME} >> $GITHUB_ENV")

    packages_path = "#{File.expand_path("..", Dir.pwd)}/packages_cache"
    xcodes(version: "#{XCODE_VER}", select_for_current_build_only: true)
    # since we archive with adhoc we need to call match twice to install both profiles
    match(type: "adhoc", readonly: true)
    match(type: "appstore", readonly: true)
    gym(
      scheme: "#{SCHEME}",
      workspace: "ConsumerMobile.xcworkspace",
      output_directory: "#{OUTPUT_DIR}",
      output_name: "#{OUTPUT_NAME}",
      export_method: "app-store",
      export_options: "./fastlane/#{SCHEME}/appstore-export-options.plist",
      export_xcargs: "-allowProvisioningUpdates",
      cloned_source_packages_path: packages_path,
      skip_package_dependencies_resolution: ENV["HAS_PACKAGES_CACHE_HIT"],
      xcargs: "-skipPackagePluginValidation -skipMacroValidation"
    )
    @app_id = sauce_upload(platform: "ios",
                           app: "#{OUTPUT_NAME}",
                           file: lane_context[SharedValues::IPA_OUTPUT_PATH],
                           region: "us",
                           sauce_username: ENV['SAUCE_USERNAME'],
                           sauce_access_key: ENV['SAUCE_ACCESS_KEY'],
                           app_description: ENV["SAUCE_APP_DESCRIPTION"])
    sh("echo SAUCE_APP_ID_#{SCHEME}=#{@app_id} >> $GITHUB_ENV")

    # Send it back to Actions
    XCODEBUILD_ARCHIVE = lane_context[SharedValues::XCODEBUILD_ARCHIVE]
    sh("echo XCODEBUILD_ARCHIVE=#{XCODEBUILD_ARCHIVE} >> $GITHUB_ENV")
    XCODEBUILD_ARCHIVE_NAME = File.basename(XCODEBUILD_ARCHIVE)
    sh("echo XCODEBUILD_ARCHIVE_NAME=#{XCODEBUILD_ARCHIVE_NAME} >> $GITHUB_ENV")
  end

  lane :lint do
    swiftlint(
      mode: :lint, # SwiftLint mode: :lint (default) or :autocorrect
      config_file: ".swiftlint-ci.yml", # The path of the configuration file (optional)
      output_file: "swiftlint.result." + REPORT_EXTENSION[ENV['SWIFTLINT_REPORTER']], # The path of the output file (optional)
      raise_if_swiftlint_error: false, # Allow fastlane to raise an error if swiftlint fails
      ignore_exit_status: false, # Allow fastlane to continue even if SwiftLint returns a non-zero exit status
      quiet: false,
      no_cache: true,
      reporter: ENV['SWIFTLINT_REPORTER']
    )
  end

  lane :installPods do
    cocoapods(
      clean_install: true,
      use_bundle_exec: true,
      try_repo_update_on_error: true
    )
  end

  lane :buildPR do
    install_saucectl
    # increment_build_number(xcodeproj: "ConsumerMobile.xcodeproj")
    XCODE_VER = ENV['XCODE_VER']
    TSTAMP = ENV['TIME_STAMP']
    OUTPUT_DIR = "./build/#{SCHEME}/release"
    sh("echo OUTPUT_DIR=#{OUTPUT_DIR} >> $GITHUB_ENV")
    OUTPUT_NAME = "#{SCHEME}-#{TSTAMP}.ipa"
    sh("echo OUTPUT_NAME_#{SCHEME}=#{OUTPUT_NAME} >> $GITHUB_ENV")
    packages_path = "#{File.expand_path("..", Dir.pwd)}/packages_cache"
    xcodes(version: "#{XCODE_VER}", select_for_current_build_only: true)
    shield
    match(type: "adhoc", readonly: true)
    gym(
      scheme: "#{SCHEME}",
      workspace: "ConsumerMobile.xcworkspace",
      output_directory: "#{OUTPUT_DIR}",
      output_name: "#{OUTPUT_NAME}",
      export_method: "ad-hoc",
      export_options: "./fastlane/#{SCHEME}/adhoc-export-options.plist",
      export_xcargs: "-allowProvisioningUpdates",
      cloned_source_packages_path: packages_path,
      skip_package_dependencies_resolution: ENV["HAS_PACKAGES_CACHE_HIT"],
      xcargs: "-skipPackagePluginValidation -skipMacroValidation"
    )
    @app_id = sauce_upload(platform: "ios",
                           app: "#{OUTPUT_NAME}",
                           file: lane_context[SharedValues::IPA_OUTPUT_PATH],
                           region: "us",
                           sauce_username: ENV['SAUCE_USERNAME'],
                           sauce_access_key: ENV['SAUCE_ACCESS_KEY'],
                           app_description: ENV["SAUCE_APP_DESCRIPTION"])
    sh("echo SAUCE_APP_ID_#{SCHEME}=#{@app_id} >> $GITHUB_ENV")
  end

  desc "Run unit tests"
  lane :tests do
    run_tests(workspace: "ConsumerMobile.xcworkspace",
              scheme: "#{SCHEME}",
              testplan: "#{SCHEME}UnitTestPlan")
  end

  desc "Create Changelog"
  lane :makeChangelog do
    changelog_from_git_commits(
      #           between: ["7b092b3", "HEAD"],  # Optional, lets you specify a revision/tag range between which to collect commit info
      pretty: "- (%ae) %s",
      date_format: "short",
      match_lightweight_tag: false,
      merge_commit_filtering: "exclude_merges"
    )
  end

  error do |lane, exception|
    puts("Something went wrong with the deployment.")
    #       slack(
    #         message: "Something went wrong with the deployment.",
    #         slack_url: "https://hooks.slack.com/services/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",
    #         success: false,
    #         payload: { "Error Info" => exception.error_info.to_s }
    #       )
  end

end
`./fastlane/Appfile`
app_identifier(ENV['APP_IDENTIFIER']) # The bundle identifier of your app
apple_id(ENV['APPLE_ID']) # Your Apple Developer Portal username
itc_team_id(ENV['ITC_TEAM_ID']) # App Store Connect Team ID
team_id(ENV['TEAM_ID']) # Developer Portal Team ID

# For more information about the Appfile, see:
#     https://docs.fastlane.tools/advanced/#appfile

fastlane gems

Gem Version Update-Status
fastlane 2.219.0 ✅ Up-To-Date

Loaded fastlane plugins:

Plugin Version Update-Status
fastlane-plugin-xchtmlreport 0.1.1 ✅ Up-To-Date
fastlane-plugin-synx 0.1.4 ✅ Up-To-Date
fastlane-plugin-semantic_release 1.18.2 ✅ Up-To-Date
fastlane-plugin-simctl 0.2.1 ✅ Up-To-Date
fastlane-plugin-badge 1.5.0 ✅ Up-To-Date
fastlane-plugin-saucectl 0.1.5 ✅ Up-To-Date
Loaded gems
Gem Version
error_highlight 0.5.1
did_you_mean 1.6.3
syntax_suggest 1.0.2
executable-hooks 1.6.1
bundler-unload 1.0.2
rubygems-bundler 1.4.5
bundler 2.4.22
pathname 0.2.1
rake 13.1.0
base64 0.2.0
nkf 0.2.0
rexml 3.2.6
CFPropertyList 3.0.7
bigdecimal 3.1.6
concurrent-ruby 1.2.3
connection_pool 2.4.1
ruby2_keywords 0.0.5
drb 2.2.0
i18n 1.14.1
minitest 5.22.2
mutex_m 0.2.0
tzinfo 2.0.6
activesupport 7.1.3.2
public_suffix 4.0.7
addressable 2.8.6
httpclient 2.8.3
json 2.7.1
algoliasearch 1.27.5
artifactory 3.0.15
atomos 0.1.3
aws-eventstream 1.3.0
aws-partitions 1.894.0
aws-sigv4 1.8.0
jmespath 1.6.2
aws-sdk-core 3.191.3
aws-sdk-kms 1.77.0
aws-sdk-s3 1.143.0
babosa 1.0.4
fastimage 2.3.0
colored 1.2
highline 2.0.3
commander 4.6.0
dotenv 2.8.1
emoji_regex 3.2.3
excon 0.109.0
faraday-em_http 1.0.0
faraday-em_synchrony 1.0.0
faraday-excon 1.1.0
faraday-httpclient 1.0.1
multipart-post 2.4.0
faraday-multipart 1.0.4
faraday-net_http 1.0.1
faraday-net_http_persistent 1.2.0
faraday-patron 1.0.0
faraday-rack 1.0.0
faraday-retry 1.0.3
faraday 1.10.3
domain_name 0.6.20240107
http-cookie 1.0.5
faraday-cookie_jar 0.0.7
faraday_middleware 1.2.0
gh_inspector 1.1.3
jwt 2.8.0
multi_json 1.15.0
os 1.1.4
signet 0.19.0
googleauth 1.8.1
mini_mime 1.1.5
declarative 0.0.20
trailblazer-option 0.1.2
uber 0.1.0
representable 3.2.0
retriable 3.1.2
google-apis-core 0.11.3
google-apis-androidpublisher_v3 0.54.0
google-apis-playcustomapp_v1 0.13.0
google-cloud-env 1.6.0
digest-crc 0.6.5
google-apis-iamcredentials_v1 0.17.0
google-apis-storage_v1 0.31.0
google-cloud-errors 1.3.1
google-cloud-core 1.6.1
google-cloud-storage 1.47.0
mini_magick 4.12.0
naturally 2.2.1
optparse 0.4.0
plist 3.7.1
rubyzip 2.3.2
security 0.1.3
simctl 1.6.10
terminal-notifier 2.0.0
unicode-display_width 2.5.0
terminal-table 3.0.2
tty-screen 0.8.2
tty-cursor 0.7.1
tty-spinner 0.9.3
word_wrap 1.0.0
claide 1.1.0
colored2 3.1.2
nanaimo 0.3.0
xcodeproj 1.24.0
rouge 2.0.7
xcpretty 0.3.0
xcpretty-travis-formatter 1.0.1
badge 0.13.0
clamp 0.6.5
fuzzy_match 2.0.4
nap 1.1.0
netrc 0.11.0
ffi 1.16.3
ethon 0.16.0
typhoeus 1.4.1
cocoapods-core 1.15.2
cocoapods-deintegrate 1.0.5
cocoapods-downloader 2.1
cocoapods-plugins 1.0.0
cocoapods-search 1.0.1
cocoapods-trunk 1.6.0
cocoapods-try 1.2.0
escape 0.0.4
fourflusher 2.3.1
molinillo 0.8.0
ruby-macho 2.5.1
cocoapods 1.15.2
colorize 0.8.1
fastlane-plugin-badge 1.5.0
fastlane-plugin-saucectl 0.1.5
fastlane-plugin-semantic_release 1.18.2
fastlane-plugin-simctl 0.2.1
synx 0.2.1
fastlane-plugin-synx 0.1.4
fastlane-plugin-xchtmlreport 0.1.1

generated on: 2024-02-26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant