Skip to content

Commit c88d592

Browse files
author
David Castro
authored
Merge pull request #107 from moodleworkplace/fix-behat
Replace Selenium in-built functionality with docker image for Selenium (and Moodle 3.8)
2 parents f699dd1 + ad5d673 commit c88d592

File tree

13 files changed

+50
-172
lines changed

13 files changed

+50
-172
lines changed

.travis.dist.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
language: php
22

3-
sudo: true
4-
53
addons:
6-
firefox: "47.0.1"
74
postgresql: "9.4"
85

96
services:
107
- mysql
118
- postgresql
9+
- docker
1210

1311
cache:
1412
directories:
1513
- $HOME/.composer/cache
1614
- $HOME/.npm
1715

1816
php:
19-
- 7.0
2017
- 7.1
18+
- 7.2
19+
- 7.3
2120

2221
env:
2322
global:
24-
- MOODLE_BRANCH=MOODLE_35_STABLE
23+
- MOODLE_BRANCH=MOODLE_38_STABLE
2524
matrix:
2625
- DB=pgsql
2726
- DB=mysqli
@@ -33,6 +32,7 @@ before_install:
3332
- cd ../..
3433
- composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci ^2
3534
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
35+
- docker run -d -p 127.0.0.1:4444:4444 --net=host -v /dev/shm:/dev/shm selenium/standalone-firefox:3
3636

3737
install:
3838
- moodle-plugin-ci install

.travis.yml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
language: php
22

3-
# Behat no longer passes when false.
4-
sudo: true
5-
63
addons:
7-
firefox: "47.0.1"
8-
postgresql: "9.4"
9-
apt:
10-
packages:
11-
- chromium-chromedriver
4+
postgresql: "9.5"
125

136
services:
147
- mysql
158
- postgresql
9+
- docker
1610

