Class: Fastlane::Actions::IosCheckBetaDepsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb

Constant Summary collapse

ALL_PODS_STABLE_MESSAGE =
'All pods are pointing to a stable version. You can continue with the code freeze.'
NON_STABLE_PODS_MESSAGE =
"Please create a new stable version of those pods and update the Podfile to the newly released version before continuing with the code freeze:\n"

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



104
105
106
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb', line 104

def self.authors
  ['Automattic']
end

.available_optionsObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb', line 61

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :lockfile,
      description: 'Path to the Podfile.lock to analyse',
      default_value: 'Podfile.lock',
      type: String,
      verify_block: proc do |value|
        UI.user_error!("File `#{value}` does not exist") unless File.exist?(value)
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :report_commits,
      description: 'Whether to report pods referenced by commit',
      default_value: true,
      type: Boolean
    ),
    FastlaneCore::ConfigItem.new(
      key: :report_branches,
      description: 'Whether to report pods referenced by branch',
      default_value: true,
      type: Boolean
    ),
    FastlaneCore::ConfigItem.new(
      key: :report_version_pattern,
      description: 'Report any pod whose resolved version matches this Regex pattern. Set to empty string to ignore',
      default_value: '-beta|-rc',
      type: String
    ),
  ]
end

.descriptionObject



53
54
55
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb', line 53

def self.description
  'Runs some prechecks before finalizing a release'
end

.detailsObject



57
58
59
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb', line 57

def self.details
  'Runs some prechecks before finalizing a release'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb', line 108

def self.is_supported?(platform)
  i[ios mac].include?(platform)
end

.outputObject



93
94
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb', line 93

def self.output
end

.return_valueObject



96
97
98
99
100
101
102
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb', line 96

def self.return_value
  "    A Hash with keys `message` and `pods`.\n    - The `message` can be used to e.g. post a Buildkite annotation.\n    - The `pods` is itself a `Hash` whose keys are the pod names and values are the reason for the violation\n  RETURN_VALUE\nend\n"

.run(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb', line 11

def self.run(params)
  yaml = YAML.load_file(params[:lockfile])
  non_stable_pods = {} # Key will be pod name, value will be reason for flagging

  # Find pods referenced by commit and branch to a repo. if any
  yaml['EXTERNAL SOURCES']&.each do |pod, options|
    non_stable_pods[pod] = 'commit' if params[:report_commits] && options.key?(:commit)
    non_stable_pods[pod] = 'branch' if params[:report_branches] && options.key?(:branch)
  end

  # Find pods whose resolved version matches the regex
  version_pattern = params[:report_version_pattern]
  unless version_pattern.nil? || version_pattern.empty?
    regex = begin
      Regexp.new(version_pattern)
    rescue RegexpError
      UI.user_error!("Invalid regex pattern: `#{version_pattern}`")
    end
    resolved_pods = yaml['PODS'].flat_map { |entry| entry.is_a?(Hash) ? entry.keys : entry }
    resolved_pods.each do |line|
      (pod, version) = /(.*) \((.*)\)/.match(line)&.captures
      non_stable_pods[pod] = regex.source if regex.match?(version)
    end
  end

  message = String.new
  if non_stable_pods.empty?
    message << ALL_PODS_STABLE_MESSAGE
  else
    message << NON_STABLE_PODS_MESSAGE
    non_stable_pods.sort.each do |pod, reason|
      message << " - #{pod} (currently points to #{reason})\n"
    end
  end
  UI.important(message)
  { message: message, pods: non_stable_pods }
end