Uploaded image for project: 'Moodle Community Sites'
  1. Moodle Community Sites
  2. MDLSITE-5739

moodle-local_ci: mustache linting error with openjdk11

    XMLWordPrintable

    Details

      Description

      The problem manifested itself on Moodle plugin test on Travis using moodle-plugin-ci tool, which reported:

      WARNING: Problem calling HTML validator - please report bug to integration team.
      

      Looking deeper, it has been identified that when Travis picks Ubuntu Xenial for VM, it is using openjdk11 by default (ticket with more detailed explanation on the issue). This in turn highlighted the potential issue in moodle-local_ci if JDK version 11 is in use.

      What is happening

      I jumped on travis VM and verified what is going on. Here is a simple mustache test replicating what moodle-plugin-ci is doing as part of mustache check:

      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/moodle$ java --version
      openjdk 11.0.2 2019-01-15
      OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
      OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/moodle$ php ../ci/vendor/moodlehq/moodle-local_ci/mustache_lint/mustache_lint.php --filename=/home/travis/moodle/theme/workplace/templates/header.mustache --basename=/home/travis/moodle --validator=/home/travis/ci/vendor/moodlehq/moodle-local_ci/node_modules/vnu-jar/build/dist/vnu.jar 
      /home/travis/moodle/theme/workplace/templates/header.mustache - WARNING: Problem calling HTML validator - please report bug to integration team.
      

      Let's add some debugging:

      diff --git a/mustache_lint/mustache_lint.php b/mustache_lint/mustache_lint.php
      index a1ac17c..37dee35 100644
      --- a/mustache_lint/mustache_lint.php
      +++ b/mustache_lint/mustache_lint.php
      @@ -263,7 +263,7 @@ function validate_html($content) {
       
               // The "2>&1" part redirects stderr to stdout because the JSON is sent to stderr and PHP does not capture that.
               $output = shell_exec(sprintf('java -jar %s --format json --exit-zero-always %s 2>&1', $VALIDATOR, $file));
      -
      +        var_dump($output);
               unlink($file);
       
               if ($output === null) {
      

      And see what is actually happening:

      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/moodle$ java --version
      openjdk 11.0.2 2019-01-15
      OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
      OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/moodle$ php ../ci/vendor/moodlehq/moodle-local_ci/mustache_lint/mustache_lint.php --filename=/home/travis/moodle/theme/workplace/templates/header.mustache --basename=/home/travis/moodle --validator=/home/travis/ci/vendor/moodlehq/moodle-local_ci/node_modules/vnu-jar/build/dist/vnu.jar 
      string(91) "Warning: Nashorn engine is planned to be removed from a future JDK release
      {"messages":[]}
      "
      /home/travis/moodle/theme/workplace/templates/header.mustache - WARNING: Problem calling HTML validator - please report bug to integration team.
      

      OK, that output content we have got clearly can't be parsed by json_decode, thus the problem.

      Solution

      I could not find a related ticket in V.Nu project (apart of this one where Nashorn is mentioned), but it seems like it is no longer the issue in the latest stable release 18.11.5:

      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/ci/vendor/moodlehq/moodle-local_ci$ npm update
      + vnu-jar@18.11.5
      updated 1 package in 0.744s
      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/ci/vendor/moodlehq/moodle-local_ci$ cd -
      /home/travis/moodle
      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/moodle$ java --version
      openjdk 11.0.2 2019-01-15
      OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
      OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/moodle$ php ../ci/vendor/moodlehq/moodle-local_ci/mustache_lint/mustache_lint.php --filename=/home/travis/moodle/theme/workplace/templates/header.mustache --basename=/home/travis/moodle --validator=/home/travis/ci/vendor/moodlehq/moodle-local_ci/node_modules/vnu-jar/build/dist/vnu.jar 
      string(325) "{"messages":[{"type":"info","url":"file:/tmp/mustache_lintY7FnBk","lastLine":1,"lastColumn":21,"firstColumn":16,"subType":"warning","message":"Consider adding a “lang” attribute to the “html” start tag to declare the language of this document.","extract":"TYPE html><head><title","hiliteStart":10,"hiliteLength":6}]}
      "
      /home/travis/moodle/theme/workplace/templates/header.mustache - WARNING: HTML Validation info, line 1: Consider adding a “lang” attribute to the “html” start tag to declare the language of this document. (TYPE html><head><title) 
      

      OK, a different issue, absolutely valid notice these days BTW: https://www.w3.org/International/questions/qa-html-language-declarations#quickanswer

      But no complains regarding Nashorn engine, which is good. After fixing lang attribute (you will see it in the patch) and running again, we are getting success.

      Let's see if we can use same vnu 18.11.5 with openjdk8 (should be possible according to docs), so we are safe to upgrade. First we change java version on Xenial VM using this hack, and run our test again:

      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/moodle$ java -version                                                                                                                                                                                                                                                 
      openjdk version "1.8.0_191"
      OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12)
      OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
      travis@travis-job-d5d214f7-f40c-4cb6-8289-5bff56fde2e8:~/moodle$ php ../ci/vendor/moodlehq/moodle-local_ci/mustache_lint/mustache_lint.php --filename=/home/travis/moodle/theme/workplace/templates/header.mustache --basename=/home/travis/moodle --validator=/home/travis/ci/vendor/moodlehq/moodle-local_ci/node_modules/vnu-jar/build/dist/vnu.jar 
      string(16) "{"messages":[]}
      "
      /home/travis/moodle/theme/workplace/templates/header.mustache - OK: Mustache rendered html succesfully
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: