-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
115 lines (93 loc) · 3.28 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# frozen_string_literal: true
require 'bump/tasks'
require 'bundler/gem_helper'
require 'active_support/inflector'
require_relative 'wcc-contentful/lib/wcc/contentful/version'
version = WCC::Contentful::VERSION
GEMS = [
'wcc-contentful',
'wcc-contentful-app'
].freeze
GEMS.each do |name|
namespace name do
Dir.chdir(name) do
Bundler::GemHelper.install_tasks
end
end
end
def sync_versions
current = Bump::Bump.current
GEMS.each do |gem|
Dir.chdir(gem) do
Bump::Bump.run('set', version: current, commit: false, bundle: false, tag: false)
end
end
end
task :check do
doc_version = Gem::Version.new(version).release.to_s.sub(/\.\d+$/, "")
unless File.exist?("docs/latest") && File.readlink("docs/latest") == "./#{doc_version}"
raise "docs/latest does not point to ./#{doc_version}. Please run 'bin/doc'."
end
GEMS.each do |gem|
version_file = "#{gem}/lib/#{gem.gsub('-', '/')}/version"
require_relative version_file
version_const = to_const(gem).const_get('VERSION')
unless version_const == version
raise "Versions are not synchronized! Please update #{version_file}.rb"
end
doc_folder = "docs/#{doc_version}/#{gem}"
unless File.exist?(doc_folder)
raise "Documentation does not exist in '#{doc_folder}'. please run 'bin/doc'"
end
end
end
# After each version bump task, sync the versions of the gems
namespace :bump do
Bump::Bump::BUMPS.each do |bump|
task bump do
sync_versions
system('find . -type f -name version.rb | xargs git add')
system("git commit -m 'Release v#{Bump::Bump.current}'")
end
end
end
desc "Create tag and build and push all gems\n" \
'To prevent publishing in RubyGems use `gem_push=no rake release`'
task release: [:check].concat(GEMS.map { |g| "#{g}:release" })
desc "Build #{GEMS.join(',')} into the pkg directory."
task build: GEMS.map { |g| "#{g}:build" }
task install: GEMS.map { |g| "#{g}:install" }
task 'install:local' => GEMS.map { |g| "#{g}:install:local" }
def to_const(gem)
gem.split('-').map(&:titleize).join('::').gsub('Wcc', 'WCC').constantize
end
namespace :coverage do
task :aggregate do
require 'simplecov'
# https://github.com/colszowka/simplecov/issues/219#issuecomment-377991535
results =
GEMS.map { |g| "#{g}/coverage/.resultset.json" }.map do |result_file_name|
puts "Processing #{result_file_name}"
SimpleCov::Result.from_hash(JSON.parse(File.read(result_file_name)))
end
merged_result = SimpleCov::ResultMerger.merge_results(*results)
FileUtils.mkdir_p('./coverage')
File.write('./coverage/.resultset.json', JSON.pretty_generate(merged_result.to_hash))
end
task html: 'coverage:aggregate' do
require 'simplecov'
result = SimpleCov::Result.from_hash(JSON.parse(File.read('./coverage/.resultset.json')))
formatter = SimpleCov::Formatter::HTMLFormatter.new
formatter.format(result)
system('open ./coverage/index.html')
end
task coveralls: 'coverage:aggregate' do
require 'simplecov'
require 'coveralls'
result = SimpleCov::Result.from_hash(JSON.parse(File.read('./coverage/.resultset.json')))
formatter = Coveralls::SimpleCov::Formatter.new
formatter.format(result)
end
end
task coverage: [*GEMS.map { |g| "#{g}:coverage" }, 'coverage:aggregate'] do
end