forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
123 lines (100 loc) · 4.08 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
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'English'
require 'manageiq/ui/classic'
ManageIQ::UI::Classic::Engine.load_tasks
begin
require 'rspec/core/rake_task'
APP_RAKEFILE = File.expand_path("../spec/manageiq/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
rescue LoadError
end
if defined?(RSpec) && defined?(RSpec::Core::RakeTask)
namespace :spec do
desc "Setup environment for specs"
task :setup => ["app:test:initialize", "app:test:verify_no_db_access_loading_rails_environment", "app:test:setup_db"]
end
RSpec::Core::RakeTask.new(:spec => ["app:test:initialize", "app:evm:compile_sti_loader"]) do |t|
spec_dir = File.expand_path("spec", __dir__)
EvmTestHelper.init_rspec_task(t, ['--require', File.join(spec_dir, 'spec_helper')])
t.pattern = FileList[spec_dir + '/**/*_spec.rb'].exclude(spec_dir + '/manageiq/**/*_spec.rb').exclude(spec_dir + '/routes_spec.rb')
end
end
# Only load the jasmine tasks if we are within this repo, otherwise, the bundle
# won't contain the jasmine gem (i.e., from manageiq)
if ENV["BUNDLE_GEMFILE"].nil? || ENV["BUNDLE_GEMFILE"] == File.expand_path("../Gemfile", __FILE__)
require 'jasmine'
load 'jasmine/tasks/jasmine.rake'
require './config/jasmine_overrides'
# running jasmine outside ci ignores the `random: false` in `jasmine.yml` - needs a message
task :jasmine_url do
puts
puts "Please open http://localhost:#{Jasmine.config.port(:server)}/?random=false"
puts
end
Rake::Task['jasmine'].prerequisites.unshift 'jasmine_url'
end
namespace :spec do
desc "Run all routing specs"
RSpec::Core::RakeTask.new(:routes => 'app:test:initialize') do |t|
spec_dir = File.expand_path("spec", __dir__)
EvmTestHelper.init_rspec_task(t, ['--require', File.join(spec_dir, 'spec_helper')])
t.pattern = FileList[File.expand_path('spec/routes_spec.rb', __dir__)]
end
desc "Run all javascript specs"
task :javascript => ["app:test:initialize", :environment, "jasmine:ci"]
desc "Try to compile assets"
task :compile => ["app:assets:precompile"]
desc "Run Jest tests"
task :jest do
system('NODE_OPTIONS=--max_old_space_size=4096 yarn test')
exit $CHILD_STATUS.exitstatus
end
namespace :jest do
desc 'Run Jest tests with node debugger'
task :debug do
puts
puts "open your chrome://inspect/#devices on your chrome based browser (see https://facebook.github.io/jest/docs/en/troubleshooting.html for more details)"
puts
system('node --inspect-brk node_modules/.bin/jest --runInBand')
end
end
desc "Run Debride"
task :debride do
system('bash bin/ci/dead_method_check.sh')
exit 0
end
desc "Run security specs from core"
task :security => ["app:test:security"]
desc "Run cypress specs (starts a Rails server)"
task :cypress => "cypress:run_with_rails"
namespace :cypress do
task :run_with_rails do
# Set the rate limit to a large number to avoid 429: Too Many Requests errors
# which can occur as cypress very quickly hits a lots of endpoints.
puts "\n== Removing rate limit =="
exit $?.exitstatus unless system("bundle exec rails runner 'MiqServer.my_server.add_settings_for_resource(:server => {:rate_limiting => {:request => {:limit => 99999}}})'")
puts "\n== Starting Rails server =="
rails_pid = Bundler.with_original_env do
spawn("bin/rails s", [:out, :err] => "/dev/null")
end
puts "== Rails server started with PID #{rails_pid} =="
Rake::Task["spec:cypress:run"].invoke
ensure
if rails_pid
puts "\n== Killing Rails server with PID #{rails_pid} =="
Process.kill("INT", rails_pid)
end
end
desc "Run cypress specs (with a running Rails server)"
task :run do
ENV["CYPRESS_BROWSER"] ||= "chrome"
puts "\n== Cypress tests started for #{ENV["CYPRESS_BROWSER"]} browser =="
system("yarn cypress:run:#{ENV["CYPRESS_BROWSER"]}")
exit_status = $?.exitstatus
puts "== Cypress tests for #{ENV["CYPRESS_BROWSER"]} browser completed =="
exit exit_status
end
end
end
task :default => ENV["TEST_SUITE"] || :spec