-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRakefile
90 lines (82 loc) · 2.97 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
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rubocop/rake_task'
task default: %i[rubocop test git:submodule:test]
Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb']
end
RuboCop::RakeTask.new do |task|
task.formatters = ['progress']
task.formatters << 'github' if ENV.key?('GITHUB_ACTIONS')
end
namespace :git do
namespace :submodule do
desc 'Init git submodule'
task :init do |_, args|
sh(*%w[git submodule init], *args.extras)
end
desc 'Update git submodule'
task update: :init do |_, args|
sh(*%w[git submodule update --force], *args.extras)
end
desc 'Deinit git submodule'
task :deinit do |_, args|
sh(*%w[git submodule deinit --force], *args.extras)
end
desc 'Test git submodule'
task :test do |_, args|
submodules = if args.extras.empty?
%w[
vendor/github.com/rails/sprockets
vendor/github.com/sass/sassc-rails
vendor/github.com/twbs/bootstrap-rubygem
]
else
args.extras
end
Rake::Task['git:submodule:update'].invoke(*submodules)
submodules.each do |submodule|
patch = File.absolute_path("test/patches/#{File.basename(submodule)}.diff", __dir__)
sh(*%w[git apply], patch, chdir: submodule) if File.exist?(patch)
case submodule
when 'vendor/github.com/rails/sprockets'
Bundler.with_original_env do
sh(*%w[bundle install], chdir: submodule)
sh(*%w[bundle exec rake test TEST=test/test_sassc.rb], chdir: submodule)
end
when 'vendor/github.com/sass/sassc-rails'
Bundler.with_original_env do
gemfiles = %w[
Gemfile
gemfiles/rails_6_0.gemfile
gemfiles/sprockets_4_0.gemfile
gemfiles/sprockets-rails_3_0.gemfile
]
gemfiles.each do |gemfile|
env = { 'BUNDLE_GEMFILE' => gemfile, 'MT_COMPAT' => 'true', 'RUBYOPT' => '-rlogger' }
sh(env, *%w[bundle install], chdir: submodule)
sh(env, *%w[bundle exec rake test], chdir: submodule)
end
end
when 'vendor/github.com/twbs/bootstrap-rubygem'
Bundler.with_original_env do
gemfiles = %w[
test/gemfiles/rails_6_0.gemfile
test/gemfiles/rails_6_1.gemfile
test/gemfiles/rails_7_0_sassc.gemfile
test/gemfiles/rails_7_0_dartsass.gemfile
]
gemfiles.each do |gemfile|
env = { 'BUNDLE_GEMFILE' => gemfile, 'RUBYOPT' => '-rlogger' }
sh(env, *%w[bundle install], chdir: submodule)
sh(env, *%w[bundle exec rake], chdir: submodule)
end
end
end
end
Rake::Task['git:submodule:deinit'].invoke(*submodules)
end
end
end