Skip to content

Commit f783423

Browse files
authored
Merge pull request #176 from NoelDeMartin/moodle-app
Support and document usage with the Moodle App
2 parents e1d7ae5 + 2130c06 commit f783423

26 files changed

+335
-33
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ jobs:
8686
moodle-branch: 'MOODLE_400_STABLE'
8787
- php: '8.0'
8888
moodle-branch: 'MOODLE_311_STABLE'
89-
- php: '7.4'
90-
moodle-branch: 'MOODLE_310_STABLE'
9189
- php: '7.4'
9290
moodle-branch: 'MOODLE_39_STABLE'
93-
- php: '7.4'
94-
moodle-branch: 'MOODLE_38_STABLE'
9591

9692
steps:
9793
- name: Check out repository code
@@ -127,6 +123,7 @@ jobs:
127123
IGNORE_PATHS: 'ignore'
128124
IGNORE_NAMES: 'ignore_name.php'
129125
MUSTACHE_IGNORE_NAMES: 'broken.mustache'
126+
MOODLE_APP: 'true'
130127

131128
- name: Run Integration tests
132129
env:
@@ -145,6 +142,7 @@ jobs:
145142
moodle-plugin-ci phpunit --verbose --coverage-text --fail-on-warning
146143
moodle-plugin-ci behat --profile default
147144
moodle-plugin-ci behat --profile chrome
145+
moodle-plugin-ci behat --profile firefox --tags="@local_ci&&~@app"
148146
149147
buildphar:
150148
name: Build moodle-plugin-ci.phar
@@ -240,6 +238,7 @@ jobs:
240238
IGNORE_PATHS: 'ignore'
241239
IGNORE_NAMES: 'ignore_name.php'
242240
MUSTACHE_IGNORE_NAMES: 'broken.mustache'
241+
MOODLE_APP: 'true'
243242

244243
- name: Run Integration tests (PHAR)
245244
env:
@@ -258,3 +257,4 @@ jobs:
258257
php build/moodle-plugin-ci.phar phpunit --verbose --coverage-text --fail-on-warning
259258
php build/moodle-plugin-ci.phar behat --profile default
260259
php build/moodle-plugin-ci.phar behat --profile chrome
260+
php build/moodle-plugin-ci.phar behat --profile firefox --tags="@local_ci&&~@app"

.travis.dist.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ env:
2828
global:
2929
- PGVER=13
3030
- MOODLE_BRANCH=MOODLE_402_STABLE
31+
# Uncomment this to run Behat tests using the Moodle App.
32+
# - MOODLE_APP=true
3133
matrix:
3234
- DB=pgsql
3335
- DB=mysqli

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ before_install:
4646
fi
4747
4848
install:
49-
- moodle-plugin-ci install -vvv
49+
- MOODLE_APP=true moodle-plugin-ci install -vvv
5050

5151
script:
5252
# This is basically "integration" testing.
@@ -63,6 +63,7 @@ script:
6363
- moodle-plugin-ci phpunit --verbose --coverage-text --fail-on-warning
6464
- moodle-plugin-ci behat --profile default
6565
- moodle-plugin-ci behat --profile chrome
66+
- moodle-plugin-ci behat --profile firefox --tags="@local_ci&&~@app"
6667

6768
jobs:
6869
include:
@@ -94,6 +95,6 @@ jobs:
9495
# Last stable with highest supported PHP version.
9596
- php: 8.2
9697
env: MOODLE_BRANCH=MOODLE_402_STABLE
97-
# And oldest stable supported (with lowest supported PHP version).
98+
# And older stable supported (with lowest supported PHP version).
9899
- php: 7.4
99-
env: MOODLE_BRANCH=MOODLE_38_STABLE
100+
env: MOODLE_BRANCH=MOODLE_39_STABLE

