This repository has been archived by the owner on Jun 6, 2020. It is now read-only.
forked from alphagov/govuk_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
204 lines (177 loc) · 7.06 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
$:.unshift File.expand_path('../lib', __FILE__)
$:.unshift File.expand_path('../build_tools', __FILE__)
require "govuk_template/version"
require "gem_publisher"
desc "Compile template and assets from ./source into ./app"
task :compile do
require 'compiler/asset_compiler'
puts "Compiling assets and templates into ./app"
Compiler::AssetCompiler.compile
end
desc "Build both gem and tar version"
task :build => ["build:gem",
"build:tar",
"build:play",
"build:mustache",
"build:liquid",
"build:mustache_inheritance",
"build:jinja",
"build:ejs",
"build:webjar",
"build:django"]
namespace :build do
desc "Build govuk_template-#{GovukTemplate::VERSION}.gem into the pkg directory"
task :gem => :compile do
puts "Building pkg/govuk_template-#{GovukTemplate::VERSION}.gem"
require 'packager/gem_packager'
Packager::GemPackager.build
end
desc "Build govuk_template-#{GovukTemplate::VERSION}.tgz into the pkg directory"
task :tar => :compile do
puts "Building pkg/govuk_template-#{GovukTemplate::VERSION}.tgz"
require 'packager/tar_packager'
Packager::TarPackager.build
end
desc "Build play_govuk_template-#{GovukTemplate::VERSION}.tgz into the pkg directory"
task :play => :compile do
puts "Building pkg/play_govuk_template-#{GovukTemplate::VERSION}.tgz"
require 'packager/play_packager'
Packager::PlayPackager.build
end
desc "Build mustache_govuk_template-#{GovukTemplate::VERSION} into the pkg directory"
task :mustache => :compile do
puts "Building pkg/mustache_govuk_template-#{GovukTemplate::VERSION}"
require 'packager/mustache_packager'
Packager::MustachePackager.build
end
desc "Build liquid_govuk_template-#{GovukTemplate::VERSION} into the pkg directory"
task :liquid => :compile do
puts "Building pkg/liquid_govuk_template-#{GovukTemplate::VERSION}"
require 'packager/liquid_packager'
Packager::LiquidPackager.build
end
desc "Build mustache_inheritance_govuk_template-#{GovukTemplate::VERSION} into the pkg directory"
task :mustache_inheritance => :compile do
puts "Building pkg/mustache_inheritance_govuk_template-#{GovukTemplate::VERSION}"
require 'packager/mustache_inheritance_packager'
Packager::MustacheInheritancePackager.build
end
desc "Build jinja_govuk_template-#{GovukTemplate::VERSION} into the pkg directory"
task :jinja => :compile do
puts "Building pkg/jinja_govuk_template-#{GovukTemplate::VERSION}"
require 'packager/jinja_packager'
Packager::JinjaPackager.build
end
desc "Build django_govuk_template-#{GovukTemplate::VERSION} into the pkg directory"
task :django => :compile do
puts "Building pkg/django_govuk_template-#{GovukTemplate::VERSION}"
require 'packager/django_packager'
Packager::DjangoPackager.build
end
desc "Build ejs_govuk_template-#{GovukTemplate::VERSION} into the pkg directory"
task :ejs => :compile do
puts "Building pkg/ejs_govuk_template-#{GovukTemplate::VERSION}"
require 'packager/ejs_packager'
Packager::EJSPackager.build
end
desc "Build govuk_template-#{GovukTemplate::VERSION}.jar into the pkg directory"
task :webjar => :compile do
puts "Building pkg/govuk_template-#{GovukTemplate::VERSION}.jar"
require 'packager/webjar_packager'
Packager::WebJarPackager.build
end
desc "Build and release gem if version has been updated"
task :and_release_if_updated => :build do
p = GemPublisher::Publisher.new('govuk_template.gemspec')
if p.version_released?
puts "govuk_template-#{GovukTemplate::VERSION} already released. Not pushing."
else
puts "Pushing govuk_template-#{GovukTemplate::VERSION}"
p.pusher.push "pkg/govuk_template-#{GovukTemplate::VERSION}.gem", :rubygems
p.git_remote.add_tag "v#{GovukTemplate::VERSION}"
puts "Done."
require 'publisher/docs_publisher'
q = Publisher::DocsPublisher.new
puts "Pushing docs #{GovukTemplate::VERSION} to git repo"
q.publish
puts "Done."
end
require 'publisher/release_publisher'
q = Publisher::ReleasePublisher.new
if q.version_released?
puts "Github release v#{GovukTemplate::VERSION} already released. Not pushing."
else
puts "Pushing Github release v#{GovukTemplate::VERSION}"
q.publish
end
require 'publisher/play_publisher'
q = Publisher::PlayPublisher.new
if q.version_released?
puts "govuk_template_play #{GovukTemplate::VERSION} already released. Not pushing."
else
puts "Pushing govuk_template_play #{GovukTemplate::VERSION} to git repo"
q.publish
end
require 'publisher/mustache_publisher'
q = Publisher::MustachePublisher.new
if q.version_released?
puts "govuk_template_mustache #{GovukTemplate::VERSION} already released. Not pushing."
else
puts "Pushing govuk_template_mustache #{GovukTemplate::VERSION} to git repo"
q.publish
end
require 'publisher/ejs_publisher'
q = Publisher::EJSPublisher.new
if q.version_released?
puts "govuk_template_ejs #{GovukTemplate::VERSION} already released. Not pushing."
else
puts "Pushing govuk_template_ejs #{GovukTemplate::VERSION} to git repo"
q.publish
end
require 'publisher/jinja_publisher'
q = Publisher::JinjaPublisher.new
if q.version_released?
puts "govuk_template_jinja #{GovukTemplate::VERSION} already released. Not pushing."
else
puts "Pushing govuk_template_jinja #{GovukTemplate::VERSION} to git repo"
q.publish
end
end
end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
desc "Run integration tests against all languages/frameworks with an integration testing app"
task :integration_tests => ["integration_tests:test_html"]
namespace :integration_tests do
desc "Clear the HTML rendered by each app"
task :clean_html do
FileUtils.rm Dir.glob('integration_tests/html_for_testing/*.html')
end
desc "Run the build.sh in each app to run its tests and generate the HTML for testing"
task :build_all_test_integrations => [:build, :clean_html] do
Dir["integration_tests/integrations/*"].each do |app_directory_name|
# We need to run each app in isolation from our Bundler environment
Bundler.with_clean_env do
Dir.chdir(app_directory_name) do
require "open3"
_stdin, stdout, stderr, wait_thr = Open3.popen3("./build.sh")
exit_status = wait_thr.value.to_i
if exit_status != 0
STDERR.puts "Running #{app_directory_name}/build.sh failed with exit status: #{exit_status}"
STDERR.puts "stdout:"
STDERR.puts stdout.read
STDERR.puts "stderr:\n"
STDERR.puts stderr.read
fail # Make sure that we exit with non-zero
end
end
end
end
end
desc "Test HTML from each integration testing app"
RSpec::Core::RakeTask.new(:test_html => :build_all_test_integrations) do |t|
t.pattern = 'integration_tests/*_spec.rb'
end
end
task :spec => :compile
task :default => :spec