-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5575 from solidusio/elia/rakefile
Split the main Rakefile into themed sub-files
- Loading branch information
Showing
10 changed files
with
113 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ yarn.lock | |
package-lock.json | ||
.env | ||
/admin/app/assets/builds | ||
/test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bundler' | ||
require 'bundler/gem_tasks' | ||
|
||
task default: :spec | ||
|
||
def print_title(gem_name = '') | ||
title = ["Solidus", gem_name].join(' ').strip | ||
puts "\n#{'-' * title.size}\n#{title}\n#{'-' * title.size}" | ||
end | ||
|
||
def subproject_task(project, task, title: project, task_name: nil) | ||
task_name ||= "#{task}:#{project}" | ||
task task_name do | ||
print_title(title) | ||
Dir.chdir("#{File.dirname(__FILE__)}/#{project}") do | ||
sh "rake #{task}" | ||
end | ||
end | ||
end | ||
|
||
%w[spec db:drop db:create db:migrate db:reset].each do |task| | ||
%w(api backend core frontend sample).each do |project| | ||
desc "Run specs for #{project}" if task == 'spec' | ||
subproject_task(project, task) | ||
end | ||
|
||
desc "Run rake #{task} for each Solidus engine" | ||
task task => %w(api backend core frontend sample).map { |p| "#{task}:#{p}" } | ||
end | ||
|
||
desc "Run backend JS specs" | ||
subproject_task("backend", "spec:js", title: "backend JS", task_name: "spec:backend:js") | ||
|
||
# Add backend JS specs to `rake spec` dependencies | ||
task spec: 'spec:backend:js' | ||
|
||
task test: :spec | ||
task test_app: 'db:reset' | ||
|
||
desc "clean the whole repository by removing all the generated files" | ||
task :clean do | ||
rm_f "Gemfile.lock" | ||
rm_rf "sandbox" | ||
rm_rf "pkg" | ||
|
||
%w(api backend core frontend sample).each do |gem_name| | ||
print_title(gem_name) | ||
rm_f "#{gem_name}/Gemfile.lock" | ||
rm_rf "#{gem_name}/pkg" | ||
rm_rf "#{gem_name}/spec/dummy" | ||
end | ||
end | ||
|
||
SOLIDUS_GEM_NAMES = %w[core api backend sample] | ||
|
||
%w[build install].each do |task_name| | ||
desc "Run rake #{task} for each Solidus gem" | ||
task task_name do | ||
SOLIDUS_GEM_NAMES.each do |gem_name| | ||
cd(gem_name) { sh "rake #{task_name}" } | ||
end | ||
end | ||
end | ||
|
||
# We need to redefine release task to skip creating and pushing git tag | ||
Rake::Task["release"].clear | ||
desc "Build and push solidus gems to RubyGems" | ||
task "release" => ["build", "release:guard_clean", "release:rubygem_push"] do | ||
SOLIDUS_GEM_NAMES.each do |gem_name| | ||
cd(gem_name) { sh "rake release:rubygem_push" } | ||
end | ||
end | ||
|
||
namespace :solidus do | ||
desc "Report code coverage results for all solidus gems" | ||
task :coverage, [:formatter] do |task, args| | ||
require "simplecov" | ||
SimpleCov.merge_timeout 3600 | ||
if ENV["COVERAGE_DIR"] | ||
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"]) | ||
end | ||
if args[:formatter] == "cobertura" | ||
require "simplecov-cobertura" | ||
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter | ||
end | ||
SimpleCov.result.format! | ||
end | ||
end | ||
import 'tasks/cleaning.rake' | ||
import 'tasks/releasing.rake' | ||
import 'tasks/testing.rake' | ||
import 'tasks/linting.rake' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rake/clean' | ||
|
||
CLOBBER.include "sandbox" | ||
CLOBBER.include "Gemfile.lock" | ||
CLOBBER.include "{*/,}pkg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :lint do | ||
task :rb do | ||
ci_options = "-f junit -o '#{__dir__}/../test-results/rubocop-results.xml' " if ENV['CI'] | ||
|
||
sh %{bundle exec rubocop -P -f q #{ci_options}$(git ls-files -co --exclude-standard | grep -E "\\.rb$" | grep -v "/templates/")} | ||
end | ||
|
||
task :erb do | ||
sh 'bundle exec erb-format $(git ls-files -co --exclude-standard | grep -E "\.html.erb$") > /dev/null' | ||
end | ||
|
||
task :js do | ||
sh 'npx -y eslint $(git ls-files -co --exclude-standard | grep -E "\.js$" | grep -vE "/(vendor|config|spec)/")' | ||
end | ||
end | ||
|
||
task lint: %w[lint:rb lint:erb lint:js] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/gem_tasks' | ||
|
||
SOLIDUS_GEM_NAMES = %w[core api backend sample] | ||
|
||
%w[build install].each do |task_name| | ||
desc "Run rake #{task} for each Solidus gem" | ||
task task_name do | ||
SOLIDUS_GEM_NAMES.each do |gem_name| | ||
cd(gem_name) { sh "rake #{task_name}" } | ||
end | ||
end | ||
end | ||
|
||
# We need to redefine release task to skip creating and pushing git tag | ||
Rake::Task["release"].clear | ||
desc "Build and push solidus gems to RubyGems" | ||
task "release" => ["build", "release:guard_clean", "release:rubygem_push"] do | ||
SOLIDUS_GEM_NAMES.each do |gem_name| | ||
cd(gem_name) { sh "rake release:rubygem_push" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
task default: :spec | ||
|
||
def print_title(gem_name = '') | ||
title = ["Solidus", gem_name].join(' ').strip | ||
puts "\n#{'-' * title.size}\n#{title}\n#{'-' * title.size}" | ||
end | ||
|
||
def subproject_task(project, task, title: project, task_name: nil) | ||
task_name ||= "#{task}:#{project}" | ||
task task_name do | ||
print_title(title) | ||
Dir.chdir("#{File.dirname(__FILE__)}/#{project}") do | ||
sh "rake #{task}" | ||
end | ||
end | ||
end | ||
|
||
%w[spec db:drop db:create db:migrate db:reset].each do |task| | ||
%w(api backend core frontend sample).each do |project| | ||
desc "Run specs for #{project}" if task == 'spec' | ||
subproject_task(project, task) | ||
end | ||
|
||
desc "Run rake #{task} for each Solidus engine" | ||
task task => %w(api backend core frontend sample).map { |p| "#{task}:#{p}" } | ||
end | ||
|
||
desc "Run backend JS specs" | ||
subproject_task("backend", "spec:js", title: "backend JS", task_name: "spec:backend:js") | ||
|
||
# Add backend JS specs to `rake spec` dependencies | ||
task spec: 'spec:backend:js' | ||
|
||
task test: :spec | ||
task test_app: 'db:reset' | ||
|
||
namespace :solidus do | ||
desc "Report code coverage results for all solidus gems" | ||
task :coverage, [:formatter] do |_task, args| | ||
require "simplecov" | ||
SimpleCov.merge_timeout 3600 | ||
if ENV["COVERAGE_DIR"] | ||
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"]) | ||
end | ||
if args[:formatter] == "cobertura" | ||
require "simplecov-cobertura" | ||
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter | ||
end | ||
SimpleCov.result.format! | ||
end | ||
end |