fastlane-community / xcov

Nice code coverage reporting without hassle
MIT License
556 stars 107 forks source link

xcov 1.4 is not reading reports from Xcode 9.3 #121

Closed eMdOS closed 6 years ago

eMdOS commented 6 years ago
✅ fastlane environment ✅ ### Stack | Key | Value | | --------------------------- | ------------------------------------------- | | OS | 10.13.3 | | Ruby | 2.4.1 | | Bundler? | true | | Git | git version 2.15.1 (Apple Git-101) | | Installation Source | ~/.rvm/gems/ruby-2.4.1/bin/fastlane | | Host | Mac OS X 10.13.3 (17D102) | | Ruby Lib Dir | ~/.rvm/rubies/ruby-2.4.1/lib | | OpenSSL Version | OpenSSL 1.1.0h 27 Mar 2018 | | Is contained | false | | Is homebrew | false | | Is installed via Fabric.app | false | | Xcode Path | /Applications/Xcode.app/Contents/Developer/ | | Xcode Version | 9.3 | ### System Locale | Variable | Value | | | -------- | ----------- | - | | LANG | en_US.UTF-8 | ✅ | | LC_ALL | | | | LANGUAGE | | | ### fastlane files:
`./fastlane/Fastfile` ```ruby # 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 # # Uncomment the line if you want fastlane to automatically update itself # update_fastlane default_platform(:ios) platform :ios do desc "" lane :test do clear_derived_data scan( workspace: "Test.xcworkspace", scheme: "Module", clean: true, build_for_testing: true, code_coverage: true, output_directory: "./fastlane/output/tests" ) xcov( workspace: "Test.xcworkspace", scheme: "Module", output_directory: "./fastlane/output/code coverage" ) end end ```
`./fastlane/Appfile` ```ruby # For more information about the Appfile, see: # https://docs.fastlane.tools/advanced/#appfile ```
### fastlane gems | Gem | Version | Update-Status | | -------- | ------- | ------------- | | fastlane | 2.92.1 | ✅ Up-To-Date | ### Loaded fastlane plugins: **No plugins Loaded**
Loaded gems | Gem | Version | | ------------------------- | ------------ | | did_you_mean | 1.1.0 | | io-console | 0.4.6 | | CFPropertyList | 3.0.0 | | public_suffix | 2.0.5 | | addressable | 2.5.2 | | atomos | 0.1.2 | | babosa | 1.0.2 | | bundler | 1.16.1 | | claide | 1.0.2 | | colored | 1.2 | | colored2 | 3.1.2 | | highline | 1.7.10 | | commander-fastlane | 4.4.6 | | declarative | 0.0.10 | | declarative-option | 0.1.0 | | unf_ext | 0.0.7.5 | | unf | 0.1.4 | | domain_name | 0.5.20180417 | | dotenv | 2.3.0 | | emoji_regex | 0.1.1 | | excon | 0.62.0 | | multipart-post | 2.0.0 | | faraday | 0.15.0 | | http-cookie | 1.0.3 | | faraday-cookie_jar | 0.0.6 | | faraday_middleware | 0.12.2 | | fastimage | 2.1.1 | | gh_inspector | 1.1.3 | | jwt | 2.1.0 | | little-plugger | 1.1.4 | | multi_json | 1.13.1 | | logging | 2.2.2 | | memoist | 0.16.0 | | os | 0.9.6 | | signet | 0.8.1 | | googleauth | 0.6.2 | | httpclient | 2.8.3 | | mime-types-data | 3.2016.0521 | | mime-types | 3.1 | | uber | 0.1.0 | | representable | 3.0.4 | | retriable | 3.1.1 | | google-api-client | 0.13.6 | | json | 2.1.0 | | mini_magick | 4.5.1 | | multi_xml | 0.6.0 | | plist | 3.4.0 | | rubyzip | 1.2.1 | | security | 0.1.3 | | naturally | 2.1.0 | | simctl | 1.6.4 | | slack-notifier | 2.3.2 | | terminal-notifier | 1.8.0 | | unicode-display_width | 1.3.2 | | terminal-table | 1.8.0 | | tty-screen | 0.6.4 | | tty-cursor | 0.5.0 | | tty-spinner | 0.8.0 | | word_wrap | 1.0.0 | | nanaimo | 0.2.5 | | xcodeproj | 1.5.7 | | rouge | 2.0.7 | | xcpretty | 0.2.8 | | xcpretty-travis-formatter | 1.0.0 | | xcov | 1.4.0 |
*generated on:* **2018-04-23**

