All you need to do for your Drupal 7 module is to change one line in the default template, from this:
To run gitlab pipelines in a Drupal 7 project, create a `.gitlab-ci.yml` file from the standard template as explained [here](./setup.md). Then change one line from this:
```
- '/includes/include.drupalci.main.yml'
...
...
@@ -12,4 +12,39 @@ to this:
- '/includes/include.drupalci.main-d7.yml'
```
That's it!
## Drupal 7 core version
By default, the latest stable Drupal 7 core version is used, but you can change this by specifying a value for the `_TARGET_D7_CORE` variable:
```
variables:
_TARGET_D7_CORE: 7.98
```
## Composer
If your Drupal 7 module uses `drupal/composer` and has a `composer.json` file, you'll need to set the `_D7_DRUPAL_COMPOSER_NEEDED` variable to 1.
```
variables:
_D7_DRUPAL_COMPOSER_NEEDED: 1
```
This will use Composer 1 instead of 2, but it should allow your module to work as expected and bring in the requirements using Composer.
## Dependencies
If your module has dependencies and you are _not_ managing them with a `composer.json` file, you can use the `_D7_DRUPAL_TEST_DEPENDENCIES` variable with a list of modules. For example:
These modules will be downloaded via `drush pm:download`. You can specify different variations in the list of modules:
- Dev version of a module: `entity -dev`
- Exact version of a module: `entity-7.x-1.3`
Some modules might not be hosted in `git.drupalcode.org`. If you need to provide more complex arguments when downloading a module or dependency, you can use the `before_script` section and then specify arguments like `--source`. You must set the `--destination` parameter so the module is saved in the right location.
It will run the tests of your module using [phpunit](https://phpunit.de/index.html), but there are two flavors that you can choose from:
This job runs the [phpunit](https://phpunit.de/index.html) tests defined by your module, including Functional, FunctionalJavascript, Kernel and Unit tests. You have a choice of two ways that the tests can be executed:
- Using the `phpunit` binary directly and running the tests in sequential mode. `_PHPUNIT_CONCURRENT: 0` (default).
- Using the `run-tests.sh` Drupal core script and running the tests in parallel mode. `_PHPUNIT_CONCURRENT: 1`.
- Using the `phpunit` binary directly and running the tests in sequential mode. This is the default, but you can specify it using:
```
variables:
_PHPUNIT_CONCURRENT: 0
```
- Using the Drupal core script `run-tests.sh` to execute the tests in parallel mode:
```
variables:
_PHPUNIT_CONCURRENT: 1
```
## Using `phpunit` binary directly.
## Using `phpunit` binary directly (non-concurrent mode)
This is the default option. The tests will be run calling the `vendor/bin/phpunit` binary directly and in a sequential order. As there is no concurrency, the tests here might take a bit longer.
This is the default option. The tests will be run calling the `vendor/bin/phpunit` binary directly and in a sequential order. As there is no concurrency, the tests are likely to take longer to run.
You can use the `_PHPUNIT_EXTRA` variable to add extra options to the `phpunit` binary.
You can use the `_PHPUNIT_EXTRA` variable to add extra options to the `phpunit` binary. For example:
```
variables:
_PHPUNIT_EXTRA: "--debug"
```
### TestDox
...
...
@@ -28,6 +40,14 @@ Api Access (Drupal\Tests\api\Functional\ApiAccess)
```
Note that this option conflicts with the Drupal `HtmlOutputPrinter` printer and, if used, no `.html` artifacts will be generated after the run.
### Running a subset of the tests
There may be times when you temporarily only need to run one or two tests, instead of the whole test suite. This can be achieved using:
```
variables:
_PHPUNIT_EXTRA: "--filter='/thisTest|thatTest/' "
```
The `--filter` parameter is only valid when running the phpunit binary directly.
## Using `run-tests.sh` core script (concurrent mode)
This script is included in Drupal core and leverages concurrency and also runs the tests in the same way that Drupal core tests are run. As there is concurrency, the job should run quicker than with the sequential option.
...
...
@@ -48,7 +68,7 @@ phpunit:
## Variants
This job allows for multiple variants to check previous, current and future versions of Drupal.
The phpunit job has multiple variants to check previous, current and future versions of Drupal. See the [OPT_IN variables](./jobs.md#skip-and-opt_in-variables) for more details.