-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Fastfile
676 lines (552 loc) · 23.3 KB
/
Fastfile
1
2
3
4
5
6
7
8
9
10
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
48
49
50
51
52
53
54
55
56
57
58
59
60
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
require 'fileutils'
fastlane_require 'xcodeproj'
skip_docs # Do not create fastlane/README.txt
# Test and Validate
desc "Runs the unit tests and other verifications for the fastlane repo"
lane :test do |options|
validate_repo
end
desc "Verifies all tests pass and the current state of the repo is valid"
lane :validate_repo do
lint_source
execute_tests
validate_docs
ensure_tool_name_formatting
ensure_code_samples
ensure_special_docs_code_samples
ensure_code_snippets
ensure_actions_config_items_formatting
end
desc "Verifies source code is in a good state"
lane :lint_source do
# Verifying that no debug code is in the code base
#
exclude_dirs = ["\.bundle", "*/vendor/bundle"]
ensure_no_debug_code(text: "binding.pry", extension: ".rb", exclude: "playground.rb", exclude_dirs: exclude_dirs) # debugging code
ensure_no_debug_code(text: "# TODO", extension: ".rb", exclude_dirs: exclude_dirs) # TODOs
ensure_no_debug_code(text: "now: ", extension: ".rb", exclude_dirs: exclude_dirs) # rspec focus
ensure_no_debug_code(text: "<<<<<<<", extension: ".rb", exclude_dirs: exclude_dirs) # Merge conflict
# spaceship and credentials_manager don't have access to fastlane_core
ensure_no_debug_code(text: " UI\\.", path: "spaceship/lib", extension: ".rb", exclude_dirs: exclude_dirs)
ensure_no_debug_code(text: " UI\\.", path: "credentials_manager/lib", extension: ".rb", exclude_dirs: exclude_dirs)
rubocop(step_name: 'policekeeping_the_code_with_rubocop')
Dir.chdir("..") do
# Verify shell code style
if FastlaneCore::Helper.mac?
sh('find -E . -regex ".*\.(sh|bash)" -not -name "Pods-*" -name ".bundle" -exec shellcheck {} +')
elsif !FastlaneCore::Helper.windows?
sh('find . -regextype posix-egrep -regex ".*\.(sh|bash)" -not -name "Pods-*" -name ".bundle" -exec shellcheck {} +')
end
end
end
desc "Measure the execution time of the --help command"
lane :benchmark_help_command do
Dir.chdir("..") do
# install gnomon if not installed yet
Actions.sh("echo foo | gnomon", log: true, error_callback: lambda { |result|
if Helper.windows? || Helper.mac?
sh('npm install -g gnomon')
else
sh('sudo npm install -g gnomon')
end
})
cmd = Helper.windows? ? "cd bin && fastlane --help | gnomon" : "bin/fastlane --help | gnomon"
3.times do
content = sh(cmd, log: false)
content.each_line do |line|
UI.message("🏎️ '#{line.strip}'") if ["Total", "real", "user", "sys"].any? { |word| line.include?(word) }
end
end
end
end
desc "Runs the tests"
lane :execute_tests do
version = local_version # has to be outside of the `Dir.chdir`
# Verifying the --help command
Dir.chdir("..") do
cmd = Helper.windows? ? "cd bin && fastlane --help" : "PAGER=cat bin/fastlane --help"
content = sh(cmd)
["--version", "https://fastlane.tools", "fastlane"].each do |current|
UI.user_error!("--help missing information: '#{current}'") unless content.include?(current)
end
end
benchmark_help_command
Dir.chdir("..") do
# Install the bundle and the actual gem
sh("bundle check || bundle install")
sh("rake install")
# Ensure the file size of the fastlane gem is below 1.5 MB
size_in_mb = File.size("pkg/fastlane-#{version}.gem").to_f / (1024 * 1024 * 1.5)
UI.user_error!("fastlane gem is above 1.5 MB, make sure no additional resources are included by mistake") if size_in_mb > 1
# Run the tests
sh("bundle exec rake test_all")
end
end
# Release Management
desc "Increment the version number of this gem, after generating new Swift API"
lane :bump do |options|
verify_env_variables
ensure_git_branch(branch: "master")
ensure_git_status_clean
github_api_token = ENV["FL_GITHUB_RELEASE_API_TOKEN"]
UI.user_error!("Please provide a GitHub API token using `FL_GITHUB_RELEASE_API_TOKEN`") if github_api_token.to_s.length == 0
paths_for_commit = []
version_file_path = "./fastlane/lib/fastlane/version.rb"
# Verify everything is in a consistent state
latest_version = current_version
local_version = version_get_podspec(path: version_file_path, require_variable_prefix: false)
UI.user_error!("Version on RubyGems doesn't match local repo: #{latest_version} != #{local_version}") if latest_version != local_version
changelog_text = show_changelog
bump_type ||= 'minor' if prompt(text: "New feature, method or API?", boolean: true)
bump_type ||= 'patch'
slug = "fastlane/fastlane"
new_version = version_bump_podspec(path: version_file_path, bump_type: bump_type, require_variable_prefix: false)
# Everything looks good, let's generate the Swift API
generate_swift_api(fastlane_version: new_version)
# Alright, now let's update our FastlaneSwiftRunner manifest
generate_fastlane_swift_runner_manifest
# Add all changed files to the version bump commit
paths_for_commit += sh("cd .. && git status --porcelain fastlane/swift | sed s/^...//").each_line.to_a.map(&:strip)
paths_for_commit << "Gemfile.lock"
# Add version file path to change set
paths_for_commit << version_file_path
sh("bundle exec rake generate_team_table")
paths_for_commit << "README.md"
sh("bundle exec rake update_gem_spec_authors")
paths_for_commit << "fastlane.gemspec"
sh("git checkout -b 'version-bump-#{new_version}'")
commit_message = "Version bump to #{new_version}"
git_commit(path: paths_for_commit,
message: commit_message)
push_to_git_remote
pr_body = ["Auto-generated by fastlane 🤖"]
pr_body << "**Changes since release '#{latest_version}':**"
pr_body << changelog_text
pr_url = create_pull_request(
api_token: github_api_token,
repo: slug,
title: commit_message,
body: pr_body.join("\n\n")
)
if ENV['SLACK_URL']
slack(
channel: "action",
default_payloads: [],
message: "Version bump: #{pr_url} ✨",
payload: {}
)
end
# Revert to master branch
sh("git checkout master")
end
desc "Generate the Swift api and test it"
lane :generate_swift_api do |options|
Fastlane::VERSION = options[:fastlane_version] if options[:fastlane_version]
require "../fastlane/lib/fastlane/swift_fastlane_api_generator.rb"
swift_generator = Fastlane::SwiftFastlaneAPIGenerator.new
generated_files = swift_generator.generate_swift
Dir.chdir("swift/formatting") do
sh("rake")
UI.success("Done formatting fastlane.swift API")
end
UI.success("Done generating fastlane.swift API, ensuring it builds")
gym(
project: File.expand_path("swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj"),
skip_package_ipa: true
)
sh("swift build")
sh("rm -r ../.build")
sh("rm ../FastlaneRunner")
generated_files
end
desc "Generate the FastlaneSwiftRunner project manifest"
lane :generate_fastlane_swift_runner_manifest do |options|
# Don't attempt to upgrade config files, like Fastfile.swift, Deliverfile.swift, etc...
non_upgrade_set = TOOL_CONFIG_FILES.map { |tool_name| "#{tool_name}.swift" }.to_set
swift_folder = File.expand_path("swift")
runner_project_path = File.expand_path(File.join(swift_folder, "/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj"))
project = Xcodeproj::Project.open(runner_project_path)
swift_files = project.files
.reject { |file| file.name.nil? }
.reject { |file| non_upgrade_set.include?(file.name) }
.select { |file| file.name.end_with?(".swift") }
# It is assumed that all Swift files we're including are contained in the root group, or 1 group deep
swift_filenames_to_group_name = swift_files.each_with_object({}) { |file, object| object[file.name] = file.parent.name }
manifest_path = File.expand_path(File.join(swift_folder, "/upgrade_manifest.json"))
File.write(manifest_path, swift_filenames_to_group_name.to_json)
UI.success("Done generating FastlaneSwiftRunner project manifest")
manifest_path
end
desc "Does everything that's needed for a release"
desc "This includes running tests and verifying the GitHub release"
lane :release do
verify_env_variables
slack_train_start(distance: 2,
train: "🚀",
reverse_direction: true,
rail: "✨")
update_fastlane
slack_train
# Git verification
#
ensure_git_status_clean
ensure_git_branch(branch: 'master')
git_pull
validate_repo
# Verifying RubyGems version
#
version = local_version
old_version = current_version
puts("Deploying #{version}")
if Gem::Version.new(version) <= Gem::Version.new(old_version)
UI.user_error!("Version number #{version} was already deployed")
end
# Then push to git remote
#
push_to_git_remote
# Preparing GitHub Release
#
github_release = get_github_release(url: "fastlane/fastlane", version: version)
if (github_release || {}).fetch('body', '').length == 0
show_changelog(old_version: old_version)
title = prompt(text: 'Title: ')
description = prompt(text: "Please enter a changelog (make sure to rephrase changes to make it easy to understand, and remove non-important changes that don't affect the end-user): ",
multi_line_end_keyword: "END")
github_release = set_github_release(
repository_name: "fastlane/fastlane",
name: [version, title].join(" "),
tag_name: version,
description: description,
is_draft: false
)
# Actual release of the gem
# Using IO.popen because `gem push` will prompt for 2FA if enabled
#
command = "gem push ../pkg/fastlane-#{version}.gem"
IO.popen(command) do |io|
io.each do |line|
puts(line)
end
end
release_url = github_release['html_url']
message = [title, description, release_url].join("\n\n")
add_fastlane_git_tag(tag: "fastlane/#{version}", message: message)
end
# After publishing
#
if ENV['SLACK_URL']
release_notes = github_release['body']
# markup - turn github references into links
release_notes.gsub!(/\(#([0-9]+)\)/, '(<https://github.com/fastlane/fastlane/issues/\1|#\1>)')
slack_message = "Successfully released [fastlane #{version}](#{release_url}) :rocket:"
slack(
channel: "releases",
default_payloads: [],
message: slack_message,
payload: {
"New" => release_notes
}
)
slack(channel: "action", default_payloads: [], message: slack_message)
end
clubmate
puts("You can now tweet:".green)
releases_url = "https://github.com/fastlane/fastlane/releases/tag/#{version}"
puts("[fastlane] #{github_release['name']} #{releases_url}")
send_mac_app_ci_reminder
update_docs(version: version)
release_brew
release_github
slack_train
end
lane :release_brew do
version = local_version
sh("cd .. && brew bump-formula-pr fastlane --force --url=https://github.com/fastlane/fastlane/archive/#{version}.tar.gz")
end
lane :release_github do
version = local_version
sh("cd .. &&gem push --key github --host https://rubygems.pkg.github.com/fastlane pkg/fastlane-#{version}.gem")
end
desc "Notifies Fabric Slack to run CI Job for Mac App"
private_lane :send_mac_app_ci_reminder do
if ENV['FABRIC_SLACK_URL']
slack(
slack_url: ENV['FABRIC_SLACK_URL'],
channel: 'deployment-tools',
default_payloads: [],
message: "Please run the Fastlane Mac App Package CI job in TeamCity\n#{ENV['FABRIC_MAC_APP_CI_JOB_URL']}"
)
end
end
desc "Generate changelog from GitHub compare and PR data for mentioning GitHub usernames in release notes"
private_lane :github_changelog do |options|
old_version = options[:old_version] || current_version
path = "/repos/fastlane/fastlane/compare/#{old_version}...HEAD"
# Get all commits from previous version (tag) to HEAD
resp = github_api(path: path)
body = JSON.parse(resp[:body])
commits = body["commits"].reverse
formatted = commits.map do |commit|
# Default to commit message info
message = commit["commit"]["message"].lines.first.strip
name = commit["commit"]["author"]["name"]
username = commit["author"]["login"]
# Get pull request associate with commit message
sha = commit["sha"]
pr_resp = github_api(path: "/search/issues?q=repo:fastlane/fastlane+is:pr+base:master+SHA:#{sha}")
body = JSON.parse(pr_resp[:body])
items = body["items"]
item_infos = items.map do |item|
message = "#{item['title']} (##{item['number']})"
username = item["user"]["login"]
[message, username]
end
if item_infos.size == 0
if UI.confirm("Error generating changelog. No commit found for #{sha}. Skip?")
next
else
UI.user_error!("Cannot generate changelog. No commit found for #{sha}")
end
elsif item_infos.size == 1
message = item_infos[0][0]
username = item_infos[0][1]
else
options = item_infos.map do |item|
"#{item[1]} - #{item[0]})"
end
option = UI.select("Which changelog?", options)
index = options.index(option)
message = item_infos[index][0]
username = item_infos[index][1]
end
"* #{message} via #{name} (@#{username})"
end.compact.join("\n")
formatted
end
desc "Print out the changelog since the last tagged release and open the GitHub page with the changes"
lane :show_changelog do |options|
old_version = options[:old_version] || current_version
changes = github_changelog(old_version: old_version)
github_diff_url = "https://github.com/fastlane/fastlane/compare/#{old_version}...master"
sh("open #{github_diff_url}")
puts("Changes since release #{old_version}:\n\n#{changes.cyan}")
changes # return the text without the modified colors
end
desc "Add a git tag in the fastlane repo for this release"
private_lane :add_fastlane_git_tag do |options|
`git tag -am #{options[:message].shellescape} #{options[:tag].shellescape}`
push_git_tags
end
# Docs
desc "Validates the docs still are good"
lane :validate_docs do
# Validate docs content
ensure_tool_name_formatting
ensure_code_samples
ensure_special_docs_code_samples
ensure_code_snippets
# (Validate action documentation)
ensure_actions_config_items_formatting
# Test if generating the docs is successful
clone_docs do
generate_markdown_docs(target_path: ".")
end
# Verify docs are still working
verify_docs
end
desc "Makes sure the tests on https://docs.fastlane.tools still work with the latest version"
lane :verify_docs do
clone_docs do
Bundler.with_clean_env do
puts(`sed -i -e "s/activate_bin_path/bin_path/g" $(which bundle)`) # workaround for bundler https://github.com/bundler/bundler/issues/4602#issuecomment-233619696
sh("bundle install")
sh("bundle exec fastlane test skip_building:true") # skip_building since we don't have a proper python environment set up
end
end
end
desc "Update the actions.md on https://docs.fastlane.tools"
desc "This will also automatically submit a pull request to fastlane/docs"
lane :update_docs do |options|
debug = options[:debug]
version = options[:version]
unless debug
verify_env_variables
ensure_actions_config_items_formatting
end
template_path = File.expand_path("./assets/render_plugin.md.erb")
clone_docs(debug: debug) do
plugin_scores_cache_path = File.expand_path("./plugin_scores_cache.yml")
docs_path = generate_markdown_docs(target_path: ".")
yml_path = File.expand_path("./mkdocs.yml")
actions_md_path = File.expand_path(File.join(docs_path, "docs/generated/actions.md"))
action_docs = Dir[File.join(docs_path, "docs", "generated", "actions", "*")].collect do |current|
File.expand_path(current) # to make sure we commit the change
end
# Copy over the custom assets
custom_action_docs_path = "lib/fastlane/actions/docs/"
custom_assets = Dir[File.join(Fastlane::ROOT, custom_action_docs_path, "assets", "*")].collect do |current_asset_path|
current_output_path = File.join("docs/img/actions", File.basename(current_asset_path))
FileUtils.cp(current_asset_path, current_output_path)
File.expand_path(current_output_path) # to make sure we commit the change
end
unless options[:skip_bundle_update]
Bundler.with_clean_env do
sh("bundle update")
end
end
if `git status --porcelain`.length == 0
UI.success("No changes in the actions.md ✅")
else
# Create a new branch
sh("git checkout -b 'update-actions-md-#{Time.now.to_i}'") unless debug
plugins_path = "docs/plugins/available-plugins.md"
unless options[:skip_plugin_scores]
plugin_scores(template_path: template_path,
output_path: plugins_path,
cache_path: plugin_scores_cache_path)
end
next if debug
Dir.chdir("fastlane") do # this is an assumption of fastlane, that we have to .. when shelling out
# Commit the changes
changes_to_commit = [plugin_scores_cache_path, actions_md_path, "Gemfile.lock", plugins_path, yml_path] + action_docs + custom_assets
git_add(path: changes_to_commit)
git_commit(path: changes_to_commit,
message: "Update docs for latest fastlane release #{version} (actions.md, available-plugins.md) 🚀")
# Push them to the git remote
push_to_git_remote
# Submit the pull request
pr_url = create_pull_request(
api_token: ENV["FL_GITHUB_RELEASE_API_TOKEN"],
repo: "fastlane/docs",
title: "[Bot] Update docs for latest fastlane release #{version} (actions.md, available-plugins.md) 🚀",
body: "Auto-generated by _fastlane_ bot 🤖"
)
UI.success("Successfully submitted a pull request to fastlane/docs: #{pr_url} 🚀")
end
end
end
end
def clone_docs(debug: false)
if debug
clone_url = ENV['FASTLANE_DOCS_CLONE_URL'] || "../../docs"
Dir.chdir(clone_url) do
yield
end
else
require 'tmpdir'
git_url = ENV['FASTLANE_DOCS_GIT_URL'] || "https://github.com/fastlane/docs"
Dir.mktmpdir("fl_clone") do |tmp_dir|
Dir.chdir(tmp_dir) do
sh("git clone #{git_url} --depth=1")
Dir.chdir("docs") do
yield
end
end
end
end
end
def generate_markdown_docs(target_path: nil)
require 'fastlane/documentation/markdown_docs_generator'
Fastlane::MarkdownDocsGenerator.new.generate!(target_path: File.expand_path(target_path))
return target_path
end
# Exception Handling
error do |lane, exception|
if ENV['SLACK_URL']
slack(channel: "testing", message: exception.to_s, success: false)
end
slack_train_crash
end
# Helper
desc "Ensure all the requirement environment variables are provided"
desc "this way the deployment script will fail early (and often)"
private_lane :verify_env_variables do
ensure_env_vars(env_vars: ['GITHUB_USER_NAME', 'GITHUB_API_TOKEN'])
UI.user_error!("You're not logged in RubyGems. Log in using `gem push` if using RubyGems < 2.7.0 or `gem signin` if using RubyGems >=2.7.0") unless File.file?(File.expand_path("~/.gem/credentials"))
end
desc "Get the local version number per version.rb"
private_lane :local_version do
require_relative "../fastlane/lib/fastlane/version.rb"
Fastlane::VERSION
end
desc "Get the version number of the last release"
private_lane :current_version do
puts("Checking the latest version on RubyGems")
download(url: "https://rubygems.org/api/v1/gems/fastlane.json")["version"]
end
desc "Ensure the correct formatting for the fastlane tools"
private_lane :ensure_tool_name_formatting do
UI.message("🕗 Verifying tool name formatting...")
require 'fastlane/tools'
errors = []
Dir.chdir("..") do
Dir["**/*.md"].each do |path|
content = File.read(path)
Fastlane::TOOLS.each do |tool|
errors << "Use _#{tool}_ instead of `#{tool}` to mention a tool in the docs in '#{path}'" if content.include?("`#{tool}`")
errors << "Use _#{tool}_ instead of `_#{tool}_` to mention a tool in the docs in '#{path}'" if content.include?("`_#{tool}_`")
errors << "Use [_#{tool}_] instead of [#{tool}] to mention a tool in the docs in '#{path}'" if content.include?("[#{tool}]")
errors << "Use <em>#{tool}<em> instead of <code>#{tool}</code> to mention a tool in the docs in '#{path}'" if content.include?("<code>#{tool}</code>")
if content.include?("_#{tool.to_s.capitalize}_") || content.include?("`#{tool.to_s.capitalize}`")
errors << "fastlane tools have to be formatted in lower case: #{tool} in '#{path}'"
end
end
end
end
errors.each { |a| UI.error(a) }
UI.user_error!("Invalid formatting of one of the fastlane tools") unless errors.empty?
UI.success("✅ fastlane tools formatting is correct")
end
# Run the code samples, yo
private_lane :ensure_code_samples do
UI.message("🕗 Verifying all action code samples work with the current fastlane release")
all_content = ""
count_actions = 0
ActionsList.all_actions do |action|
all_content += "```ruby\n"
all_content += action.example_code.map { |code| code.gsub(/^\s+/, '') }.join("\n") if action.example_code
all_content += "\n```"
count_actions += 1
end
test_sample_code(content: all_content) # to not have to call the action 200 times
UI.success("✅ All fastlane action code samples (from #{count_actions} actions) work as expected")
end
# Run the other code samples, yo
private_lane :ensure_special_docs_code_samples do
UI.message("🕗 Verifying all action special docs (`fastlane/lib/fastlane/actions/docs`) code samples work with the latest fastlane release")
all_content = ""
files = Dir["../fastlane/lib/fastlane/actions/docs/*.md"]
files.each do |special_docs_page_path|
all_content += File.read(special_docs_page_path)
end
test_sample_code(content: all_content) # to not have to call the action 200 times
UI.success("✅ All fastlane action special docs code samples (from #{files.length} files) work as expected")
end
private_lane :ensure_code_snippets do
UI.message("🕗 Verifying all code snippets are correctly formatted")
shell_commands_start = '((bundle|fastlane)[ ]|[A-Z_]+=)'
errors = []
require 'fastlane/documentation/markdown_docs_generator'
Fastlane::MarkdownDocsGenerator.new.actions_md_contents.each do |action_name, content|
errors << "Use '```no-highlight ↵ <code snippet> ↵ ```' instead of '```<language> ↵ <code snippet> ↵ ```' for code snippets for action '#{action_name}'" if content =~ /```(?<!no-higlight)\w+\s*#{shell_commands_start}/
errors << "Use '```no-highlight ↵ <code snippet> ↵ ```' instead of ' <code snippet>' for code snippets for action '#{action_name}'" if content =~ /^[ ]{4}#{shell_commands_start}/
end
errors.each { |a| UI.error(a) }
UI.user_error!("Invalid formatting of one of the code snippets") unless errors.empty?
UI.success("✅ All code snippets are formatted as expected")
end
private_lane :ensure_actions_config_items_formatting do
UI.message("🕗 Verifying actions' config items formatting...")
errors = []
require 'fastlane_core/configuration/config_item'
ActionsList.all_actions do |action|
next if action.available_options.nil?
action.available_options.each do |option|
next unless option.kind_of?(FastlaneCore::ConfigItem)
errors << "Remove the '\\n' from the config item ':#{option.key}' of the action '#{action.action_name}'" if option.description && option.description =~ /\n|\\n/
end
end
errors.each { |a| UI.error(a) }
UI.user_error!("Invalid formatting of one of the actions' config items") unless errors.empty?
UI.success("✅ fastlane actions' config items formatting is correct")
end