-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring of Rakefile now split in different task files
- Loading branch information
Showing
5 changed files
with
90 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/setup' | ||
require 'bundler/gem_tasks' | ||
require 'rake/testtask' | ||
require 'rubocop/rake_task' | ||
require 'json' | ||
|
||
RuboCop::RakeTask.new(:rubocop) | ||
|
||
unless ENV['CI'] | ||
require 'rake/manifest' | ||
Rake::Manifest::Task.new do |t| | ||
t.patterns = FileList.new.include('lib/**/*', 'LICENSE.txt').exclude('**/*.md') | ||
t.manifest_file = 'pagy.manifest' | ||
end | ||
|
||
desc 'Build the gem, checking the manifest first' | ||
task build: 'manifest:check' | ||
end | ||
|
||
# Separate tasks for each test that must run a process | ||
# in isolation in order to avoid affecting also other tests. | ||
test_tasks = {} | ||
|
||
%w[ headers | ||
i18n | ||
overflow | ||
support | ||
oj_shared | ||
shared | ||
trim | ||
items_trim | ||
items_countless | ||
items_elasticsearch | ||
elasticsearch_rails | ||
searchkick | ||
].each do |name| | ||
task_name = :"test_#{name}" | ||
file_path = "test/**/#{name}_test.rb" | ||
test_tasks[task_name] = file_path | ||
Rake::TestTask.new(task_name) do |t| | ||
test_files = FileList.new file_path | ||
t.test_files = test_files | ||
t.description = "Run tests in #{test_files.join(', ')}" | ||
end | ||
end | ||
|
||
# Collect the other tests | ||
Rake::TestTask.new(:test_others) do |t| | ||
test_files = FileList.new.include('test/**/*_test.rb').exclude(*test_tasks.values) | ||
t.test_files = test_files | ||
t.description = "Run tests in #{test_files.join(', ')}" | ||
end | ||
|
||
desc 'Display SimpleCov coverage summary' | ||
task :coverage_summary do | ||
last_run = JSON.load_file('coverage/.last_run.json') | ||
result = last_run['result']['line'] | ||
puts "\n>>> SimpleCov Coverage: #{result}% <<<" | ||
if result < 100.0 | ||
Warning.warn "!!!!! Missing #{(100.0 - result).round(2)}% coverage !!!!!" | ||
puts "\n(run it again with COVERAGE_REPORT=true for a line-by-line HTML report @ coverage/index.html)" unless ENV['COVERAGE_REPORT'] | ||
end | ||
end | ||
|
||
# get the full list of of all the test tasks (and test files that each task run) with: | ||
# rake -D test_* | ||
desc "Run all the test tasks: #{test_tasks.keys.join(', ')}" | ||
task test: [*test_tasks.keys, :test_others] | ||
Rake.add_rakelib 'tasks' | ||
|
||
task default: %i[test rubocop coverage_summary] |
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'json' | ||
|
||
desc 'Display SimpleCov coverage summary' | ||
task :coverage_summary do | ||
last_run = JSON.load_file('coverage/.last_run.json') | ||
result = last_run['result']['line'] | ||
puts "\n>>> SimpleCov Coverage: #{result}% <<<" | ||
if result < 100.0 | ||
Warning.warn "!!!!! Missing #{(100.0 - result).round(2)}% coverage !!!!!" | ||
puts "\n(run it again with COVERAGE_REPORT=true for a line-by-line HTML report @ coverage/index.html)" unless ENV['COVERAGE_REPORT'] | ||
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,27 @@ | ||
# frozen_string_literal: true | ||
|
||
return if ENV['CI'] | ||
|
||
# gem build and release tasks, with added checks and patches | ||
|
||
require 'bundler/gem_tasks' | ||
require 'rake/manifest' | ||
|
||
Rake::Manifest::Task.new do |t| | ||
t.patterns = FileList.new.include('lib/**/*', 'LICENSE.txt').exclude('**/*.md') | ||
t.manifest_file = 'pagy.manifest' | ||
end | ||
|
||
desc 'Build the gem, checking the manifest first' | ||
task build: 'manifest:check' | ||
|
||
module Bundler | ||
class GemHelper | ||
def version_tag | ||
"#{@tag_prefix}#{version}" # remove that stupid 'v' prepended to the version number | ||
end | ||
end | ||
end | ||
|
||
desc 'Release the gem, checking the manifest first' | ||
task release: 'manifest:check' |
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rubocop/rake_task' | ||
|
||
RuboCop::RakeTask.new(:rubocop) |
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,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rake/testtask' | ||
|
||
# Separate tasks for each test that must run a process | ||
# in isolation in order to avoid affecting also other tests. | ||
test_tasks = {} | ||
|
||
%w[ headers | ||
i18n | ||
overflow | ||
support | ||
oj_shared | ||
shared | ||
trim | ||
items_trim | ||
items_countless | ||
items_elasticsearch | ||
elasticsearch_rails | ||
searchkick | ||
].each do |name| | ||
task_name = :"test_#{name}" | ||
file_path = "test/**/#{name}_test.rb" | ||
test_tasks[task_name] = file_path | ||
Rake::TestTask.new(task_name) do |t| | ||
test_files = FileList.new file_path | ||
t.test_files = test_files | ||
t.description = "Run tests in #{test_files.join(', ')}" | ||
end | ||
end | ||
|
||
# Collect the other tests | ||
Rake::TestTask.new(:test_others) do |t| | ||
test_files = FileList.new.include('test/**/*_test.rb').exclude(*test_tasks.values) | ||
t.test_files = test_files | ||
t.description = "Run tests in #{test_files.join(', ')}" | ||
end | ||
|
||
desc "Run all the test tasks: #{test_tasks.keys.join(', ')}" | ||
task test: [*test_tasks.keys, :test_others] | ||
|
||
# get the full list of of all the test tasks (and test files that each task run) with: | ||
# rake -D test_* |