-
Notifications
You must be signed in to change notification settings - Fork 38
/
Rakefile
70 lines (61 loc) · 2.23 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
# frozen_string_literal: true
require "rails"
Rails.env = "test"
require "bundler/gem_tasks"
# Run `rake release` to release a new version of the gem.
require "rake/testtask"
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList["test/test*.rb"]
t.verbose = true
end
namespace :test do
task :capture do
ENV["TEST_CAPTURE"] = "true"
Rake::Task[:test].invoke
end
task :rubocop do
sh "rubocop"
end
task :system do
rm_rf "test/tmp/system_test"
Dir.chdir "test/tmp" do
sh "rails new system_test --javascript esbuild"
Dir.chdir "system_test"
sh "bundle config disable_local_branch_check true"
sh "bundle config set --local local.dockerfile-rails #{__dir__}"
sh "bundle add dockerfile-rails --group development " +
"--git https://github.com/rubys/dockerfile-rails.git"
sh "bin/rails generate dockerfile --force"
cp "#{__dir__}/test/docker-entrypoint", "bin"
IO.write "config/routes.rb",
'Rails.application.routes.draw {get "/up", to: proc {[200, {}, ["ok"]]}}'
sh "docker buildx build . --load -t system:test"
key = IO.read("config/master.key")
sh "docker run -p 3000:3000 -e RAILS_MASTER_KEY=#{key} --rm system:test"
end
ensure
rm_rf "test/tmp/system_test" unless ENV["TEST_KEEP"]
end
task :alpine do
rm_rf "test/tmp/system_test"
Dir.chdir "test/tmp" do
sh "rails new system_test --javascript esbuild --main"
Dir.chdir "system_test"
sh "bundle config disable_local_branch_check true"
sh "bundle config set --local local.dockerfile-rails #{__dir__}"
sh "bundle add dockerfile-rails --group development " +
"--git https://github.com/rubys/dockerfile-rails.git"
sh "bin/rails generate dockerfile --alpine --force"
cp "#{__dir__}/test/docker-entrypoint", "bin"
IO.write "config/routes.rb",
'Rails.application.routes.draw {get "/up", to: proc {[200, {}, ["ok"]]}}'
sh "docker buildx build . --load -t system:test"
key = IO.read("config/master.key")
sh "docker run -p 3000:3000 -e RAILS_MASTER_KEY=#{key} --rm system:test"
end
ensure
rm_rf "test/tmp/system_test" unless ENV["TEST_KEEP"]
end
task all: %w(test:rubocop test test:system)
end