|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: Upgrading from 2.X to 3.0 |
| 4 | +--- |
| 5 | + |
| 6 | +This document outlines the steps one should take when upgrading to the new major version. |
| 7 | + |
| 8 | +## Step 1: Review the new requirements |
| 9 | + |
| 10 | +Requirements have changed, this project now requires PHP 7.0 or later and Moodle 3.2 or later. |
| 11 | + |
| 12 | +## Step 2: Review the change log |
| 13 | + |
| 14 | +Detailed information about what changed in Version 3 can be found in the [change log](CHANGELOG.md). |
| 15 | + |
| 16 | +## Step 3: Review the Travis CI configuration file |
| 17 | + |
| 18 | +Review the updated [.travis.dist.yml](https://github.com/moodlehq/moodle-plugin-ci/blob/master/.travis.dist.yml) |
| 19 | +and update your `.travis.yml` file in your plugin. For detailed information about the contents of `.travis.dist.yml` |
| 20 | +file, please see this [help document](TravisFileExplained.md). **Please carefully** review the updated |
| 21 | +`.travis.dist.yml` as some steps have been removed and others added, like installation of Java 8, |
| 22 | +upgrade of NodeJS, etc. |
| 23 | + |
| 24 | +A summary of the actions required may be: |
| 25 | + |
| 26 | +1. Move to `moodlehq/moodle-plugin-ci` and bump to version 3 (^3). |
| 27 | +2. Ensure that the `docker` service is available. |
| 28 | +3. Remove any use of selenium or browsers, now they are handled automatically using docker images. |
| 29 | +4. Remove any use of manual `nvm`, `node` or `npm` stuff (unless it's to install components specific for your plugin). Now that's handled automatically too. |
| 30 | + |
| 31 | +Note: Still, it's possible to configure the `node` version to be used, in case you want to experiment or have any exact need for a given plugin or branch. This is how it works, in order of precedence, fall-backing to next: |
| 32 | + |
| 33 | +1. `--node-version` (install option). |
| 34 | +2. `NODE_VERSION` (env variable). |
| 35 | +3. `.nvmrc` (file present since Moodle 3.5). |
| 36 | +4. `lts/carbon` (last resort, default/legacy before Moodle 3.5). |
| 37 | + |
| 38 | +## FAQ |
| 39 | + |
| 40 | +### What is happening to Version 2? |
| 41 | + |
| 42 | +Version 2 still exists as its last release [2.5.0](https://github.com/moodlehq/moodle-plugin-ci/tree/2.5.0). You can continue |
| 43 | +to use it, but it is no longer getting new features and may not receive additional updates. In addition, it may start breaking in Moodle 3.10 or later. |
| 44 | + |
| 45 | +### Why Version 3? |
| 46 | + |
| 47 | +Mainly to clearly separate development from the original [moodle-plugin-ci](https://github.com/blackboard-open-source/moodle-plugin-ci) as explained [here](https://github.com/moodlehq/moodle-plugin-ci#history-acknowledgement-and-appreciation). Also because, since **Moodle 3.5** we have a better way to control different node/npm versions using [nvm](https://github.com/nvm-sh/nvm) automatically. Finally because we wanted to leave PHP 5.x behind once and forever and this was a good moment to force the jump to **PHP 7**. |
| 48 | + |
| 49 | +### Can I run Version 1 and 3? |
| 50 | + |
| 51 | +If your plugin uses a single Git branch, but still works on Moodle versions older than 3.2, then you might be wanting |
| 52 | +to try to use both versions in a single `.travis.yml` file. First, this is not recommended due to its complexity. |
| 53 | +The preferred method is to use separate branches so your `.travis.yml` file is only using one version or another. |
| 54 | +If that is not desirable, then one could go about it by using environment variables. First, be sure that you update |
| 55 | +your `.travis.yml` file as explained above. Then a rough and **untested** example might be: |
| 56 | + |
| 57 | +```yaml |
| 58 | +# WARNING - this is only a partial example, several steps were excluded to keep it simple! |
| 59 | + |
| 60 | +env: |
| 61 | + # Define a V3 flag to conditionally run commands. |
| 62 | + - MOODLE_BRANCH=MOODLE_31_STABLE DB=pgsql V3=false |
| 63 | + - MOODLE_BRANCH=MOODLE_32_STABLE DB=mysqli V3=true |
| 64 | + |
| 65 | +before_install: |
| 66 | + # You must install the correct version of this project: |
| 67 | + - if [ "$V3" = false ]; then composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^1; fi |
| 68 | + - if [ "$V3" = true ]; then composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3; fi |
| 69 | + |
| 70 | +script: |
| 71 | + # Example of a Version 3 execution: |
| 72 | + - if [ "$V3" = true ]; then ...; fi |
| 73 | + |
| 74 | + # Example of a Version 1 execution: |
| 75 | + - if [ "$V3" = false ]; then ...; fi |
| 76 | + |
| 77 | + # And of course some exist in both versions, so just call it normally: |
| 78 | + - moodle-plugin-ci phpunit |
| 79 | +``` |
0 commit comments