-
Notifications
You must be signed in to change notification settings - Fork 63
/
Rakefile
127 lines (106 loc) · 3.5 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
116
117
118
119
120
121
122
123
124
125
126
127
# encoding: utf-8
require 'rubygems'
require 'bundler'
require 'colorize'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'juwelier'
Juwelier::Tasks.new do |gem|
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
gem.name = "hiptest-publisher"
gem.homepage = "https://cucumber.io"
gem.license = "MIT"
gem.summary = "Export your tests from CucumberStudio into executable tests."
gem.description = "Provides a command-line tool that generates Java, Python or Ruby code to run the tests."
gem.email = "[email protected]"
gem.authors = ["CucumberStudio R&D"]
gem.executables = ['hiptest-publisher']
gem.files = `git ls-files -- lib/* config/*`.split("\n")
gem.require_path = "lib"
gem.required_ruby_version = '>= 2.7'
end
Juwelier::RubygemsDotOrgTasks.new
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end
desc "Code coverage detail"
task :simplecov do
ENV['COVERAGE'] = "true"
Rake::Task['test'].execute
end
task default: :test
task :do_release do
version = File.open('VERSION').read
if File.readlines("CHANGELOG.md").grep(/Nothing changed yet/).size > 0
header = "Changelog has not been updated since last release.".red
commits = `git log $(git describe --tags --abbrev=0)..HEAD --oneline`
abort("#{header}\nHere are the commit messages to help you fill that:\n\n#{commits}")
end
Rake::Task["prerelease_changelog_update"].invoke
`git commit CHANGELOG.md -m "Update changelog before release #{version}"`
Rake::Task["release"].invoke
Rake::Task["postrelease_changelog_update"].invoke
`git commit CHANGELOG.md -m "Update changelog after release #{version}"`
`git push`
end
task :prerelease_changelog_update do
version = File.open('VERSION').read
header_line = -2
new_changelog = ""
File.readlines('CHANGELOG.md').each_with_index do |line, index|
if line == "[Unreleased]\n"
new_changelog << "[#{version}]\n"
header_line = index
elsif line.start_with?('[Unreleased]')
new_changelog << line
.gsub('Unreleased', version)
.gsub('master', "v#{version}")
.gsub(' ', ' ')
elsif index == header_line + 1
new_changelog << ("-" * (version.length + 2)) + "\n"
else
new_changelog << line
end
end
File.write('CHANGELOG.md', new_changelog)
end
task :postrelease_changelog_update do
version = File.open('VERSION').read
new_changelog = ""
changes_header = -2
File.readlines('CHANGELOG.md').each_with_index do |line, index|
if line == "[#{version}]\n"
new_changelog << [
'[Unreleased]',
'------------',
'',
' - Nothing changed yet',
'',
''
].join("\n")
elsif line =="<!-- List of releases -->\n"
changes_header = index
elsif index == changes_header + 1
new_changelog << "[Unreleased]: https://github.com/hiptest/hiptest-publisher/compare/v#{version}...master\n"
end
new_changelog << line
end
File.write('CHANGELOG.md', new_changelog)
end
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "hiptest-publisher #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end