rtomayko / tilt

Generic interface to multiple Ruby template engines

Home Page:http://github.com/rtomayko/tilt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

coffee-script is getting deprecated

lucaskanashiro opened this issue · comments

tilt right now is failing to build from source in Debian and Ubuntu because of an issue with coffee-script:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1013504

coffee-script seems to be on the deprecation route, the upstream maintainers are not willing to support it anymore:

rails/ruby-coffee-script#22 (comment)

Due to that, coffee-script is going to be removed from Debian (and Ubuntu) soon:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019927

and this will impact tilt. Could we try to avoid the dependency on coffee-script?

Tilt doesn't depend on coffee-script. Tilt will allow use of coffee-script if it is installed, but if not installed, the tests will only give a warning. coffee-script is included in the Gemfile, so that it is tested in CI. That part could probably be made optional, such as only including it when an environment variable is given.

Thanks for the quick reply @jeremyevans !

I see you have been cautious in those tests, thanks for that. Maybe the Gemfile change you mentioned would be great. I also think we could let users know that those coffee-script related features are going to be deprecated, so they can move away from it without getting surprised. WDYT?

I'm not sure if we'll be deprecating tilt's support for coffee-script. The tests still pass, so even if the coffee-script gem is no longer actively maintained, tilt's support is still usable. Tilt tends to be conservative in terms of deprecation, only deprecating support when it causes issues in CI. I'll submit a PR for the Gemfile change.

I'm not sure if we'll be deprecating tilt's support for coffee-script. The tests still pass

I am afraid they don't pass with with Coffeescript 2.x, which was released in 2017:

$ ruby -Ilib:test -e 'Dir.glob "./test/**/*coffee*_test.rb", &method(:require)' - -v
Run options: -v --seed 48633

# Running:

LiterateCoffeeScriptTemplateTest#test_disabling_coffee_script_wrapper = 0.34 s = F
LiterateCoffeeScriptTemplateTest#test_is_registered_for_litcoffee_files = 0.00 s = .
LiterateCoffeeScriptTemplateTest#test_bare_is_disabled_by_default = 0.00 s = .
LiterateCoffeeScriptTemplateTest#test_can_be_rendered_more_than_once = 0.18 s = .
LiterateCoffeeScriptTemplateTest#test_compiles_and_evaluates_the_template_on_render = 0.19 s = .
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_overridden_by_no_wrap = 0.19 s = F
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_is_registered_for_litcoffee_files = 0.00 s = .
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_no_options = 0.18 s = F
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_overridden_by_bare = 0.17 s = F
CoffeeScriptTemplateTest#test_disabling_coffee_script_wrapper = 0.19 s = F
CoffeeScriptTemplateTest#test_is_registered_for_coffee_files = 0.00 s = .
CoffeeScriptTemplateTest#test_bare_is_disabled_by_default = 0.00 s = .
CoffeeScriptTemplateTest#test_can_be_rendered_more_than_once = 0.18 s = .
CoffeeScriptTemplateTest#test_compiles_and_evaluates_the_template_on_render = 0.18 s = .
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_overridden_by_no_wrap = 0.17 s = F
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_is_registered_for_litcoffee_files = 0.00 s = .
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_no_options = 0.19 s = F
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_overridden_by_bare = 0.19 s = F
CoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_overridden_by_no_wrap = 0.19 s = F
CoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_is_registered_for_coffee_files = 0.00 s = .
CoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_no_options = 0.17 s = F
CoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_overridden_by_bare = 0.17 s = F
CoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_overridden_by_no_wrap = 0.20 s = F
CoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_is_registered_for_coffee_files = 0.00 s = .
CoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_no_options = 0.20 s = F
CoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_overridden_by_bare = 0.22 s = F

Finished in 3.515684s, 7.3954 runs/s, 15.9286 assertions/s.

  1) Failure:
LiterateCoffeeScriptTemplateTest#test_disabling_coffee_script_wrapper [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:27]:
Expected /puts\("Hello,\ "\ \+\ name\);\n/ to match "(function() {\n  // This is some comment.\n  var name;\n\n  name = \"Josh\";\n\n  puts(`Hello, ${name}`);\n\n  // This is a comment too.\n\n}).call(this);\n".

  2) Failure:
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_overridden_by_no_wrap [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:62]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "// This is some comment.\nvar name;\n\nname = \"Josh\";\n\nputs(`Hello, ${name}`);\n\n// This is a comment too.\n".

  3) Failure:
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_no_options [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:50]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "(function() {\n  // This is some comment.\n  var name;\n\n  name = \"Josh\";\n\n  puts(`Hello, ${name}`);\n\n  // This is a comment too.\n\n}).call(this);\n".

  4) Failure:
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_overridden_by_bare [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:56]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "// This is some comment.\nvar name;\n\nname = \"Josh\";\n\nputs(`Hello, ${name}`);\n\n// This is a comment too.\n".

  5) Failure:
CoffeeScriptTemplateTest#test_disabling_coffee_script_wrapper [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:27]:
Expected /puts\("Hello,\ "\ \+\ name\);\n/ to match "(function() {\n  var name;\n\n  name = \"Josh\";\n\n  puts(`Hello, ${name}`);\n\n}).call(this);\n".

  6) Failure:
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_overridden_by_no_wrap [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:91]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "(function() {\n  // This is some comment.\n  var name;\n\n  name = \"Josh\";\n\n  puts(`Hello, ${name}`);\n\n  // This is a comment too.\n\n}).call(this);\n".

  7) Failure:
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_no_options [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:79]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "// This is some comment.\nvar name;\n\nname = \"Josh\";\n\nputs(`Hello, ${name}`);\n\n// This is a comment too.\n".

  8) Failure:
LiterateCoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_overridden_by_bare [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:85]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "(function() {\n  // This is some comment.\n  var name;\n\n  name = \"Josh\";\n\n  puts(`Hello, ${name}`);\n\n  // This is a comment too.\n\n}).call(this);\n".

  9) Failure:
CoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_overridden_by_no_wrap [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:62]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "var name;\n\nname = \"Josh\";\n\nputs(`Hello, ${name}`);\n".

 10) Failure:
CoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_no_options [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:50]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "(function() {\n  var name;\n\n  name = \"Josh\";\n\n  puts(`Hello, ${name}`);\n\n}).call(this);\n".

 11) Failure:
CoffeeScriptTemplateTest::TestWrapperGloballyEnabled#test_overridden_by_bare [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:56]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "var name;\n\nname = \"Josh\";\n\nputs(`Hello, ${name}`);\n".

 12) Failure:
CoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_overridden_by_no_wrap [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:91]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "(function() {\n  var name;\n\n  name = \"Josh\";\n\n  puts(`Hello, ${name}`);\n\n}).call(this);\n".

 13) Failure:
CoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_no_options [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:79]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "var name;\n\nname = \"Josh\";\n\nputs(`Hello, ${name}`);\n".

 14) Failure:
CoffeeScriptTemplateTest::TestWrapperGloballyDisabled#test_overridden_by_bare [/builddir/build/BUILD/tilt-2.0.10/usr/share/gems/gems/tilt-2.0.10/test/tilt_coffeescripttemplate_test.rb:85]:
Expected /puts\("Hello,\ "\ \+\ name\);/ to match "(function() {\n  var name;\n\n  name = \"Josh\";\n\n  puts(`Hello, ${name}`);\n\n}).call(this);\n".

26 runs, 56 assertions, 14 failures, 0 errors, 0 skips

Admittedly, I have tested with tilt-2.0.10, but checking the source code, the test cases were not updated yet.

BTW the coffee script path can be modified via env variable:

https://github.com/rails/ruby-coffee-script/blob/dd834f78a7cc07e37f6dbf2d91e865f920f5ddfb/lib/coffee_script.rb#L11

The specs pass in CI, which uses the latest version of the coffee-script gem, which appears to use CoffeeScript 1.12.2. FWIW, The spec failures you are seeing with CoffeeScript 2.x appear to be due to fragile tests, and not the underlying support being broken.

