Repository navigation
Expand file tree
/
Copy pathRakefile
More file actions
93 lines (74 loc) · 3.33 KB
/
Copy pathRakefile
File metadata and controls
93 lines (74 loc) · 3.33 KB
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
require "bundler/gem_tasks"
# The release workflow runs `rake release` (rubygems/release-gem) after the create_github_release lane has already
# tagged the release. Prevent another tag.
Rake::Task["release:source_control_push"].clear
Dir.glob("internal/rakelib/*.rake").each { |r| load r }
task(:test_all) do
formatter = "--format progress"
# On GitHub Actions - automatically write out the rspec logs to be parsed later.
formatter += " --format json --out rspec_logs.json" if ENV["GITHUB_ACTIONS"]
command = "rspec --pattern spec/**/*_spec.rb,*/spec/**/*_spec.rb #{formatter} #{ENV['RSPEC_ARGS']}"
sh(command)
end
# run, displays and saves the list of tests that do not work standalone
task(:test_all_individually) do
files = Dir.glob("./**/*_spec.rb")
failed = files.select do |file|
formatter = "--format progress"
command = "rspec #{formatter} #{ENV['RSPEC_ARGS']} #{file}"
sh(command)
false
rescue => _
true
end
unless failed.empty?
puts("Individual tests failing: #{failed.join(' ')}")
file = "failed_tests"
File.write(file, failed.join("\n"))
raise "Some tests are failing when ran on their own. See #{file}"
end
end
task(:generate_team_table) do
require_relative 'fastlane/lib/fastlane/documentation/markdown_docs_generator'
readme = File.read("README.md")
readme.sub!(/(?<=<!-- team:start -->\n).*(?=<!-- team:end -->)/m) { Fastlane::MarkdownDocsGenerator.render_team("internal/team.json") }
File.write("README.md", readme)
puts("All done")
end
task(:update_gem_spec_authors) do
require 'json'
contributors = JSON.parse(File.read("internal/team.json"))
names = contributors.values.collect do |current|
current["name"]
end.shuffle
gemspec = File.read("fastlane.gemspec")
names = names.join("\",\n \"")
gemspec.gsub!(/spec.authors\s+\=\s.*?\]/m, "spec.authors = [\"#{names}\"]")
File.write("fastlane.gemspec", gemspec)
end
task(default: :test_all)
# Prepare the plugin template RuboCop config before building/installing the gem
desc "Prepare .rubocop.yml for plugin template"
task(:prepare_rubocop_config) do
require 'yaml'
require 'fileutils'
lib = File.expand_path('fastlane/lib', __dir__)
rubocop_config = File.expand_path('.rubocop.yml', __dir__)
next unless File.exist?(rubocop_config)
require_relative 'internal/plugin_template_rubocop_config'
config = Fastlane::Internal::PluginTemplateRubocopConfig.from(YAML.safe_load(File.read(rubocop_config), aliases: true))
target = File.join(lib, 'fastlane/plugins/template/.rubocop.yml')
FileUtils.mkdir_p(File.dirname(target))
File.write(target, YAML.dump(config))
end
# test_all and test_parallel as well as the packaging tasks. The template's
# .rubocop.yml is generated and gitignored, so a working copy can be left
# holding one from an older fastlane, and plugin_generator_spec then generates a
# plugin whose gemspec and rubocop config disagree about the Ruby version. That
# surfaces as `expected 0, got 1` with the rubocop output thrown away, which is
# a poor thing to debug: it looks like an environment problem and is a stale
# file. Regenerating first is cheap and makes the run say the same thing on any
# machine. See fastlane#30184.
%w(build install release test_all test_parallel).each do |t|
Rake::Task[t].enhance([:prepare_rubocop_config]) if Rake::Task.task_defined?(t)
end