Last active
February 8, 2021 19:59
-
-
Save fjcaetano/04126b3051f6cd6aebe041bb1dfe14e9 to your computer and use it in GitHub Desktop.
Codecov Fastlane action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation