From 8357a6973c9919db55fd84e06d75789d3024b3f5 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 10:03:56 +0200 Subject: [PATCH 1/9] Migrate to GitHub Actions --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c3cfe48 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: [push, pull_request] + +jobs: + rubies: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos] + ruby: [ '3.0', '2.7', '2.6', '2.5' ] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Install dependencies + run: bundle install + - name: Run test + run: rake + - name: Install gem + run: rake install From 70e8498ebc7989fab4f15f4f1b483527888ab40a Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 10:22:31 +0200 Subject: [PATCH 2/9] Fix a test failure and minitest warnings --- lib/execjs/mini_racer_runtime.rb | 1 + test/test_execjs.rb | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/execjs/mini_racer_runtime.rb b/lib/execjs/mini_racer_runtime.rb index b8a3bca..9b66bbf 100644 --- a/lib/execjs/mini_racer_runtime.rb +++ b/lib/execjs/mini_racer_runtime.rb @@ -6,6 +6,7 @@ module ExecJS def initialize(runtime, source = "", options={}) source = encode(source) @context = ::MiniRacer::Context.new + @context.eval("delete this.console"); translate do @context.eval(source) end diff --git a/test/test_execjs.rb b/test/test_execjs.rb index 81804a1..1ff9319 100644 --- a/test/test_execjs.rb +++ b/test/test_execjs.rb @@ -104,21 +104,21 @@ class TestExecJS < Test '"\\\\"' => "\\" }.each_with_index do |(input, output), index| define_method("test_exec_string_#{index}") do - assert_equal output, ExecJS.exec("return #{input}") + assert_output output, ExecJS.exec("return #{input}") end define_method("test_eval_string_#{index}") do - assert_equal output, ExecJS.eval(input) + assert_output output, ExecJS.eval(input) end define_method("test_compile_return_string_#{index}") do context = ExecJS.compile("var a = #{input};") - assert_equal output, context.eval("a") + assert_output output, context.eval("a") end define_method("test_compile_call_string_#{index}") do context = ExecJS.compile("function a() { return #{input}; }") - assert_equal output, context.call("a") + assert_output output, context.call("a") end end @@ -145,25 +145,25 @@ class TestExecJS < Test json_value = JSON.generate(value, quirks_mode: true) define_method("test_json_value_#{index}") do - assert_equal value, JSON.parse(json_value, quirks_mode: true) + assert_output value, JSON.parse(json_value, quirks_mode: true) end define_method("test_exec_value_#{index}") do - assert_equal value, ExecJS.exec("return #{json_value}") + assert_output value, ExecJS.exec("return #{json_value}") end define_method("test_eval_value_#{index}") do - assert_equal value, ExecJS.eval("#{json_value}") + assert_output value, ExecJS.eval("#{json_value}") end define_method("test_strinigfy_value_#{index}") do context = ExecJS.compile("function json(obj) { return JSON.stringify(obj); }") - assert_equal json_value, context.call("json", value) + assert_output json_value, context.call("json", value) end define_method("test_call_value_#{index}") do context = ExecJS.compile("function id(obj) { return obj; }") - assert_equal value, context.call("id", value) + assert_output value, context.call("id", value) end end @@ -421,4 +421,14 @@ class TestExecJS < Test assert_equal "function foo(bar){return bar}", context.call("uglify", "function foo(bar) {\n return bar;\n}") end + + private + + def assert_output(expected, actual) + if expected.nil? + assert_nil actual + else + assert_equal expected, actual + end + end end From 75b69a4e46533f8746230c2ab2a3f74365bd8e6f Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 10:30:06 +0200 Subject: [PATCH 3/9] Upgrade bundler and rubygems on CI --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3cfe48..50cc1f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,10 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} + - name: Update Rubygems + run: gem update --system + - name: Install bundler + run: gem install bundler -v '2.2.16' - name: Install dependencies run: bundle install - name: Run test From 8eadf60e7f42ea01959c3bd067fcb9055277b35e Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 10:37:30 +0200 Subject: [PATCH 4/9] Use macos latest --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50cc1f0..65fcecd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos] + os: [ubuntu-latest, macos-latest] ruby: [ '3.0', '2.7', '2.6', '2.5' ] runs-on: ${{ matrix.os }} steps: From 1dce3d077866c01d32230aead7b82d7e5b7a341b Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 11:45:12 +0200 Subject: [PATCH 5/9] Update JavaScriptCore path --- lib/execjs/runtimes.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/execjs/runtimes.rb b/lib/execjs/runtimes.rb index 9804257..19d9d96 100644 --- a/lib/execjs/runtimes.rb +++ b/lib/execjs/runtimes.rb @@ -24,7 +24,10 @@ module ExecJS JavaScriptCore = ExternalRuntime.new( name: "JavaScriptCore", - command: "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", + command: [ + "/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc", + "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", + ], runner_path: ExecJS.root + "/support/jsc_runner.js" ) From c5fd11d7b0338ae7779f69a293964f3440ee3787 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 11:53:56 +0200 Subject: [PATCH 6/9] Explicitly call process.exit in the node runner to prevent it from hanging --- lib/execjs/support/node_runner.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/execjs/support/node_runner.js b/lib/execjs/support/node_runner.js index 2987d9f..dc1b677 100644 --- a/lib/execjs/support/node_runner.js +++ b/lib/execjs/support/node_runner.js @@ -28,4 +28,5 @@ this.process = __process__; print(JSON.stringify(['err', '' + err, err.stack])); } + __process__.exit(0); }); From a7a4096c22214b8810780bca7a39e29f792b7e94 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 11:57:49 +0200 Subject: [PATCH 7/9] Add NodeJS to the CI --- .github/workflows/ci.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65fcecd..502f256 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,13 +3,37 @@ name: CI on: [push, pull_request] jobs: - rubies: + ubuntu: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] ruby: [ '3.0', '2.7', '2.6', '2.5' ] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Node + run: sudo apt-get install -y nodejs + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Update Rubygems + run: gem update --system + - name: Install bundler + run: gem install bundler -v '2.2.16' + - name: Install dependencies + run: bundle install + - name: Run test + run: rake + - name: Install gem + run: rake install + macos: + strategy: + fail-fast: false + matrix: + ruby: [ '3.0', '2.7', '2.6', '2.5' ] + runs-on: macos-latest steps: - name: Checkout uses: actions/checkout@v2 From 0c34623a55c239e1f2b194853d47cb1062a5f569 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 12:12:25 +0200 Subject: [PATCH 8/9] Add jruby and truffle-ruby --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 502f256..db2454c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ '3.0', '2.7', '2.6', '2.5' ] + ruby: [ '3.0', '2.7', '2.6', '2.5', 'jruby', 'truffleruby' ] runs-on: ubuntu-latest steps: - name: Checkout From 2af3225dcaf2bd89d3d65a0dddd742b3651e0565 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 7 May 2021 12:16:59 +0200 Subject: [PATCH 9/9] Remove travis config --- .travis.yml | 87 ----------------------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3151394..0000000 --- a/.travis.yml +++ /dev/null @@ -1,87 +0,0 @@ -language: ruby -cache: bundler -sudo: false -# we need trust so correct gcc runs for mini_racer, latest v8 requires gcc 4.8+ - -before_install: - - if [ "$EXECJS_RUNTIME" == "V8" ]; then brew update; fi - - if [ "$EXECJS_RUNTIME" == "V8" ]; then brew install v8; fi - - if [ "$EXECJS_RUNTIME" == "Node" ]; then node --version; fi - - if [ "$EXECJS_RUNTIME" == "MiniRacer" ]; then gem install bundler -v 1.12.0; fi -script: bundle && bundle exec ruby test/test_execjs.rb - -matrix: - include: - - rvm: 2.0.0 - env: EXECJS_RUNTIME=Node - - rvm: 2.0.0 - env: EXECJS_RUNTIME=Duktape - - rvm: 2.0.0 - env: EXECJS_RUNTIME=MiniRacer - dist: trusty - sudo: true - - - rvm: 2.1.10 - env: EXECJS_RUNTIME=Node - - rvm: 2.1.10 - env: EXECJS_RUNTIME=Duktape - - rvm: 2.1.10 - env: EXECJS_RUNTIME=MiniRacer - dist: trusty - sudo: true - - - rvm: 2.2.7 - env: EXECJS_RUNTIME=Node - - rvm: 2.2.7 - env: EXECJS_RUNTIME=Duktape - - rvm: 2.2.7 - env: EXECJS_RUNTIME=MiniRacer - dist: trusty - sudo: true - - - rvm: 2.3.4 - env: EXECJS_RUNTIME=Node - - rvm: 2.3.4 - env: EXECJS_RUNTIME=Duktape - - rvm: 2.3.4 - env: EXECJS_RUNTIME=MiniRacer - dist: trusty - sudo: true - - - rvm: 2.4.1 - env: EXECJS_RUNTIME=Node - - rvm: 2.4.1 - env: EXECJS_RUNTIME=Duktape - - rvm: 2.4.1 - env: EXECJS_RUNTIME=MiniRacer - dist: trusty - sudo: true - - - rvm: ruby-head - env: EXECJS_RUNTIME=Node - - rvm: ruby-head - env: EXECJS_RUNTIME=Duktape - - rvm: ruby-head - env: EXECJS_RUNTIME=MiniRacer - dist: trusty - sudo: true - - - rvm: jruby-19mode - env: EXECJS_RUNTIME=Node - - rvm: jruby-19mode - env: EXECJS_RUNTIME=RubyRhino - - - os: osx - env: EXECJS_RUNTIME=JavaScriptCore - - os: osx - env: EXECJS_RUNTIME=Node - - os: osx - env: EXECJS_RUNTIME=Duktape - - os: osx - env: EXECJS_RUNTIME=V8 - - os: osx - env: EXECJS_RUNTIME=MiniRacer - osx_image: xcode7.3 - allow_failures: - - rvm: ruby-head - fast_finish: true