Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-68887

CssSyntaxError when linting war module on Windows

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • core
    • windows 11, java11
      also ci.jenkins.io - but that also continues but does not fail

      git core.autocrlf=false
    • 2.358

      building jenkins core (master) fails on windows

      ```
      INFO] 67:3 â?¼ Expected selector "#plugins tr.deleted .jenkins-toggle-switch label" to come before selector "#plugins tr.has-disabled-dependency .enable .jenkins-toggle-switch label" no-descending-specificity
      [INFO]
      [INFO] src/main/less/pages/setupWizardFirstUser.less
      [INFO] 21:25 â?¼ Expected newline after "," selector-list-comma-newline-after
      [INFO]
      [INFO] error Command failed with exit code 2.
      [INFO] error Command failed with exit code 2.info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
      [INFO] error Command failed with exit code 2.
      [INFO] error Command failed with exit code 2.info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary for Jenkins main module 2.358-SNAPSHOT:
      [INFO]
      [INFO] Jenkins main module ................................ SUCCESS [ 3.305 s]
      [INFO] Jenkins BOM ........................................ SUCCESS [ 0.225 s]
      [INFO] Jenkins cli ........................................ SUCCESS [ 21.519 s]
      [INFO] Jenkins core ....................................... SUCCESS [02:51 min]
      [INFO] Jenkins war ........................................ FAILURE [01:56 min]
      [INFO] Tests for Jenkins core ............................. SKIPPED
      [INFO] Jenkins coverage ................................... SKIPPED
      [INFO] ------------------------------------------------------------------------
      ```

      this is also the case on CI however there due to the profiles it uses the failure does not seem to be fatal (or because these yarn things are tests.)

      https://ci.jenkins.io/blue/rest/organizations/jenkins/pipelines/Core/pipelines/jenkins/branches/master/runs/3747/nodes/75/steps/88/log/?start=0

      Steps to reproduce

      checlout the latest jenkinsci/jenkins code on windows
      mvn install

      expected behaviour

      the build and tests pass and the artfacts are installed to the local repo

      Actual Results

      build fails (yarn lint)?

          [JENKINS-68887] CssSyntaxError when linting war module on Windows

          Basil Crow added a comment -

          The difference between the passing build (Linux) and failing build (Windows) is in src/main/less/abstracts/theme.less. On Linux it prints:

          [INFO] 1:6 Expected newline after "," selector-list-comma-newline-after 
          [INFO] 4:37 Expected "SFMono-Regular" to be "sfmono-regular" value-keyword-case 
          [INFO] 4:53 Expected "SF" to be "sf" value-keyword-case 
          [INFO] 4:56 Expected "Mono" to be "mono" value-keyword-case 
          [INFO] 4:62 Expected "JetBrainsMono" to be "jetbrainsmono" value-keyword-case 
          [INFO] 4:77 Expected "Consolas" to be "consolas" value-keyword-case 
          [INFO] 32:25 Expected "#063F61" to be "#063f61" color-hex-case 
          [INFO] 130:21 Expected "#063F61" to be "#063f61" color-hex-case 
          [INFO] 131:35 Expected "#063F61" to be "#063f61" color-hex-case 
          [INFO] 132:36 Expected "#063F61" to be "#063f61" color-hex-case 
          [INFO] 259:19 Expected "#C3CCD1" to be "#c3ccd1" color-hex-case 
          [INFO] 260:25 Expected "#5C7889" to be "#5c7889" color-hex-case 
          [INFO] 329:4 Expected a trailing semicolon declaration-block-trailing-semicolon
          [INFO] 329:5 Expected newline before "}" of a multi-line block block-closing-brace-newline-before 
          [INFO] 333:3 Unexpected unknown property "blue" property-no-unknown 
          [INFO] 334:3 Unexpected unknown property "brown" property-no-unknown 
          [INFO] 335:3 Unexpected unknown property "cyan" property-no-unknown 
          [INFO] 336:3 Unexpected unknown property "green" property-no-unknown 
          [INFO] 337:3 Unexpected unknown property "indigo" property-no-unknown 
          [INFO] 338:3 Unexpected unknown property "orange" property-no-unknown 
          [INFO] 339:3 Unexpected unknown property "pink" property-no-unknown 
          [INFO] 340:3 Unexpected unknown property "purple" property-no-unknown 
          [INFO] 341:3 Unexpected unknown property "red" property-no-unknown 
          [INFO] 342:3 Unexpected unknown property "yellow" property-no-unknown 
          [INFO] 342:11 Expected "#ffcc00" to be "#fc0" color-hex-length 
          [INFO] 346:3 Unexpected unknown property "error" property-no-unknown 
          [INFO] 347:3 Unexpected unknown property "warning" property-no-unknown 
          [INFO] 348:3 Unexpected unknown property "success" property-no-unknown 
          [INFO] 349:3 Unexpected unknown property "destructive" property-no-unknown 
          [INFO] 350:3 Unexpected unknown property "build" property-no-unknown 
          

          On Windows it fails after printing:

          [INFO] 327:3 Unknown word CssSyntaxError
          

          Line 327 is:

          786473d3681 war/src/main/less/abstracts/theme.less  (Jan Faracik         2022-05-14 07:48:19 +0100 327)   each(@semantics, {
          786473d3681 war/src/main/less/abstracts/theme.less  (Jan Faracik         2022-05-14 07:48:19 +0100 328)     --@{key}-color: @value;
          786473d3681 war/src/main/less/abstracts/theme.less  (Jan Faracik         2022-05-14 07:48:19 +0100 329)   })
          

          Pinging janfaracik as this was added in https://github.com/jenkinsci/jenkins/pull/6538. Perhaps there should be a semicolon at the end of line 329?

          Basil Crow added a comment - The difference between the passing build (Linux) and failing build (Windows) is in src/main/less/abstracts/theme.less . On Linux it prints: [INFO] 1:6 Expected newline after "," selector-list-comma-newline-after [INFO] 4:37 Expected "SFMono-Regular" to be "sfmono-regular" value-keyword-case [INFO] 4:53 Expected "SF" to be "sf" value-keyword-case [INFO] 4:56 Expected "Mono" to be "mono" value-keyword-case [INFO] 4:62 Expected "JetBrainsMono" to be "jetbrainsmono" value-keyword-case [INFO] 4:77 Expected "Consolas" to be "consolas" value-keyword-case [INFO] 32:25 Expected "#063F61" to be "#063f61" color-hex-case [INFO] 130:21 Expected "#063F61" to be "#063f61" color-hex-case [INFO] 131:35 Expected "#063F61" to be "#063f61" color-hex-case [INFO] 132:36 Expected "#063F61" to be "#063f61" color-hex-case [INFO] 259:19 Expected "#C3CCD1" to be "#c3ccd1" color-hex-case [INFO] 260:25 Expected "#5C7889" to be "#5c7889" color-hex-case [INFO] 329:4 Expected a trailing semicolon declaration-block-trailing-semicolon [INFO] 329:5 Expected newline before "}" of a multi-line block block-closing-brace-newline-before [INFO] 333:3 Unexpected unknown property "blue" property-no-unknown [INFO] 334:3 Unexpected unknown property "brown" property-no-unknown [INFO] 335:3 Unexpected unknown property "cyan" property-no-unknown [INFO] 336:3 Unexpected unknown property "green" property-no-unknown [INFO] 337:3 Unexpected unknown property "indigo" property-no-unknown [INFO] 338:3 Unexpected unknown property "orange" property-no-unknown [INFO] 339:3 Unexpected unknown property "pink" property-no-unknown [INFO] 340:3 Unexpected unknown property "purple" property-no-unknown [INFO] 341:3 Unexpected unknown property "red" property-no-unknown [INFO] 342:3 Unexpected unknown property "yellow" property-no-unknown [INFO] 342:11 Expected "#ffcc00" to be "#fc0" color-hex-length [INFO] 346:3 Unexpected unknown property "error" property-no-unknown [INFO] 347:3 Unexpected unknown property "warning" property-no-unknown [INFO] 348:3 Unexpected unknown property "success" property-no-unknown [INFO] 349:3 Unexpected unknown property "destructive" property-no-unknown [INFO] 350:3 Unexpected unknown property "build" property-no-unknown On Windows it fails after printing: [INFO] 327:3 Unknown word CssSyntaxError Line 327 is: 786473d3681 war/src/main/less/abstracts/theme.less (Jan Faracik 2022-05-14 07:48:19 +0100 327) each(@semantics, { 786473d3681 war/src/main/less/abstracts/theme.less (Jan Faracik 2022-05-14 07:48:19 +0100 328) --@{key}-color: @value; 786473d3681 war/src/main/less/abstracts/theme.less (Jan Faracik 2022-05-14 07:48:19 +0100 329) }) Pinging janfaracik as this was added in https://github.com/jenkinsci/jenkins/pull/6538 . Perhaps there should be a semicolon at the end of line 329?

          The error described above is caused by calling "yarn lint" which apparently fails, likely not by a missing semicolon.
          I went ahead and ran over .less file with styelint to take care of defined issues, however, that doesn't resolve the failure of "yarn lint".

          Alexander Brandes added a comment - The error described above is caused by calling "yarn lint" which apparently fails, likely not by a missing semicolon. I went ahead and ran over .less file with styelint to take care of defined issues, however, that doesn't resolve the failure of "yarn lint".

          Basil Crow added a comment -

          But the linter isn't showing "error Command failed with exit code 2" on Linux, even though there are warnings on Linux. This makes me suspect the linter is returning a zero exit code when it ran successfully and discovered warnings but a non-zero exit code when it failed to run successfully. The difference in output shows that theme.less around line 327 is where the Windows linter run has trouble (CssSyntaxError) and my theory is that this error causes the non-zero exit code.

          Basil Crow added a comment - But the linter isn't showing "error Command failed with exit code 2" on Linux, even though there are warnings on Linux. This makes me suspect the linter is returning a zero exit code when it ran successfully and discovered warnings but a non-zero exit code when it failed to run successfully. The difference in output shows that theme.less around line 327 is where the Windows linter run has trouble ( CssSyntaxError ) and my theory is that this error causes the non-zero exit code.

          Basil Crow added a comment -

          Basil Crow added a comment - BTW this post corroborates my theory: https://github.com/stylelint/stylelint/issues/2215#issuecomment-269507140

          Interesting, I don't have a windows installation at hand at the moment, though surprisingly enough macOS, specifically running with zsh, doesn't complain about it.

          Alexander Brandes added a comment - Interesting, I don't have a windows installation at hand at the moment, though surprisingly enough macOS, specifically running with zsh, doesn't complain about it.

          Basil Crow added a comment -

          Shell has nothing to do with it, and macOS/Linux builds are unaffected. The CssSyntaxError only appears on Windows builds, which causes the linter to crash with a non-zero exit code.

          Basil Crow added a comment - Shell has nothing to do with it, and macOS/Linux builds are unaffected. The CssSyntaxError only appears on Windows builds, which causes the linter to crash with a non-zero exit code.

          James Nord added a comment - - edited

          also worth noting is that if I use -Dmaven.test.failure.ignore=true then the build at least continues - which explains why it works on windows in ci.jenkins.io.

          But also shows - something that would seem to be wring - failure to lint should not let the build keep running :-/

          James Nord added a comment - - edited also worth noting is that if I use -Dmaven.test.failure.ignore=true then the build at least continues - which explains why it works on windows in ci.jenkins.io. But also shows - something that would seem to be wring - failure to lint should not let the build keep running :-/

          Basil Crow added a comment -

          Shot in the dark: it might be worth trying to unroll the two @each loops into their expanded form to see if that chases the problem away.

          Basil Crow added a comment - Shot in the dark: it might be worth trying to unroll the two @each loops into their expanded form to see if that chases the problem away.

          Basil Crow added a comment -

          The stack trace is as follows:

          CssSyntaxError: jenkinsci/jenkins/war/src/main/less/abstracts/theme.less:327:3: Unknown word
              at Input.error (jenkinsci/jenkins/war/node_modules/postcss-less/node_modules/postcss/lib/input.js:130:16)
              at LessParser.unknownWord (jenkinsci/jenkins/war/node_modules/postcss-less/node_modules/postcss/lib/parser.js:563:22)
              at LessParser.unknownWord (jenkinsci/jenkins/war/node_modules/postcss-less/lib/LessParser.js:209:11)
              at LessParser.other (jenkinsci/jenkins/war/node_modules/postcss-less/node_modules/postcss/lib/parser.js:168:12)
              at LessParser.other (jenkinsci/jenkins/war/node_modules/postcss-less/lib/LessParser.js:158:13)
              at LessParser.parse (jenkinsci/jenkins/war/node_modules/postcss-less/node_modules/postcss/lib/parser.js:77:16)
              at parse (jenkinsci/jenkins/war/node_modules/postcss-less/lib/index.js:11:12)
              at new LazyResult (jenkinsci/jenkins/war/node_modules/stylelint/node_modules/postcss/lib/lazy-result.js:60:16)
              at jenkinsci/jenkins/war/node_modules/stylelint/lib/getPostcssResult.js:110:19
              at async Promise.all (index 5)
          

          Uncommenting https://github.com/shellscape/postcss-less/blob/984f4901aced4b74535d96b04242681d538d628b/lib/LessParser.js#L192= to examine the unknown portion of the parse tree, I see this on Windows:

          unknown [
            [ 'word', 'each', 327, 3, 327, 6 ],
            [
              'brackets',
              '(@semantics, {\r\n    --@{key}-color: @value;\r\n  })',
              327,
              7,
              327,
              55
            ],
            [ 'space', '\r\n' ]
          ]
          

          On Linux, I see:

          unknown [
            [ 'word', 'each', 327, 3, 327, 6 ],
            [ '(', '(', 327, 7 ],
            [ 'at-word', '@semantics,', 327, 8, 327, 18 ],
            [ 'space', ' ' ],
            [ '{', '{', 327, 20 ],
            [ 'space', '\n    ' ],
            [ 'word', '--', 328, 5, 328, 6 ],
            [ 'at-word', '@', 328, 7, 328, 7 ],
            [ '{', '{', 328, 8 ],
            [ 'word', 'key', 328, 9, 328, 11 ],
            [ '}', '}', 328, 12 ],
            [ 'word', '-color', 328, 13, 328, 18 ],
            [ ':', ':', 328, 19 ],
            [ 'space', ' ' ],
            [ 'at-word', '@value', 328, 21, 328, 26 ],
            [ ';', ';', 328, 27 ],
            [ 'space', '\n  ' ],
            [ '}', '}', 329, 3 ],
            [ ')', ')', 329, 4 ],
            [ 'space', '\n' ]
          ]
          

          The logic a few lines down in LessParser.js to parse @each blocks is expecting the latter type of parse tree, not the former. Since the "brackets" part of the erroneous parse tree had Windows line breaks in it, I theorized that might be the problem. Sure enough, converting the file to Unix line breaks resulted in a passing run.

          Basil Crow added a comment - The stack trace is as follows: CssSyntaxError: jenkinsci/jenkins/war/src/main/less/abstracts/theme.less:327:3: Unknown word at Input.error (jenkinsci/jenkins/war/node_modules/postcss-less/node_modules/postcss/lib/input.js:130:16) at LessParser.unknownWord (jenkinsci/jenkins/war/node_modules/postcss-less/node_modules/postcss/lib/parser.js:563:22) at LessParser.unknownWord (jenkinsci/jenkins/war/node_modules/postcss-less/lib/LessParser.js:209:11) at LessParser.other (jenkinsci/jenkins/war/node_modules/postcss-less/node_modules/postcss/lib/parser.js:168:12) at LessParser.other (jenkinsci/jenkins/war/node_modules/postcss-less/lib/LessParser.js:158:13) at LessParser.parse (jenkinsci/jenkins/war/node_modules/postcss-less/node_modules/postcss/lib/parser.js:77:16) at parse (jenkinsci/jenkins/war/node_modules/postcss-less/lib/index.js:11:12) at new LazyResult (jenkinsci/jenkins/war/node_modules/stylelint/node_modules/postcss/lib/lazy-result.js:60:16) at jenkinsci/jenkins/war/node_modules/stylelint/lib/getPostcssResult.js:110:19 at async Promise.all (index 5) Uncommenting https://github.com/shellscape/postcss-less/blob/984f4901aced4b74535d96b04242681d538d628b/lib/LessParser.js#L192= to examine the unknown portion of the parse tree, I see this on Windows: unknown [ [ 'word', 'each', 327, 3, 327, 6 ], [ 'brackets', '(@semantics, {\r\n --@{key}-color: @value;\r\n })', 327, 7, 327, 55 ], [ 'space', '\r\n' ] ] On Linux, I see: unknown [ [ 'word', 'each', 327, 3, 327, 6 ], [ '(', '(', 327, 7 ], [ 'at-word', '@semantics,', 327, 8, 327, 18 ], [ 'space', ' ' ], [ '{', '{', 327, 20 ], [ 'space', '\n ' ], [ 'word', '--', 328, 5, 328, 6 ], [ 'at-word', '@', 328, 7, 328, 7 ], [ '{', '{', 328, 8 ], [ 'word', 'key', 328, 9, 328, 11 ], [ '}', '}', 328, 12 ], [ 'word', '-color', 328, 13, 328, 18 ], [ ':', ':', 328, 19 ], [ 'space', ' ' ], [ 'at-word', '@value', 328, 21, 328, 26 ], [ ';', ';', 328, 27 ], [ 'space', '\n ' ], [ '}', '}', 329, 3 ], [ ')', ')', 329, 4 ], [ 'space', '\n' ] ] The logic a few lines down in LessParser.js to parse @each blocks is expecting the latter type of parse tree, not the former. Since the "brackets" part of the erroneous parse tree had Windows line breaks in it, I theorized that might be the problem. Sure enough, converting the file to Unix line breaks resulted in a passing run.

          Basil Crow added a comment -

          also worth noting is that if I use Dmaven.test.failure.ignore=true then the build at least continues - which explains why it works on windows in ci.jenkins.io. But also shows - something that would seem to be [wrong] - failure to lint should not let the build keep running :/

          I filed JENKINS-68903 to track this work.

          Basil Crow added a comment - also worth noting is that if I use Dmaven.test.failure.ignore=true then the build at least continues - which explains why it works on windows in ci.jenkins.io. But also shows - something that would seem to be [wrong] - failure to lint should not let the build keep running : / I filed JENKINS-68903 to track this work.

            basil Basil Crow
            teilo James Nord
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: