I am a senior Php developer specialized in Drupal, I offer various services on Drupal development, audits, training and deployment.
You can check and evaluate my work or my modules and feel free to contact me for a quote on any Drupal related project.

Contact me

Image

Quickly setup Gtilab-CI with your Drupal 8 module

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), 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

Download Gitlab CI for Drupal 8

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
Gitlab variables.

Create a branch testing and push your module code to Gitlab.

Check the pipelines menu on your Gitlab !

Exemple de pipeline Gtilab

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

 

 

Comments