|
1 | 1 | # This is docker image for running Laravel 5.5 Dusk tests
|
2 | 2 |
|
3 |
| -[](https://hub.docker.com/r/chilio/laravel-dusk-ci) [](https://hub.docker.com/r/chilio/laravel-dusk-ci) [](https://hub.docker.com/r/chilio/laravel-dusk-ci) [](https://github.com/chilio/laravel-dusk-ci/tags) [](https://github.com/chilio/laravel-dusk-ci/issues) [](https://raw.githubusercontent.com/chilio/test-dusk/master/LICENSE) |
| 3 | +[](https://hub.docker.com/r/chilio/laravel-dusk-ci) [](https://hub.docker.com/r/chilio/laravel-dusk-ci) [](https://hub.docker.com/r/chilio/laravel-dusk-ci) [](https://github.com/chilio/laravel-dusk-ci/tags) [](https://github.com/chilio/laravel-dusk-ci/issues) [](https://raw.githubusercontent.com/chilio/laravel-dusk-ci/master/LICENSE) |
4 | 4 |
|
5 |
| -This is **complete** test suite for **Laravel 5.5** with **Dusk browser tests** enabled running on docker. |
| 5 | +This is **complete** test suite for **Laravel 5.5** with **Dusk browser tests** enabled running on docker. |
6 | 6 |
|
7 |
| -You can safely use this for testing purposes in **gitlab environments**, especially gitlab ci runners. |
| 7 | +You can safely use this for testing purposes in **gitlab ci environments**, especially via gitlab ci runners. |
8 | 8 |
|
9 |
| -##### **What's included?** |
| 9 | +### **What's included?** |
10 | 10 |
|
11 | 11 | | FRAMEWORK | VERSION |
|
12 | 12 | | --------- | ------- |
|
13 | 13 | | PHP | 7.1.9.1 |
|
| 14 | +| Xdebug | 2.5.5 | |
14 | 15 | | NGINX | 1.10.3 |
|
15 | 16 | | NODEJS | 6.11.3 |
|
16 | 17 | | NPM | 3.10.10 |
|
17 |
| -| YARN | 1.0.2 | |
18 |
| -| BOWER | 1.8.0 | |
19 |
| -| PHPUNIT | 6.3.0 | |
20 |
| -| NODE-SASS | 4.3.0 | |
| 18 | +| YARN | 1.1.0 | |
| 19 | +| BOWER | 1.8.2 | |
| 20 | +| PHPUNIT | 6.3.1 | |
| 21 | +| NODE-SASS | 4.5.3 | |
21 | 22 | | GULP | 3.9.1 |
|
22 | 23 |
|
23 |
| -##### **Available additional commands:** |
| 24 | +### **Available additional commands:** |
24 | 25 |
|
25 |
| -`start-nginx-ci-project` - configures and starts nginx php-fpm |
| 26 | +`configure-laravel` - sets up file permissions, generates laravel key, migrates and seeds db |
26 | 27 |
|
27 |
| -`configure-laravel` - runs laravel build routines (change path permissions, execute artisan commands) |
| 28 | +`start-nginx-ci-project` - configures and starts nginx with php-fpm |
28 | 29 |
|
29 |
| -##### **Note:** |
| 30 | +### **Databases:** |
30 | 31 |
|
31 |
| -This build is tested with **mysql**, but probably works with other docker db engines |
| 32 | +This build is tested with **mysql**, but also works with other docker db engines |
32 | 33 |
|
33 | 34 | To successfully run mysql add to your test routine:
|
34 | 35 |
|
35 |
| -services: |
| 36 | +`services:` |
36 | 37 |
|
37 |
| -- mysql:5.7 |
| 38 | + `mysql:latest` #or specify version you need for example `mysql:5.7` |
38 | 39 |
|
39 |
| -And in your .env mark mysql as the right resource |
| 40 | +And in your .env mark mysql as the corresponding resource (**DB_HOST=mysql**) |
40 | 41 |
|
41 |
| -##### **Usage:** |
| 42 | +### **Usage:** |
42 | 43 |
|
43 | 44 | In your .gitlab-ci.yml use this image like:
|
44 | 45 |
|
45 | 46 | `image: chilio/laravel-dusk-ci:stable`
|
46 | 47 |
|
47 |
| -add script line: |
| 48 | +add script lines: |
48 | 49 |
|
49 |
| -`- start-nginx-ci-project` ***<-- THIS IS THE IMPORTANT POINT BEFORE RUNNING DUSK*** |
| 50 | +`- cp .env.example .env` # remember to have **APP_URL=http://localhost** and **DB_HOST=mysql** |
50 | 51 |
|
51 |
| -Finally you can run all your tests served by nginx | php-fpm. |
| 52 | +`- configure-laravel` # preparations to run project |
| 53 | + |
| 54 | +`- start-nginx-ci-project` # Here we start webserver, so this is important before running dusk |
| 55 | + |
| 56 | +Finally you can run all your tests served by nginx | php-fpm via: |
| 57 | + |
| 58 | +`- php artisan dusk` |
52 | 59 |
|
53 | 60 | ------
|
54 | 61 |
|
55 |
| -Further examples (use it if needed): |
| 62 | +#### Further example script commands (if needed in your case): |
56 | 63 |
|
57 | 64 | `- yarn --network-concurrency 1` # when you have problems with slow connection
|
58 | 65 |
|
59 | 66 | `- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts`
|
60 | 67 |
|
61 |
| -`- cp .env.example .env` ***<-- APP_URL=http://localhost AND DB_HOST=mysql*** |
62 | 68 |
|
63 |
| - |
64 |
| -`- bower install --allow-root --quiet` |
| 69 | +`- bower install --quiet` |
65 | 70 |
|
66 | 71 | `- npm run dev ` or if you are on yarn registry `- yarn run dev `
|
67 | 72 |
|
68 |
| -`- configure-laravel` |
69 |
| - |
70 |
| -`./vendor/phpunit/phpunit/phpunit -v --coverage-text --colors --stderr` |
| 73 | +`./vendor/phpunit/phpunit/phpunit -v --coverage-text --colors --stderr`# to run phpunit with version specified in your project |
71 | 74 |
|
72 |
| -`- php artisan dusk` |
| 75 | +### **Examples:** |
73 | 76 |
|
74 |
| -##### **Examples:** |
| 77 | +**[gitlab-ci.yml](examples/.gitlab-ci.yml)** with stages, cache, and artifacts, assuming you are using scripts like "dev" in package.json. |
75 | 78 |
|
76 |
| -[**gitlab-ci.yml with stages and cache** (assuming you are on gitlab-multi-runner v9.5 and using scripts like "dev" in package.json):](examples/.gitlab-ci.yml) |
| 79 | +### **Caveats:** |
77 | 80 |
|
78 |
| -##### **Caveats:** |
| 81 | +- In your dusk tests remember to use -**>waitFor()** to make sure page is rendered properly, before test fails. |
| 82 | +- This docker has been tested with **gitlab-multi-runner** 9.5.0 version |
79 | 83 |
|
80 |
| -- In your dusk tests use ->waitFor() to make sure page is rendered properly |
81 |
| -- Remember to set up .env variables properly -> especially DB_HOST=mysql , APP_URL=http://localhost |
82 |
| -- **gitlab-multi-runner is evolving** (especially changes in cache functionality), in case of problems make sure you are using 9.5.0 version, which worked at this moment |
83 | 84 |
|
84 |
| -##### **Updates**: |
| 85 | +- in my scenario using `yarn run dev` instead of `npm run dev` was much faster, but this might not work out of the box and you may need to adapt your project. |
85 | 86 |
|
86 |
| -- bower does not need **--allow-root** anymore, in case you want to use it in this docker container |
87 |
| -- yarn does not need **--network-concurrency 1** anymore - you can always try if you experience problems |
88 |
| -- always better use `yarn run dev` instead of `npm run dev` if you have this script configured in package.json |
89 | 87 |
|
0 commit comments