Gitlab-CI introduced a flexible and powerful CI solution. My project Giltab CI fo Drupal 8 is meant to ease the integration with a Drupal 8 project.
It is now ready to handle a single module or theme and provide a full pipeline for your testing.
Here is a brief article to integrate Gitlab-CI with your module in probably less than 10 minutes!
This CI includes Drupal testing (Unit, Functional, Functional JavaScript, Nightwatch.js), code quality for PHP, JavaScript, CSS, Sass and some metrics for your PHP code.
Full version include Behat tests, Pa11y accessibility tests, a sample of deploy but this is not used in this tutorial.
Installation
From my project, download the code: https://gitlab.com/mog33/gitlab-ci-drupal
Extract and copy .gitlab-ci.yml
and the.gitlab-ci
folder at the root of your module.
Go to Gitlab Settings > CI/ CD > Variables and add those variables (first one is empty!):
CI_IMAGE_VARIANT drupal
CI_TYPE module
WEB_ROOT /var/www/html
PHP_CODE_QA /var/www/html/modules/custom
PHP_CODE_METRICS /var/www/html/modules/custom
SKIP_TEST_SECURITY 1
SKIP_TEST_BEHAT 1
SKIP_TEST_PA11Y 1
# If Nightwatch tests
NIGHTWATCH_TESTS --tag my_module
# If not set
SKIP_TEST_NIGHTWATCH 1
# If you don't have sass files
SKIP_LINT_SASS 1
# If you don't have any css files
SKIP_LINT_CSS 1
# If you don't have any javascript files
SKIP_LINT_JS 1
Create a branch testing
and push your module code to Gitlab.
Check the pipelines menu on your Gitlab !
If you want to choose when to run the CI, for example on a branch master or on a tag, adapt the section with:
.test_except_only: &test_except_only
except:
refs:
- master
variables:
- $SKIP_TESTS == "1"
only:
refs:
- testing
- tags
Et VoilĂ !
More information on the project page : https://gitlab.com/mog33/gitlab-ci-drupal