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

GitHub Actions failing at installation of Node.js #309

Closed PhilippImhof closed 2 weeks ago

PhilippImhof commented 1 month ago

A few days ago, some of my CI checks randomly failed at the install moodle-plugin-ci step. After a few retries, all checks finally passed. In the meantime, things have become worse. Currently, all checks are constantly failing. Some other developers reported the same in the dev chat.

 0/9 [>---------------------------]   0% < 1 sec [Starting install]
 2/9 [======>---------------------]  22% 15 secs [Moodle assets]
 3/9 [=========>------------------]  33% 15 secs [Install plugins]
 4/9 [============>---------------]  44% 16 secs [Installing Node.js]
In VendorInstaller.php line [12](https://github.com/PhilippImhof/moodle-quiz_essaydownload/actions/runs/10297980501/job/28511977093#step:6:13)9:

  Node.js installation failed.  

install [--moodle MOODLE] [--data DATA] [--repo REPO] [--branch BRANCH] [--plugin PLUGIN] [--db-type DB-TYPE] [--db-user DB-USER] [--db-pass DB-PASS] [--db-name DB-NAME] [--db-host DB-HOST] [--db-port DB-PORT] [--not-paths NOT-PATHS] [--not-names NOT-NAMES] [--extra-plugins EXTRA-PLUGINS] [--no-init] [--no-plugin-node] [--node-version NODE-VERSION]
Error: Process completed with exit code 1.
kabalin commented 1 month ago

Test run on main branch fails too. Latest release of ubuntu-22.04 bumped nvm to 0.40.0. Looks to me as related https://github.com/nvm-sh/nvm/issues/3405.

jrchamp commented 1 month ago

Maybe actions/setup-node is a more reliable way to install Node.js?

stronk7 commented 1 month ago

Coincidentally I arrived to this issue, worth checking it. It seems that some incompatibility between nvm (that we use to install the target nodejs version) and GitHub actions may be the root of the problem: https://github.com/nvm-sh/nvm/issues/3405

A fix is being worked on, based on the last comments there…

stronk7 commented 1 month ago

Ah, @kabalin , just saw your comment now! Snap!

kabalin commented 1 month ago

A fix is being worked on, based on the last comments there…

Yeah, runner-images would need to be updated too following the fix in nvm, will take time. Temporary workaround is to install nvm 0.39.7 explicitly like at #310.

kabalin commented 4 weeks ago

Just to note, if we go for GH Action #303 (#53), this could be easily fixed for everyone without need to add workaround to individual workflows.

Ghostscypher commented 4 weeks ago

Solved mine temporarily by adding the following before Install moodle-plugin-ci step

      - name: Install NVM and Node
        run: |
          curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
          export NVM_DIR="$HOME/.nvm"
          [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
          nvm install 20
          nvm use 20

Just a temporary fix before this plugin is updated

kabalin commented 4 weeks ago

Just a temporary fix before this plugin is updated

So, you are installing version 20 explicitly, can you share the workflow? I would expect install step to fail as it only bypass node installation if NVM_DIR is undefined. Installing v0.40.0 is not necessary, it is already of that version in ubuntu-22.04 image we use (which actually cause of regression).

The easiest workaround for now is described in #310, a one-liner fix to downgrade nvm.

ljharb commented 4 weeks ago

set +e is a much easier workaround than downgrading nvm, fwiw.

kabalin commented 4 weeks ago

set +e is a much easier workaround than downgrading nvm, fwiw.

Hmm, does not seem have effect (unless I am using it wrong way) https://github.com/kabalin/moodle-plugin-ci/actions/runs/10384715590/job/28752387566#step:6:168

ljharb commented 3 weeks ago

You're using it correctly afaict (altho . /home/runner/.nvm/nvm.sh && nvm install && nvm use can just be . /home/runner/.nvm/nvm.sh --install), but I only see a moodle error and not the actual result of running that command?

kabalin commented 3 weeks ago

See https://github.com/moodlehq/moodle-plugin-ci/pull/310#issuecomment-2297629714 for suggestion to make this nvm installation permanent part of workflow.

kabalin commented 2 weeks ago

We fixed this in 4.5.4 release, those who added temporary workaround can safely remove it. Sorry for delaying the fix and thanks for your patience :)

jrchamp commented 2 weeks ago

@kabalin Thank you so much! Can a similar fix be applied to the 3.x branch? We still do some testing against older versions which do not work with 4.x

kabalin commented 1 week ago

@kabalin Thank you so much! Can a similar fix be applied to the 3.x branch? We still do some testing against older versions which do not work with 4.x

Yep, the fix has been released for 3.x too.

ljharb commented 1 week ago

fwiw v0.40.1 of nvm has been released, which should fix this issue.