Skip to content

Commit

Permalink
Use .nvmrc for picking the right version of npm.
Browse files Browse the repository at this point in the history
This closes #7
  • Loading branch information
kabalin committed Jul 17, 2020
1 parent 9f98b64 commit e7dd891
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 42 deletions.
2 changes: 0 additions & 2 deletions .travis.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ env:

before_install:
- phpenv config-rm xdebug.ini
- nvm install 14.0.0
- nvm use 14.0.0
- cd ../..
- composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^2
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
Expand Down
37 changes: 1 addition & 36 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ env:

before_install:
- phpenv config-rm xdebug.ini
- nvm install 14.0.0
- nvm use 14.0.0
- make init
# Mimic how a Moodle plugin would be run.
- cp -R tests/Fixture/moodle-local_travis ../moodle-local_travis
- export PATH="$(cd bin; pwd):$(cd vendor/bin; pwd):$PATH"
- export TRAVIS_BUILD_DIR=$(cd ../moodle-local_travis; pwd)

install:
- moodle-plugin-ci install
- moodle-plugin-ci install -vvv

script:
- make test-phpunit
Expand All @@ -54,36 +52,3 @@ script:
- moodle-plugin-ci behat --profile default
- moodle-plugin-ci behat --profile chrome

jobs:
include:
- stage: Tests
php: 7.3
before_install: skip
install:
- make init
script:
- make validate
- stage: Integration tests
- php: 7.3
env: MOODLE_BRANCH=MOODLE_39_STABLE
- php: 7.3
env: MOODLE_BRANCH=MOODLE_38_STABLE
- php: 7.3
env: MOODLE_BRANCH=MOODLE_37_STABLE
- php: 7.2
env: MOODLE_BRANCH=MOODLE_35_STABLE
- stage: Deploy
before_install: skip
install: skip
script: skip
before_deploy:
- make build/moodle-plugin-ci.phar
- php build/moodle-plugin-ci.phar list
deploy:
provider: releases
token: $GITHUB_OAUTH_ENCRYPTED_TOKEN
file: build/moodle-plugin-ci.phar
cleanup: false
on:
repo: moodlehq/moodle-plugin-ci
tags: true
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
this is no longer required, you can remove this step.
- Updated version of `moodlehq/moodle-local_codechecker` to v2.9.6
- Updated [.travis.dist.yml] to build Moodle 3.9
- `moodle-plugin-ci install` installs nvm according to .nvmrc file. See [#7](https://github.com/moodlehq/moodle-plugin-ci/issues/7)
- ACTION REQUIRED: You may safely remove `nvm install <version>` and `nvm use
<version>` from .travis.yml, this is now a part of installation routine.
- Updated [.travis.dist.yml] to use nvm 14.0.0

### Added
Expand Down
4 changes: 0 additions & 4 deletions docs/TravisFileExplained.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ env:
before_install:
# This disables XDebug which should speed up the build.
- phpenv config-rm xdebug.ini
# This installs NodeJS which is used by Grunt, adjust according to `.nvmrc` file
# in your Moodle installation.
- nvm install 14.0.0
- nvm use 14.0.0
# Currently we are inside of the clone of your repository. We move up two
# directories to build the project.
- cd ../..
Expand Down
7 changes: 7 additions & 0 deletions src/Installer/MoodleInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ public function install()
$this->execute->mustRun($process);
}

// If .nvmrc exists, use the right version of npm.
if (is_file($this->moodle->directory.'/.nvmrc') && $nvmDir = getenv('NVM_DIR')) {
$process = new Process("bash -c 'source $nvmDir/nvm.sh' && . $nvmDir/nvm.sh && nvm install && nvm use", $this->moodle->directory);
$process->setTimeout(null);
$this->execute->mustRun($process);
}

$this->getOutput()->step('Moodle assets');

$this->getOutput()->debug('Creating Moodle data directories');
Expand Down

0 comments on commit e7dd891

Please sign in to comment.