We don't generally deprecate/remove support unless something is actually broken on modern Ruby or we cannot properly test it in CI. See #382 for the last time we deprecated template engines. Are you OK with the change proposed in #385?

Just to explain the context, while this seems to be originally reported by Debian/Ubuntu folks, I'm coming with from Fedora. The issue is that the abandoned coffee-script-source gem prevents update of the Coffescript compiler. While Tilt users would likely preferred to use the most recent Coffeescript for all possible purposes, they won't be able to do that due to that gem.

So this is catch 22. Coffeescript upstream would probably like everybody to use Coffeescript 2.x, users would probably like to use Coffeescript 2.x, Tilt probably supports Coffeescript 2.x, but nothing of this happens, because there is abandoned coffee-script-source gem which won't be ever updated.

On Fedora, we could probably update the coffee-script-source gem to provide the Coffeescript 2.x, but in that case, we will face the failing test suite and the solution would be to ignore the test cases, i.e. to drop the coffee-script dependency.

However, given that Rails does not use Coffeescript anymore (and I believe that is the reason behind abandoned coffee-script-source gem), the solution for Fedora will likely be dropping the coffee-script dependency from Tilt package and the test suite can ignore the test cases in such situation just fine. I'll also likely drop the entire coffee-script gem package from Fedora. Therefore it won't be issue for Fedora anymore, but still, this situation is unfortunate.

And just FTR, I am certainly not blaming Tilt here.

The specs pass in CI, which uses the latest version of the coffee-script gem, which appears to use CoffeeScript 1.12.2.

Correct

FWIW, The spec failures you are seeing with CoffeeScript 2.x appear to be due to fragile tests, and not the underlying support being broken.

That also seems to be correct. If the tests were adjusted to support CoffeeScript 2.x and they were also really tested against CoffeeScript 2.x, that would possibly make the situation less unfortunate.

We don't generally deprecate/remove support unless something is actually broken on modern Ruby or we cannot properly test it in CI. See #382 for the last time we deprecated template engines. Are you OK with the change proposed in #385?

This won't help, because we don't use Bundler to run tests on Fedora. Can't speak for others, though.

Just to explain the context, while this seems to be originally reported by Debian/Ubuntu folks, I'm coming with from Fedora. The issue is that the abandoned coffee-script-source gem prevents update of the Coffescript compiler. While Tilt users would likely preferred to use the most recent Coffeescript for all possible purposes, they won't be able to do that due to that gem.

I would guess it more likely that Tilt users would be using Coffeescript for legacy projects that used Coffeescript 1.x and have not yet migrated off of it, as opposed to active projects using Coffeescript 2.x with the enivronment variable to force the gem to load the external Coffeescript source.

So this is catch 22. Coffeescript upstream would probably like everybody to use Coffeescript 2.x, users would probably like to use Coffeescript 2.x, Tilt probably supports Coffeescript 2.x, but nothing of this happens, because there is abandoned coffee-script-source gem which won't be ever updated.

I'm sure Coffeescript upstream would prefer that everyone use the latest release of Coffeescript. However, I doubt Tilt users care much about Coffeescript 2.x.

On Fedora, we could probably update the coffee-script-source gem to provide the Coffeescript 2.x, but in that case, we will face the failing test suite and the solution would be to ignore the test cases, i.e. to drop the coffee-script dependency.

I would recommend against that approach.

However, given that Rails does not use Coffeescript anymore (and I believe that is the reason behind abandoned coffee-script-source gem), the solution for Fedora will likely be dropping the coffee-script dependency from Tilt package and the test suite can ignore the test cases in such situation just fine. I'll also likely drop the entire coffee-script gem package from Fedora. Therefore it won't be issue for Fedora anymore, but still, this situation is unfortunate.

That sounds like a better approach to me.

FWIW, The spec failures you are seeing with CoffeeScript 2.x appear to be due to fragile tests, and not the underlying support being broken.

That also seems to be correct. If the tests were adjusted to support CoffeeScript 2.x and they were also really tested against CoffeeScript 2.x, that would possibly make the situation less unfortunate.

We would accept patches that allow the specs to pass with both CoffeeScript 1.x and 2.x.