-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
93 lines (79 loc) · 1.76 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
# Checks if executable exists in current path
def command?(command)
system("command -v #{command} > /dev/null 2>&1")
end
# Default target, if no is provided
task default: [:setup]
# Steps for project environment setup
task :setup => [
:pre_setup,
:check_for_homebrew,
:update_homebrew,
:check_for_swiftlint,
:install_bundler_gem,
:install_ruby_gems,
:install_carthage,
:install_carthage_dependencies
]
# Combines project setup with unit tests
task :setup_with_unit_test => [
:setup,
:unit_test
]
# Pre-setup steps
task :pre_setup do
puts "macOS project setup ..."
end
# Check if Homebrew is available
task :check_for_homebrew do
puts "Checking Homebrew ..."
if not command?('brew')
STDERR.puts "Homebrew not found, please install it:"
STDERR.puts "https://brew.sh/"
exit
end
end
# Update Homebrew
task :update_homebrew do
puts "Updating Homebrew ..."
sh "brew update"
end
# Check if SwiftLint is available
task :check_for_swiftlint do
puts "Checking SwiftLint ..."
if not command?('swiftlint')
STDERR.puts "SwiftLint not found. Installing now..."
sh "brew install swiftlint"
exit
end
end
# Install Bundler Gem
task :install_bundler_gem do
if not command?('bundle')
sh "gem install bundler -v '~> 1.16'"
else
sh "gem update bundler '~> 1.16'"
end
end
# Install Ruby Gems
task :install_ruby_gems do
sh "bundle install"
end
# Install Carthage
task :install_carthage do
sh "brew unlink carthage || true"
sh "brew install carthage"
sh "brew link --overwrite carthage"
end
# Install Carthage dependencies
task :install_carthage_dependencies do
sh "carthage update --no-use-binaries --platform osx --cache-builds"
end
# Run SwiftLint
task :lint do
sh 'swiftlint'
end
# Run fastlane unit tests
task :unit_test do
sh "fastlane test"
end