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
41 stars 43 forks source link

Add option to avoid installing npm dependencies for a plugin #276

Closed PhMemmel closed 4 months ago

PhMemmel commented 4 months ago

Like in moodle core github repository where the whole node_modules directory already is being included in the git repository, most repositories of moodle plugins are already "deployment ready" which means, all libraries are already part of the git repository.

Currently, moodle-plugin-ci will execute npm install in the plugin directory anywhere as soon as it finds a package.json file. This however might not be necessary in most cases IMO, in some cases you even want to prevent this (reduce pipeline run time, traffic). Also moodle-plugin-ci will not check the current state of the repository but the eventually changed one (in case package.json is not in sync with the node_modules directory).

I suggest a command line option for the installation command which allows to prevent moodle-plugin-ci of executing the npm install for the plugin.

kabalin commented 4 months ago

Hello @PhMemmel,

Like in moodle core github repository where the whole node_modules directory already is being included in the git repository

That is not the case, and it is generally recommended not to do that. We use shrinkwrap to lock dependencies and include npm-shrinkwrap.json in the repo.

If for whatever reason node_modules is already included in plugin, running npm install will be quick. I do not see the benefits of this patch TBH, would be good to hear more opinions.

PhMemmel commented 4 months ago

Hello @kabalin,

thanks for correcting me regarding the inclusion of node_modules directory, I was confused by the fact that whenever I'm working in the sourcecode, it's of course there and there are no git issues because it's in the .gitignore file :)

Let me elaborate on my use case besides that:

So I hope you see that there are use cases in which you do not want moodle-plugin-ci to run npm install for your plugin. I agree with you, that usually it's perfectly fine to run npm install, that's why I used an additional command line switch and not change the default behavior.