-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support and document usage with the Moodle App
- Loading branch information
1 parent
1de4152
commit 0dd3ad6
Showing
10 changed files
with
263 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
language: php | ||
|
||
addons: | ||
postgresql: "10" | ||
|
||
services: | ||
- mysql | ||
- postgresql | ||
- docker | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/.npm | ||
|
||
php: | ||
- 7.3 | ||
- 7.4 | ||
- 8.0 | ||
|
||
env: | ||
global: | ||
- MOODLE_BRANCH=MOODLE_311_STABLE | ||
- MOODLE_BEHAT_IONIC_WWWROOT=http://localhost:8100 | ||
- MOODLE_BEHAT_DEFAULT_BROWSER=chrome | ||
matrix: | ||
- DB=pgsql | ||
- DB=mysqli | ||
|
||
before_install: | ||
- if [[ ${TRAVIS_PHP_VERSION:0:1} -gt 7 ]]; then pecl install xmlrpc-beta; fi | ||
- echo 'max_input_vars=5000' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
# Don't disable xdebug if you want to get it used for code coverage. | ||
- phpenv config-rm xdebug.ini | ||
# Alternative (for Moodle 3.10 and up) is to use pcov. It can be installed using: | ||
# - pecl install pcov | ||
- cd ../.. | ||
- composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 | ||
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" | ||
- docker run -d -p 8100:80 moodlehq/moodleapp:next-test | ||
- moodle-plugin-ci add-plugin moodlehq/moodle-local_moodleappbehat --branch integration | ||
|
||
install: | ||
- moodle-plugin-ci install | ||
|
||
script: | ||
- moodle-plugin-ci phplint | ||
- moodle-plugin-ci phpcpd | ||
- moodle-plugin-ci phpmd | ||
- moodle-plugin-ci codechecker | ||
- moodle-plugin-ci validate | ||
- moodle-plugin-ci savepoints | ||
- moodle-plugin-ci mustache | ||
- moodle-plugin-ci grunt | ||
- moodle-plugin-ci phpdoc --fail-on-warning | ||
- moodle-plugin-ci phpunit | ||
- moodle-plugin-ci behat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
layout: page | ||
title: Moodle App | ||
--- | ||
|
||
In order to test plugins with mobile support, the only command that needs a special configuration is Behat. In particular, you need the following: | ||
|
||
- The Moodle App should be available during Behat runs and initialisation. One easy way to achieve this is using the [Moodle App Docker images](https://moodledev.io/docs/moodleapp/development/setup/docker-images), but you can configure it using a different approach if you prefer. What's important is that the app is reachable by the Behat scripts, and also make sure that it's running in the `test` environment so that the testing JavaScript in the app is available. | ||
- Related with the previous point, the Moodle instance needs to know where the app running. This can be configured using the `MOODLE_BEHAT_IONIC_WWWROOT` env variable during the `moodle-plugin-ci install` call. | ||
- The default browser in behat profiles must be `chrome`, or app scenarios will be ignored. This can also be configured using an env variable, called `MOODLE_BEHAT_DEFAULT_BROWSER`, during the `moodle-plugin-ci install` call. Be aware that using this variable will change the default browser, which is Firefox. If you still want to use Firefox for tests that are unrelated to the app, you can do so by running `moodle-plugin-ci behat --profile firefox`. | ||
- Finally, you need to install the [local_moodleappbehat](https://github.com/moodlehq/moodle-local_moodleappbehat) plugin; you can do this with the `add-plugin` command before running `install`. This plugin defines some Behat steps specifics to the app, if you want to learn more check out [Acceptance testing for the Moodle App](https://moodledev.io/docs/moodleapp/development/testing/acceptance-testing). | ||
|
||
For a complete example using these settings, you can look at the [.travis-app.dist.yml](https://github.com/moodlehq/moodle-plugin-ci/blob/master/.travis-app.dist.yml) or [gha-app.dist.yml](https://github.com/moodlehq/moodle-plugin-ci/blob/master/gha-app.dist.yml) files. You can look at the sections below to see how they differ from the originals. | ||
|
||
**Important:** Please notice that the configuration below only works with the development of the Moodle App and will be available in stable versions starting with the 4.1 release. If you want to use this setup against older versions, the same principles still apply but you'll need to tweak a couple of settings. In particular, you should be using the [local_moodlemobileapp](https://github.com/moodlehq/moodle-local_moodlemobileapp/) plugin instead and relying on stable tags in Docker images (for example, `latest-test`). | ||
|
||
## Github Actions | ||
|
||
```yaml | ||
# Add the moodlehq/moodleapp Docker image using the -test environment under services. | ||
moodleapp: | ||
image: moodlehq/moodleapp:next-test | ||
ports: | ||
- 8100:80 | ||
|
||
# Add the local_moodleappbehat plugin before running the install step. | ||
- name: Add local_moodleappbehat | ||
run: moodle-plugin-ci add-plugin moodlehq/moodle-local_moodleappbehat --branch integration | ||
|
||
# Add a couple of environment variables in the install step. | ||
MOODLE_BEHAT_IONIC_WWWROOT: http://localhost:8100 | ||
MOODLE_BEHAT_DEFAULT_BROWSER: chrome | ||
``` | ||
## Travis | ||
```yaml | ||
# Add a couple of global environment variables. | ||
- MOODLE_BEHAT_IONIC_WWWROOT=http://localhost:8100 | ||
- MOODLE_BEHAT_DEFAULT_BROWSER=chrome | ||
|
||
# Start a moodlehq/moodleapp Docker container using the -test environment, and add the local_moodleappbehat plugin, before install. | ||
- docker run -d -p 8100:80 moodlehq/moodleapp:next-test | ||
- moodle-plugin-ci add-plugin moodlehq/moodle-local_moodleappbehat --branch integration | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
name: Moodle Plugin CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-18.04 | ||
|
||
services: | ||
postgres: | ||
image: postgres:10 | ||
env: | ||
POSTGRES_USER: 'postgres' | ||
POSTGRES_HOST_AUTH_METHOD: 'trust' | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 | ||
mariadb: | ||
image: mariadb:10 | ||
env: | ||
MYSQL_USER: 'root' | ||
MYSQL_ALLOW_EMPTY_PASSWORD: "true" | ||
MYSQL_CHARACTER_SET_SERVER: "utf8mb4" | ||
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 | ||
moodleapp: | ||
image: moodlehq/moodleapp:next-test | ||
ports: | ||
- 8100:80 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ['7.3', '7.4', '8.0'] | ||
moodle-branch: ['MOODLE_311_STABLE'] | ||
database: [pgsql, mariadb] | ||
|
||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v2 | ||
with: | ||
path: plugin | ||
|
||
- name: Setup PHP ${{ matrix.php }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: ${{ matrix.extensions }} | ||
ini-values: max_input_vars=5000 | ||
# none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead. | ||
coverage: none | ||
|
||
- name: Initialise moodle-plugin-ci | ||
run: | | ||
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 | ||
echo $(cd ci/bin; pwd) >> $GITHUB_PATH | ||
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH | ||
sudo locale-gen en_AU.UTF-8 | ||
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV | ||
- name: Add local_moodleappbehat | ||
run: moodle-plugin-ci add-plugin moodlehq/moodle-local_moodleappbehat --branch integration | ||
|
||
- name: Install moodle-plugin-ci | ||
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 | ||
env: | ||
DB: ${{ matrix.database }} | ||
MOODLE_BRANCH: ${{ matrix.moodle-branch }} | ||
MOODLE_BEHAT_IONIC_WWWROOT: http://localhost:8100 | ||
MOODLE_BEHAT_DEFAULT_BROWSER: chrome | ||
|
||
- name: PHP Lint | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci phplint | ||
|
||
- name: PHP Copy/Paste Detector | ||
continue-on-error: true # This step will show errors but will not fail | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci phpcpd | ||
|
||
- name: PHP Mess Detector | ||
continue-on-error: true # This step will show errors but will not fail | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci phpmd | ||
|
||
- name: Moodle Code Checker | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci codechecker --max-warnings 0 | ||
|
||
- name: Moodle PHPDoc Checker | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci phpdoc | ||
|
||
- name: Validating | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci validate | ||
|
||
- name: Check upgrade savepoints | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci savepoints | ||
|
||
- name: Mustache Lint | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci mustache | ||
|
||
- name: Grunt | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci grunt --max-lint-warnings 0 | ||
|
||
- name: PHPUnit tests | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci phpunit --fail-on-warning | ||
|
||
- name: Behat features | ||
if: ${{ always() }} | ||
run: moodle-plugin-ci behat --profile chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters