diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1a8c706..f76716ec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ on: [push, pull_request, workflow_dispatch] jobs: selftest: name: CI test (make validate) - runs-on: ubuntu-24.04 + runs-on: ubuntu-22.04 steps: - name: Check out repository code @@ -57,8 +57,7 @@ jobs: citest: name: Integration tests - needs: selftest - runs-on: ubuntu-24.04 + runs-on: ubuntu-22.04 services: postgres: @@ -181,7 +180,7 @@ jobs: phartest: name: Integration tests (PHAR) needs: buildphar - runs-on: ubuntu-24.04 + runs-on: ubuntu-22.04 services: postgres: diff --git a/src/Installer/VendorInstaller.php b/src/Installer/VendorInstaller.php index dc89d994..d9147a3a 100644 --- a/src/Installer/VendorInstaller.php +++ b/src/Installer/VendorInstaller.php @@ -15,7 +15,6 @@ use MoodlePluginCI\Bridge\Moodle; use MoodlePluginCI\Bridge\MoodlePlugin; use MoodlePluginCI\Process\Execute; -use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\Process; /** @@ -112,16 +111,19 @@ public function canInstallNvm(): bool */ public function installNvm(): void { - $nvmDir = "{$this->moodle->directory}/.nvm"; - (new Filesystem())->mkdir($nvmDir); - $cmd = "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | NVM_DIR=\"{$nvmDir}\" bash"; + $cmd = 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash'; $process = $this->execute->passThroughProcess( Process::fromShellCommandline($cmd, $this->moodle->directory, null, null, null) ); if (!$process->isSuccessful()) { throw new \RuntimeException('nvm installation failed.'); } - putenv('NVM_DIR=' . $nvmDir); + preg_match('/^export NVM_DIR=(.+)$/m', trim($process->getOutput()), $matches); + if (isset($matches[1]) && is_dir($matches[1])) { + putenv('NVM_DIR=' . $matches[1]); + } else { + $this->getOutput()->debug('Can\'t retrieve NVM_DIR content from the command output.'); + } } /** @@ -155,7 +157,7 @@ public function installNode(): void } $nvmDir = getenv('NVM_DIR'); - $cmd = ". $nvmDir/nvm.sh && nvm install && nvm use && echo \"NVM_BIN=\$NVM_BIN\""; + $cmd = ". {$nvmDir}/nvm.sh && nvm --version"; $process = $this->execute->passThroughProcess( Process::fromShellCommandline($cmd, $this->moodle->directory, null, null, null)