SlatherOrg / slather

Generate test coverage reports for Xcode projects & hook it into CI.
MIT License
1.55k stars 236 forks source link

Slather, CircleCI, Fastlane, CodeClimate #430

Open ahmed-khalil opened 5 years ago

ahmed-khalil commented 5 years ago

So for my iOS project my flow is as follows, upon having an open PR on GitHub, an automated CircleCI workflow is triggered which runs some commands and then utilises fastlane to run the builds and tests. After that I need to use slather to upload test coverage information to CodeClimate. On CodeClimate they say that it is possible to use slather for that. Unfortunately, I've been searching the internet for any sort of documentation for how I should configure my .yml file of slather or config file for CircleCi to get this process right and nothing is mentioned anywhere about. Also looked for examples on combining the four of them and nothing. Any help?

kevnm67 commented 4 years ago

@ahmed-khalil I use the same type of setup. Here's an example lane for fastlane:

lane :scan_and_slather do |options|
  scheme = options[:scheme]
  xcproject = options[:xcproject]
  workspace = options[:workspace]

  scan(
    scheme: scheme,
    clean: true,
    code_coverage: true,
    device: options[:device] || 'iPhone 11 Pro'
  )

  slather(
    scheme: scheme,
    circleci: true,
    cobertura_xml: true,
    output_directory: './fastlane/test_output',
    proj: "#{xcproject}.xcodeproj",
    workspace: "#{workspace}.xcworkspace",
    ignore: [
      '../../../Library/*',
      '**/DerivedData/*',
      'Carthage/*'
    ]
  )
end

The above depends on your project (i.e. some options may be omitted depending on your setup).

For circle CI, in your test job something similar to the following:

- run:
    name: Prepare cc-test-reporter
    command: |
      curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 > ./cc-test-reporter
      chmod +x ./cc-test-reporter
      ./cc-test-reporter before-build
- run:
    name: run tests
    command: |
      bundle exec fastlane scan_and_slather
- run:
    command: ./cc-test-reporter after-build