mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
DEV: Remove ember-cli flags from the backend (#17147)
…and other auxiliary code * Restore `QUNIT_EMBER_CLI` flag warning * Add `ALLOW_EMBER_CLI_PROXY_BYPASS`
This commit is contained in:
@ -1,15 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if !defined?(EMBER_CLI)
|
||||
EMBER_CLI = EmberCli.enabled?
|
||||
end
|
||||
|
||||
if ENV["EMBER_CLI_PROD_ASSETS"] == "0"
|
||||
STDERR.puts "The 'legacy' ember environment is discontinued. Compiling with ember-cli assets..."
|
||||
end
|
||||
|
||||
task 'assets:precompile:before' do
|
||||
|
||||
require 'uglifier'
|
||||
require 'open3'
|
||||
|
||||
@ -17,7 +8,7 @@ task 'assets:precompile:before' do
|
||||
raise "rake assets:precompile should only be run in RAILS_ENV=production, you are risking unminified assets"
|
||||
end
|
||||
|
||||
if EMBER_CLI && !(ENV["EMBER_CLI_COMPILE_DONE"] == "1")
|
||||
if ENV["EMBER_CLI_COMPILE_DONE"] != "1"
|
||||
compile_command = "NODE_OPTIONS='--max-old-space-size=2048' yarn --cwd app/assets/javascripts/discourse run ember build -prod"
|
||||
only_assets_precompile_remaining = (ARGV.last == "assets:precompile")
|
||||
|
||||
@ -55,12 +46,10 @@ task 'assets:precompile:before' do
|
||||
require 'sprockets'
|
||||
require 'digest/sha1'
|
||||
|
||||
if EMBER_CLI
|
||||
# Add ember cli chunks
|
||||
Rails.configuration.assets.precompile.push(
|
||||
*EmberCli.script_chunks.values.flatten.flat_map { |name| ["#{name}.js", "#{name}.map"] }
|
||||
)
|
||||
end
|
||||
# Add ember cli chunks
|
||||
Rails.configuration.assets.precompile.push(
|
||||
*EmberCli.script_chunks.values.flatten.flat_map { |name| ["#{name}.js", "#{name}.map"] }
|
||||
)
|
||||
end
|
||||
|
||||
task 'assets:precompile:css' => 'environment' do
|
||||
@ -102,7 +91,6 @@ task 'assets:flush_sw' => 'environment' do
|
||||
end
|
||||
|
||||
def is_ember_cli_asset?(name)
|
||||
return false if !EMBER_CLI
|
||||
%w(
|
||||
discourse.js
|
||||
admin.js
|
||||
|
@ -214,9 +214,9 @@ task 'docker:test' do
|
||||
|
||||
unless ENV["SKIP_PLUGINS"]
|
||||
if ENV["SINGLE_PLUGIN"]
|
||||
@good &&= run_or_fail("CI=1 QUNIT_EMBER_CLI=1 bundle exec rake plugin:qunit['#{ENV['SINGLE_PLUGIN']}','#{js_timeout}']")
|
||||
@good &&= run_or_fail("CI=1 bundle exec rake plugin:qunit['#{ENV['SINGLE_PLUGIN']}','#{js_timeout}']")
|
||||
else
|
||||
@good &&= run_or_fail("CI=1 QUNIT_EMBER_CLI=1 bundle exec rake plugin:qunit['*','#{js_timeout}']")
|
||||
@good &&= run_or_fail("CI=1 bundle exec rake plugin:qunit['*','#{js_timeout}']")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -28,24 +28,18 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||
false
|
||||
end
|
||||
|
||||
if ENV['QUNIT_EMBER_CLI'] == "0"
|
||||
if ENV["QUNIT_EMBER_CLI"] == "0"
|
||||
puts "The 'legacy' ember environment is discontinued - running tests with ember-cli assets..."
|
||||
end
|
||||
|
||||
ember_cli = true
|
||||
|
||||
port = ENV['TEST_SERVER_PORT'] || 60099
|
||||
while !port_available? port
|
||||
port += 1
|
||||
end
|
||||
|
||||
if ember_cli
|
||||
unicorn_port = 60098
|
||||
while unicorn_port == port || !port_available?(unicorn_port)
|
||||
unicorn_port += 1
|
||||
end
|
||||
else
|
||||
unicorn_port = port
|
||||
unicorn_port = 60098
|
||||
while unicorn_port == port || !port_available?(unicorn_port)
|
||||
unicorn_port += 1
|
||||
end
|
||||
|
||||
env = {
|
||||
@ -61,10 +55,6 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||
"UNICORN_TIMEOUT" => "90",
|
||||
}
|
||||
|
||||
if !ember_cli
|
||||
env["EMBER_CLI_PROD_ASSETS"] = "0"
|
||||
end
|
||||
|
||||
pid = Process.spawn(
|
||||
env,
|
||||
"#{Rails.root}/bin/unicorn",
|
||||
@ -75,7 +65,6 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||
success = true
|
||||
test_path = "#{Rails.root}/test"
|
||||
qunit_path = args[:qunit_path]
|
||||
qunit_path ||= "/qunit" if !ember_cli
|
||||
|
||||
options = { seed: (ENV["QUNIT_SEED"] || Random.new.seed), hidepassed: 1 }
|
||||
|
||||
@ -96,9 +85,10 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||
|
||||
# wait for server to accept connections
|
||||
require 'net/http'
|
||||
warmup_path = ember_cli ? "/assets/discourse/tests/active-plugins.js" : "/qunit"
|
||||
warmup_path = "/assets/discourse/tests/active-plugins.js"
|
||||
uri = URI("http://localhost:#{unicorn_port}/#{warmup_path}")
|
||||
puts "Warming up Rails server"
|
||||
|
||||
begin
|
||||
Net::HTTP.get(uri)
|
||||
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, Net::ReadTimeout, EOFError
|
||||
@ -109,24 +99,20 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||
end
|
||||
puts "Rails server is warmed up"
|
||||
|
||||
if ember_cli
|
||||
cmd = ["env", "UNICORN_PORT=#{unicorn_port}"]
|
||||
if qunit_path
|
||||
# Bypass `ember test` - it only works properly for the `/tests` path.
|
||||
# We have to trigger a `build` manually so that JS is available for rails to serve.
|
||||
system("yarn", "ember", "build", chdir: "#{Rails.root}/app/assets/javascripts/discourse")
|
||||
test_page = "#{qunit_path}?#{query}&testem=1"
|
||||
cmd += ["yarn", "testem", "ci", "-f", "testem.js", "-t", test_page]
|
||||
else
|
||||
cmd += ["yarn", "ember", "test", "--query", query]
|
||||
end
|
||||
system(*cmd, chdir: "#{Rails.root}/app/assets/javascripts/discourse")
|
||||
cmd = ["env", "UNICORN_PORT=#{unicorn_port}"]
|
||||
|
||||
if qunit_path
|
||||
# Bypass `ember test` - it only works properly for the `/tests` path.
|
||||
# We have to trigger a `build` manually so that JS is available for rails to serve.
|
||||
system("yarn", "ember", "build", chdir: "#{Rails.root}/app/assets/javascripts/discourse")
|
||||
test_page = "#{qunit_path}?#{query}&testem=1"
|
||||
cmd += ["yarn", "testem", "ci", "-f", "testem.js", "-t", test_page]
|
||||
else
|
||||
cmd = "node #{test_path}/run-qunit.js http://localhost:#{port}#{qunit_path}"
|
||||
cmd += "?#{query.gsub('+', '%20').gsub("&", '\\\&')}"
|
||||
cmd += " #{args[:timeout]}" if args[:timeout].present?
|
||||
system(cmd)
|
||||
cmd += ["yarn", "ember", "test", "--query", query]
|
||||
end
|
||||
|
||||
system(*cmd, chdir: "#{Rails.root}/app/assets/javascripts/discourse")
|
||||
|
||||
success &&= $?.success?
|
||||
ensure
|
||||
# was having issues with HUP
|
||||
|
Reference in New Issue
Block a user