docs/CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
2626
To avoid that problem, it's recommended to to add the `libonig5` package to the `travis.yml` file. For a working example, please reference the updated `.travis.dist.yml`file.
2727
- Updated project dependencies to current [moodle-cs](https://github.com/moodlehq/moodle-cs) and [moodle-local_moodlecheck](https://github.com/moodlehq/moodle-local_moodlecheck) versions.
2828

29+
### Added
30+
- Support and document usage with the [Moodle App](MoodleApp.md).
31+
2932
## [4.1.8] - 2023-10-20
3033
### Changed
3134
- Updated project dependencies to current [moodle-cs](https://github.com/moodlehq/moodle-cs) version.
@@ -429,7 +432,7 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
429432

430433
### Fixed
431434
- `moodle-plugin-ci validate` now only regards required language strings as present if they are assigned to the
432-
`$string` array. Before, other array variables were accepted although Moodle would not recognise them.
435+
`$string` array. Before, other array variables were accepted although Moodle would not recognise them.
433436

434437
### Added
435438
- `moodle-plugin-ci install` now provides an option `--no-init` to skip initialization of the Behat and PHPUnit
@@ -468,7 +471,7 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
468471
PHP compatibility issues for the **currently** running PHP version. This makes it important to run this command
469472
on your lowest and highest supported PHP version. EG: on PHP 5.6 and 7.1.
470473
- `moodle-plugin-ci validate` command now validates tags in Behat feature files. EG: mod_forum should have @mod
471-
and @mod_forum tags in each feature file.
474+
and @mod_forum tags in each feature file.
472475
- The `.travis.dist.yml` now installs Version 2 of this tool.
473476
- Updated Moodle coding standard to v2.7.0.
474477

docs/GHAFileExplained.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,16 @@ jobs:
124124
# Other env vars are available for install, namely:
125125
# - DB_USER / DB_PASS / DB_NAME / DB_HOST / DB_PORT: used
126126
# by install to feed the corresponding --db-xxxx options.
127+
# - MOODLE_APP: used to install dependencies to run Behat tests
128+
# using the Moodle App.
127129
- name: Install moodle-plugin-ci
128130
run: |
129131
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
130132
env:
131133
DB: ${{ matrix.database }}
132134
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
135+
# Uncomment this to run Behat tests using the Moodle App.
136+
# MOODLE_APP: 'true'
133137

134138
# Steps that are run for the purpose of testing. Any of these steps
135139
# can be re-ordered or removed to your liking. And of course, you can

docs/Help.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Always a good idea to check the [change log](CHANGELOG.md) if something suddenly
1616
* [Ignoring files](IgnoringFiles.md): how to ignore files that might be causing failures.
1717
* [Generating code coverage](CodeCoverage.md): how to generate code coverage of your plugin.
1818
* [CLI commands and options](CLI.md): the available `moodle-plugin-ci` commands and their options.
19+
* [Moodle App](MoodleApp.md): how to configure `moodle-plugin-ci` to test plugins with mobile support.
1920

2021
## Test steps quick start
2122

@@ -84,7 +85,10 @@ There are few important options that you may want to use:
8485
- The suite option allows you to set the theme to use for behat test. If
8586
not specified, the default theme is used, e.g. usage: `--suite boost`
8687
- The profile option allows you to set the browser driver to use,
87-
default is Firefox. If you need Chrome, set `--profile chrome`.
88+
default is Firefox (or Chrome when `MOODLE_APP` is set). If you need a specific browser,
89+
use `--profile chrome` or `--profile firefox`.
90+
- The tags option allows you to specify which scenarios to run filtered by tags,
91+
default is the tag with the plugin's component name, e.g. usage: `--tags="@local_myplugin~@ciskip"`
8892

8993
## Upgrade guides
9094

docs/MoodleApp.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
layout: page
3+
title: Moodle App
4+
---
5+
6+
In order to test plugins with mobile support, the only command that needs a special configuration is `behat`.
7+
8+
In practice, you only need to set the `MOODLE_APP` env variable to `true`, and all the dependencies will be configured during the `install` command. You can also configure the behaviour of [Acceptance testing for the Moodle App](https://moodledev.io/general/app/development/testing/acceptance-testing) using the following env variables:
9+
10+
- `MOODLE_APP_DOCKER_IMAGE`: Tag of [the Moodle App Docker image](https://moodledev.io/general/app/development/setup/docker-images) to use for running the app. The default value is `moodlehq/moodleapp:latest-test`.
11+
- `MOODLE_APP_BEHAT_PLUGIN_PROJECT`: Project in github to use for installing the plugin with Behat steps specific to the Moodle App. The default value is `moodlehq/moodle-local_moodleappbehat`. This variable will be ignored if `MOODLE_APP_BEHAT_PLUGIN_REPOSITORY` is set.
12+
- `MOODLE_APP_BEHAT_PLUGIN_REPOSITORY`: Repository url to use for installing the plugin with Behat steps specific to the Moodle App. By default, the github repository defined in `MOODLE_APP_BEHAT_PLUGIN_PROJECT` will be used.
13+
- `MOODLE_APP_BEHAT_PLUGIN_BRANCH`: Branch of the repository to use for installing the plugin with Behat steps specific to the Moodle App. The default value is `latest`.
14+
- `MOODLE_BEHAT_IONIC_WWWROOT`: Value to use in `$CFG->behat_ionic_wwwroot`. The default value is `http://localhost:8100`. This value should only be used if `MOODLE_APP` is not set, and the Moodle App dependencies are configured manually.
15+
16+
Finally, keep in mind that mobile tests only run on Chrome, so make sure that you're using the correct browser. If you're setting the `MOODLE_APP` variable, the default browser should already be Chrome; but you can set it explicitly using the `--profile` flag otherwise.
17+
18+
For specific examples, look at the [gha.dist.yml](GHAFileExplained.md) or [.travis.dist.yml](TravisFileExplained.md) files, and uncomment the lines mentioning the app.
19+
20+
**Important:** Please notice that `MOODLE_APP` only works starting with version 4.1 of the app. If you want to use this setup against older versions, you'll have to use `MOODLE_BEHAT_IONIC_WWWROOT` and configure the dependencies manually (installing the plugin, launching the docker image, etc.).

docs/TravisFileExplained.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ env:
5252
- PGVER=13
5353
# This line determines which version branch of Moodle to test against.
5454
- MOODLE_BRANCH=MOODLE_402_STABLE
55+
# Uncomment this to run Behat tests using the Moodle App.
56+
# - MOODLE_APP=true
57+
5558
# This matrix is used for testing against multiple databases. So for
5659
# each version of PHP being tested, one build will be created for each
5760
# database listed here. EG: for PHP 7.4, one build will be created

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Next steps on your continuous build journey may include:
167167
* Reviewing the [help documentation](Help.md) to further improve and customize your build.
168168
* Resolve any build errors you may currently have. Get to that ever rewarding Green Build status.
169169
* Show off your build status by adding the build status badge to your plugin's README file.
170+
* Learn how to [configure CI for your mobile plugins in the Moodle App](MoodleApp.md).
170171
* Write new tests to increase your code coverage.
171172
* Contribute to this repo if you have improvement idea or found an issue.
172173
* Enjoy your favorite beverage because you no longer have to waste time manually testing your plugin!

gha.dist.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ jobs:
5959
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
6060
6161
- name: Install moodle-plugin-ci
62-
run: |
63-
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
62+
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
6463
env:
6564
DB: ${{ matrix.database }}
6665
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
66+
# Uncomment this to run Behat tests using the Moodle App.
67+
# MOODLE_APP: 'true'
6768

6869
- name: PHP Lint
6970
if: ${{ !cancelled() }}

0 commit comments

Comments
 (0)