forked from fastlane/fastlane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
117 lines (96 loc) · 3.75 KB
/
Rakefile
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
require "bundler/gem_tasks"
GEMS = %w(fastlane danger-device_grid)
SECONDS_PER_DAY = 60 * 60 * 24
task(:rubygems_admins) do
names = ["KrauseFx", "joshdholtz", "snatchev", "powerivq"]
(GEMS + ["krausefx-shenzhen", "commander-fastlane", "fastlane-plugin-firebase_test_lab"]).each do |gem_name|
names.each do |name|
puts(`gem owner #{gem_name} -a #{name}`)
end
end
end
task(:test_all) do
formatter = "--format progress"
formatter += " -r rspec_junit_formatter --format RspecJunitFormatter -o #{ENV['CIRCLE_TEST_REPORTS']}/rspec/fastlane-junit-results.xml" if ENV["CIRCLE_TEST_REPORTS"]
command = "rspec --pattern ./**/*_spec.rb #{formatter} #{ENV['RSPEC_ARGS']}"
run_rspec(command)
end
def run_rspec(command)
# To move Ruby 3.0 or next major version migration going forward, we want to keep monitoring deprecation warnings
if Gem.win_platform?
# Windows would not work with /bin/bash so skip collecting warnings
sh(command)
else
# Mix stderr into stdout to let handle `tee` it and then collect warnings by filtering stdout out
command += " 2>&1 | tee >(grep 'warning:' > #{File.join(ENV['CIRCLE_TEST_REPORTS'], 'ruby_warnings.txt')})" if ENV["CIRCLE_TEST_REPORTS"]
# tee >(...) occurs syntax error with `sh` helper which uses /bin/sh by default.
sh("/bin/bash -o pipefail -c \"#{command}\"")
end
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}"
run_rspec(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
# Overwrite the default rake task
# since we use fastlane to deploy fastlane
task(:push) do
sh("bundle exec fastlane release")
end
task(:generate_team_table) do
require 'json'
content = ["<table id='team'>"]
contributors = JSON.parse(File.read("team.json"))
counter = 0
number_of_rows = 5
contributors.keys.shuffle.each do |github_user|
user_content = contributors[github_user]
github_user_name = user_content['name']
github_user_id = github_user_name.downcase.gsub(' ', '-')
github_profile_url = "https://github.com/#{github_user}"
content << "<tr>" if counter % number_of_rows == 0
content << "<td id='#{github_user_id}'>"
content << "<a href='#{github_profile_url}'>"
content << "<img src='#{github_profile_url}.png' width='140px;'>"
content << "</a>"
if user_content['twitter']
content << "<h4 align='center'><a href='https://twitter.com/#{user_content['twitter']}'>#{github_user_name}</a></h4>"
else
content << "<h4 align='center'>#{github_user_name}</h4>"
end
# content << "<p align='center'>#{user_content['slogan']}</p>" if user_content['slogan'].to_s.length > 0
content << "</td>"
content << "</tr>" if counter % number_of_rows == number_of_rows - 1
counter += 1
end
content << "</table>"
readme = File.read("README.md")
readme.gsub!(%r{\<table id='team'\>.*\<\/table\>}m, content.join("\n"))
File.write("README.md", readme)
puts("All done")
end
task(:update_gem_spec_authors) do
require 'json'
contributors = JSON.parse(File.read("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)