It is always failing and crashing ...

[13:18:48]: Unable to find any .xccoverage file.
[13:18:48]: Make sure you have enabled 'Gather code coverage' setting on your scheme settings.
[13:18:48]: Alternatively you can provide the full path to your .xccoverage file.

...

/Users/user/.rvm/gems/ruby-2.4.1/gems/xcov-1.4.0/lib/xcov/error_handler.rb:20:in `handle_error': [!] Error creating your coverage report - see the log above (RuntimeError)

... which does not make sense since I am using Xcode 9.3 (which is using .xccovreport format).

Gather code coverage option is enabled/checked.

Is there another way to configure the xcov lane in order to make it work properly?

chrisballinger commented 6 years ago

Try manually passing in the derived data folder. For example:


BUILD_PATH="./build"
DERIVED_DATA_PATH = "#{BUILD_PATH}/derived_data"
PROJECT_NAME='BonMot.xcodeproj'

...

  begin
    scan(
      output_types: 'junit,html',
      devices: devices,
      destination: destination,
      scheme: scheme,
      output_directory: scan_output_path,
      code_coverage: true,
      derived_data_path: DERIVED_DATA_PATH,
      result_bundle: true,
      disable_concurrent_testing: disable_concurrent_testing
    )
  rescue => ex
    # Don't fail the entire lane when running tests, but print failure to STDERR
    STDERR.puts ex
  end

  xcov(
    project: PROJECT_NAME,
    scheme: scheme,
    output_directory: "#{BUILD_PATH}/#{scheme}/xcov",
    derived_data_path: DERIVED_DATA_PATH
  )
Usipov commented 6 years ago

Xcode 9 has changed the way it stores coverage reports Xcode 9.3 also includes a new command line tool to represent coverage data in both human-readable and machine-parseable format: xccov (see man xccov)

In general there are now two files instead of one: .xccovreport and .xccovarchive. The coverage report contains line coverage percentages for each target, source file, and function/method that has coverage information. The coverage archive contains the raw execution counts for each file in the report

hungrxyz commented 6 years ago

Same issue.

nakiostudio commented 6 years ago

Hi @eMdOS @markobyte 👋

Can I see the arguments you're passing to xcov? Thanks :)

hungrxyz commented 6 years ago

I'm trying to use it with BuddyBuild following this tutorial: https://www.buddybuild.com/blog/using-danger-ci-with-buddybuild

xcov.report(  
   scheme: ENV['BUDDYBUILD_SCHEME'],
   workspace: "#{ENV['BUDDYBUILD_WORKSPACE']}/xx.workspace",
   minimum_coverage_percentage: XX,
   derived_data_path: ENV['BUDDYBUILD_TEST_DIR'],
)
nakiostudio commented 6 years ago

@markobyte is BuddyBuild running Xcode 9.3? and the latest version of xcov?

Also, could you try with derived_data_path: "/tmp/sandbox/#{ENV['BUDDYBUILD_APP_ID']}/bbtest" instead of derived_data_path: ENV['BUDDYBUILD_TEST_DIR']?

hungrxyz commented 6 years ago

Stupid mistake on my side. For some reason I though BuddyBuild is doing bundle update. Works after updating the bundle locally.

nakiostudio commented 6 years ago

Thanks for the update @markobyte 👍. It's always tricky to draw line between the things BB does automatically and the things you need to do by yourself.

nakiostudio commented 6 years ago

Closing for lack of activity.