1711
cache:
1812
directories:
@@ -36,7 +30,8 @@ install:
3630
- nvm install 8.9
3731
- nvm use 8.9
3832
- make init
39-
33+
# Start Selenium Standalone with Chrome/Firefox installed.
34+
- docker run -d -p 127.0.0.1:4444:4444 --net=host -v /dev/shm:/dev/shm selenium/standalone-${PROFILE}:3
4035
# Mimic how a Moodle plugin would be run.
4136
- cp -R tests/Fixture/moodle-local_travis ../moodle-local_travis
4237
- export PATH="$(cd bin; pwd):$(cd vendor/bin; pwd):$PATH"
@@ -56,7 +51,7 @@ script:
5651
- moodle-plugin-ci validate
5752
- moodle-plugin-ci savepoints
5853
- moodle-plugin-ci mustache
59-
- moodle-plugin-ci grunt
54+
- moodle-plugin-ci grunt || [ "$MOODLE_BRANCH" != 'master' -a "$MOODLE_BRANCH" != 'MOODLE_38_STABLE' ]
6055
- moodle-plugin-ci phpdoc
6156
- moodle-plugin-ci phpunit --coverage-text
6257
- moodle-plugin-ci behat --profile $PROFILE
@@ -72,20 +67,13 @@ jobs:
7267
- make validate
7368
- stage: Integration tests
7469
- php: 7.3
70+
env: MOODLE_BRANCH=MOODLE_38_STABLE
71+
- php: 7.3
72+
env: MOODLE_BRANCH=MOODLE_37_STABLE
73+
- php: 7.2
7574
env: MOODLE_BRANCH=MOODLE_36_STABLE
7675
- php: 7.2
7776
env: MOODLE_BRANCH=MOODLE_35_STABLE
78-
- php: 7.1
79-
env: MOODLE_BRANCH=MOODLE_34_STABLE
80-
- php: 7.0
81-
env: MOODLE_BRANCH=MOODLE_33_STABLE DB=mariadb
82-
addons:
83-
mariadb: 10.2
84-
apt:
85-
packages:
86-
- chromium-chromedriver
87-
- php: 5.6
88-
env: MOODLE_BRANCH=MOODLE_32_STABLE DB=mysqli PROFILE=default
8977
- stage: Deploy
9078
addons: skip
9179
install: skip

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
1515
[#91](https://github.com/blackboard-open-source/moodle-plugin-ci/issues/91).
1616
- Updated verion of `moodlehq/moodle-local_ci` to fix Mustache linting. See
1717
[#91](https://github.com/blackboard-open-source/moodle-plugin-ci/issues/91).
18+
- Updated [.travis.dist.yml] to build Moodle 3.8: removed PHP 7.0 and added
19+
7.2 and 7.3 (per release notes).
20+
- Replaced Selenium in-built functionality with docker image for Selenium
21+
Standalone server. See [#99](https://github.com/blackboard-open-source/moodle-plugin-ci/issues/99).
1822

1923
### Added
2024
- New help document: [CLI commands and options](CLI.md)

docs/CLI.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Run Behat on a plugin
240240

241241
### Usage
242242

243-
* `behat [-m|--moodle MOODLE] [-p|--profile PROFILE] [--suite SUITE] [--start-servers] [--jar JAR] [--auto-rerun AUTO-RERUN] [--dump] [--] <plugin>`
243+
* `behat [-m|--moodle MOODLE] [-p|--profile PROFILE] [--suite SUITE] [--start-servers] [--auto-rerun AUTO-RERUN] [--dump] [--] <plugin>`
244244

245245
Run Behat on a plugin
246246

@@ -285,22 +285,13 @@ Behat suite to use (Moodle theme)
285285

286286
#### `--start-servers`
287287

288-
Start Selenium and PHP servers
288+
Start PHP server
289289

290290
* Accept value: no
291291
* Is value required: no
292292
* Is multiple: no
293293
* Default: `false`
294294

295-
#### `--jar`
296-
297-
Path to Selenium Jar file
298-
299-
* Accept value: yes
300-
* Is value required: yes
301-
* Is multiple: no
302-
* Default: `NULL`
303-
304295
#### `--auto-rerun`
305296

306297
Number of times to rerun failures
@@ -1993,4 +1984,4 @@ Do not ask any interactive question
19931984
* Accept value: no
19941985
* Is value required: no
19951986
* Is multiple: no
1996-
* Default: `false`
1987+
* Default: `false`

docs/Chrome.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/Help.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ changed. Also a good place to look for new goodies.
1414
* [Add extra Moodle configs](AddExtraConfig.md): how to add extra configs to Moodle `config.php`.
1515
* [Add extra plugins](AddExtraPlugins.md): how to add plugin dependencies to Moodle.
1616
* [Ignoring files](IgnoringFiles.md): how to ignore files that might be causing failures.
17-
* [Using Chrome with Behat](Chrome.md): how to use Chrome instead of Firefox for Behat.
1817
* [Generating code coverage](CodeCoverage.md): how to generate code coverage of your plugin.
1918
* [CLI commands and options](CLI.md): the available `moodle-plugin-ci` commands and their options.
2019

docs/TravisFileExplained.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@ see [Travis CI's documentation](http://docs.travis-ci.com/user/getting-started/)
1111
# This is the language of our project.
1212
language: php
1313

14-
# If using Behat, then this should be true due to an issue with Travis CI.
15-
# If not using Behat, recommended to use `sudo: false` as it is faster.
16-
sudo: true
17-
18-
# Installs the required version of Firefox for Behat, an updated version
19-
# of PostgreSQL and extra APT packages.
14+
# Installs the updated version of PostgreSQL and extra APT packages.
2015
addons:
21-
firefox: "47.0.1"
2216
postgresql: "9.4"
2317

2418
# Ensure DB services are running.
@@ -36,19 +30,20 @@ cache:
3630
# listed here will create a separate build and run the tests against that
3731
# version of PHP.
3832
php:
39-
- 7.0
4033
- 7.1
34+
- 7.2
35+
- 7.3
4136

4237
# This section sets up the environment variables for the build.
4338
env:
4439
global:
4540
# This line determines which version branch of Moodle to test against.
46-
- MOODLE_BRANCH=MOODLE_35_STABLE
41+
- MOODLE_BRANCH=MOODLE_38_STABLE
4742
# This matrix is used for testing against multiple databases. So for
4843
# each version of PHP being tested, one build will be created for each
49-
# database listed here. EG: for PHP 5.6, one build will be created
50-
# using PHP 5.6 and pgsql. In addition, another build will be created
51-
# using PHP 5.6 and mysqli.
44+
# database listed here. EG: for PHP 7.1, one build will be created
45+
# using PHP 7.1 and pgsql. In addition, another build will be created
46+
# using PHP 7.1 and mysqli.
5247
matrix:
5348
- DB=pgsql
5449
- DB=mysqli
@@ -57,7 +52,7 @@ env:
5752
# (git://github.com/moodle/moodle.git is used by default):
5853
# - MOODLE_REPO=git://github.com/username/moodle.git
5954

60-
# This lists steps that are run before the installation step.
55+
# This lists steps that are run before the installation step.
6156
before_install:
6257
# This disables XDebug which should speed up the build.
6358
- phpenv config-rm xdebug.ini
@@ -71,6 +66,10 @@ before_install:
7166
- composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci ^2
7267
# Update the $PATH so scripts from this project can be called easily.
7368
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
69+
# Start Selenium Standalone server with Chrome/Firefox installed. If you
70+
# prefer to run Behat tests with Chrome profile (see Behat step details below),
71+
# use selenium/standalone-chrome:3 image instead.
72+
- docker run -d -p 127.0.0.1:4444:4444 --net=host -v /dev/shm:/dev/shm selenium/standalone-firefox:3
7473

7574
# This lists steps that are run for installation and setup.
7675
install:
@@ -115,19 +114,23 @@ script:
115114
# This step runs Grunt tasks on the plugin. By default, it tries to run
116115
# tasks relevant to your plugin and Moodle version, but you can run
117116
# specific tasks by passing them as options,
118-
# EG: moodle-plugin-ci grunt -t task1 -t task2
117+
# EG: moodle-plugin-ci grunt -t task1 -t task2
119118
- moodle-plugin-ci grunt
120119
# This step runs the PHPUnit tests of your plugin. If your plugin has
121120
# PHPUnit tests, then it is highly recommended that you keep this step.
122121
- moodle-plugin-ci phpunit
123122
# This step runs the Behat tests of your plugin. If your plugin has
124123
# Behat tests, then it is highly recommended that you keep this step.
125-
# There are two important options that you may want to use:
124+
# There are few important options that you may want to use:
126125
# - The auto rerun option allows you to rerun failures X number of times,
127126
# default is 2, EG usage: --auto-rerun 3
128127
# - The dump option allows you to print the failure HTML to the console,
129128
# handy for debugging, EG usage: --dump
130129
# - The suite option allows you to set the theme to use for behat test. If
131130
# not specified, the default theme is used, EG usage: --suite boost
131+
# - The profile option allows you to set the browser driver to use,
132+
# default is Firefox. If you need Chrome, set '--profile chrome' and make
133+
# sure that you are using correct Selenium server docker image in
134+
# before_install section above.
132135
- moodle-plugin-ci behat
133136
```

res/template/config.php.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ $CFG->behat_faildump_path = '{{BEHATDUMP}}';
3939
$CFG->behat_profiles = [
4040
'default' => [
4141
'browser' => 'firefox',
42-
'wd_host' => 'http://localhost:4444/wd/hub',
42+
'wd_host' => '{{BEHATWDHOST}}',
4343
],
4444
'chrome' => [
4545
'browser' => 'chrome',
46-
'wd_host' => 'http://localhost:4444/wd/hub',
46+
'wd_host' => '{{BEHATWDHOST}}',
4747
],
4848
];
4949

src/Bridge/MoodleConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public function createContents(AbstractDatabase $database, $dataDir)
4545
'{{PHPUNITDATAROOT}}' => $dataDir.'/phpu_moodledata',
4646
'{{BEHATDATAROOT}}' => $dataDir.'/behat_moodledata',
4747
'{{BEHATDUMP}}' => $dataDir.'/behat_dump',
48-
'{{BEHATWWWROOT}}' => 'http://localhost:8000',
48+
'{{BEHATWWWROOT}}' => getenv('MOODLE_BEHAT_WWWROOT') ?: 'http://localhost:8000',
49+
'{{BEHATWDHOST}}' => getenv('MOODLE_BEHAT_WDHOST') ?: 'http://localhost:4444/wd/hub',
4950
'{{EXTRACONFIG}}' => self::PLACEHOLDER,
5051
];
5152

0 commit comments

Comments
 (0)