-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRakefile
More file actions
131 lines (109 loc) · 3.17 KB
/
Rakefile
File metadata and controls
131 lines (109 loc) · 3.17 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
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
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rails'
require "action_view/railtie"
require 'workarea/core'
require 'rake/testtask'
require 'date'
load 'rails/test_unit/testing.rake'
load 'workarea/changelog.rake'
load Workarea::Core::Engine.root.join('lib', 'tasks', 'services.rake')
GEMS = %w(admin storefront).freeze
ROOT_DIR = Dir.pwd
GEMS.each do |gem|
Rake::TestTask.new("#{gem}_test") do |t|
t.libs << "#{gem}/test"
t.pattern = "#{gem}/test/**/*_test.rb"
t.verbose = false
t.warning = false
end
task "#{gem}_test_ci" do
ENV['CI'] = 'true'
ENV['JUNIT_PATH'] = "#{gem}/test/reports"
$: << "#{gem}/test"
Rails::TestUnit::Runner.rake_run(["#{gem}/test/**/*_test.rb"])
end
end
Rake::Task['test'].clear
desc 'Run tests for all gems'
task :test do
require 'rails/test_unit/reporter'
$: << 'admin/test'
$: << 'storefront/test'
Rails::TestUnitReporter.executable = 'bin/rails test'
# Override this to print a command that we rerun the test on failure
Rails::TestUnitReporter.class_eval do
def format_rerun_snippet(result)
location, line = result.method(result.name).source_location
rel_path = relative_path_for(location)
GEMS.each do |gem|
if rel_path.include?(gem)
return "cd #{gem} && bin/rails test #{rel_path}:#{line}"
end
end
"#{executable} #{rel_path}:#{line}"
end
end
Rails::TestUnit::Runner.rake_run(GEMS.map { |g| "#{g}/test" })
end
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'workarea/api/version'
desc "Release version #{Workarea::Api::VERSION} of the gem"
task :release do
host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
#
# Build documentation
#
#
system <<~COMMAND
(cd admin && GENERATE_API_DOCS=true bin/rails test) &&
(cd storefront && GENERATE_API_DOCS=true bin/rails test) &&
git add doc/ &&
git commit -am "Update documentation" &&
git push origin HEAD
COMMAND
#
# Updating changelog
#
#
Rake::Task['workarea:changelog'].execute
system 'git add CHANGELOG.md'
system 'git commit -m "Update CHANGELOG"'
#
# Build gem files
#
#
GEMS.each do |gem|
Dir.chdir("#{ROOT_DIR}/#{gem}")
system "gem build workarea-api-#{gem}.gemspec"
end
Dir.chdir(ROOT_DIR)
system 'gem build workarea-api.gemspec'
#
# Push gem files
#
#
puts 'Pushing gems...'
GEMS.each do |gem|
system "gem push #{gem}/workarea-api-#{gem}-#{Workarea::Api::VERSION}.gem"
system "gem push #{gem}/workarea-api-#{gem}-#{Workarea::Api::VERSION}.gem --host #{host}"
end
system "gem push workarea-api-#{Workarea::Api::VERSION}.gem"
system "gem push workarea-api-#{Workarea::Api::VERSION}.gem --host #{host}"
system 'Tagging git...'
system "git tag -a v#{Workarea::Api::VERSION} -m 'Tagging #{Workarea::Api::VERSION}'"
system 'git push origin HEAD --follow-tags'
#
# Clean up
#
#
puts 'Cleaning up...'
GEMS.each do |gem|
system "rm #{gem}/workarea-api-#{gem}-#{Workarea::Api::VERSION}.gem"
end
system "rm workarea-api-#{Workarea::Api::VERSION}.gem"
end