moodlehq / moodle-plugin-ci

Helps running Moodle plugins analysis checks and tests under various CI environments.
https://moodlehq.github.io/moodle-plugin-ci/
GNU General Public License v3.0
44 stars 45 forks source link

Presence of .scss file in a plugin makes moodle-plugin-ci grunt command to fail #314

Open marinaglancy opened 2 weeks ago

marinaglancy commented 2 weeks ago

We have a plugin that has a .scss file that we just store there together with a script that compiles to .css

On moodle-plugin-ci 4.5.4 the 'grunt' command fails:

Run moodle-plugin-ci grunt --max-lint-warnings 0
 RUN  Grunt on block_rbreport
Running "gherkinlint" task
Done.
>> Running tasks for component directory blocks/rbreport
Running "stylelint:css" (stylelint) task
>> Linted 1 files without errors
Done.
>> Running tasks for component directory blocks/rbreport
Running "stylelint:scss" (stylelint) task
Verifying property stylelint.scss exists in config...ERROR
>> Unable to process task.
Warning: Required config property "stylelint.scss" missing. Use --force to continue.
Aborted due to warnings.
Error: Process completed with exit code 1.

This was not failing on moodle-plugin-ci 4.5.0

marinaglancy commented 2 weeks ago

This is the plugin itself: https://github.com/moodleworkplace/moodle-block_rbreport

For now we are adding a workaround - the file .moodle-plugin-ci.yml with the contents:

filter:
  notPaths:
    - scss
kabalin commented 2 weeks ago

Hm, this is likely caused by #278 (included in 4.5.1)

kabalin commented 5 days ago

The fundamental issue is that we do not expect scss/ directory to present in non-theme plugins when calling grunt stylelint:scss, so it is not added to gruntfile config.

This issue can be replicated by calling stylelint:scss on block_rbreport repo, you will get the same error:

1055 rbreport:MOODLE_402_STABLE> npx grunt stylelint:scss
>> Running tasks for component directory blocks/rbreport

Running "stylelint:scss" (stylelint) task
Verifying property stylelint.scss exists in config...ERROR
>> Unable to process task.
Warning: Required config property "stylelint.scss" missing. Use --force to continue.

Aborted due to warnings.

The solution is not to use explicit stylelint:scss in grunt command, instead call stylelint and let grunt task logic to decide type of stylelint to run. We still need support for cases when someone pass --task stylelint:scss though, it would make sense to check that we are dealing with theme plugin, or just pass to Moodle core grunt task to decide.

Patch will follow.