Skip to content

Instantly share code, notes, and snippets.

@fjcaetano
Last active February 8, 2021 19:59
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjcaetano/04126b3051f6cd6aebe041bb1dfe14e9 to your computer and use it in GitHub Desktop.
Save fjcaetano/04126b3051f6cd6aebe041bb1dfe14e9 to your computer and use it in GitHub Desktop.
Codecov Fastlane action
module Fastlane
module Actions
class CodecovAction < Action
def self.run(params)
ci_only = params[:ci_only]
cmd = ['curl -s https://codecov.io/bash | bash']
cmd << "-s --" if params.all_keys.inject(false) { |p, k| p or params[k] }
cmd << "-X xcodeplist" if params[:use_xcodeplist]
cmd << "-J '#{params[:project_name]}'" if params[:project_name]
cmd << "-t '#{params[:token]}'" if params[:token]
cmd << "-v" if params[:verbose]
if Helper.is_ci? || !ci_only
sh cmd.join(" ")
else
puts "Not CI: Skipping coverage files upload"
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Upload your coverage files to Codecov"
end
def self.details
"https://codecov.io"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :use_xcodeplist,
env_name: "FL_CODECOV_USE_XCODEPLIST",
description: "[BETA] Upload to Codecov using xcodeplist",
is_string: false,
default_value: false,),
FastlaneCore::ConfigItem.new(key: :project_name,
env_name: "FL_CODECOV_PROJECT_NAME",
description: "Upload to Codecov using a project name",
optional: true),
FastlaneCore::ConfigItem.new(key: :token,
env_name: "FL_CODECOV_TOKEN",
description: "API token for private repos",
optional: true),
FastlaneCore::ConfigItem.new(key: :verbose,
env_name: "FL_CODECOV_VERBOSE",
description: "Verbose logs",
is_string: false,
optional: true,
default_value: false),
FastlaneCore::ConfigItem.new(key: :ci_only,
env_name: "FL_CODECOV_CI_ONLY",
description: "Upload coverage only if running on CI",
is_string: false,
optional: true,
default_value: true),
]
end
def self.author
"Flávio Caetano (@fjcaetano)"
end
def self.is_supported?(platform)
true
end
end
end
end
@fjcaetano
Copy link
Author

fjcaetano commented Jul 10, 2019

Installation

  1. Add this gist as a submodule
$ git submodule add https://gist.github.com/04126b3051f6cd6aebe041bb1dfe14e9.git fastlane/actions/codecov
  1. Create a symlink in the action folder
$ ln -s codecov/codecov.rb fastlane/actions/codecov.rb
  1. Check if it is working in your project's root directory:
$ fastlane actions codecov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment