CI is there

Just use it

Specific

Gitlab CI

Node.JS

ReactJS

Grunt

Behat

Jenkins

Sonar

Docker

Reviews App

  • Code

  • Build

  • Test

  • Deploy

Automation

Gitlab CI

  • Automate Code Review
  • Deploy
    • (optionally) package code
    • deliver
    • run updates, cache clear, etc
    • run compile tasks and any extra
    • provide deploy logs and status
  • Execute Tests

we use it to

Gitlab CI

  • Executes pipelines specified in .gitlab-ci.yml
  • Alerts the team of failed/success pipelines
  • Makes every pipeline information available
  • Scalable: consist of multiple machine nodes (runners)

Advantages

Gitlab CI

sample config

stages:
  - build
  - review
  - test
  - deploy

sonar:
  stage: test
  script:
    - sonar-scanner -Dsonar.host.url=http://sonar.adyax-dev.com -Dsonar.analysis.mode=preview -Dsonar.issuesReport.console.enable=true -Dsonar.gitlab.commit_sha=$CI_BUILD_REF -Dsonar.gitlab.ref=$CI_BUILD_REF_NAME
  only:
    - branches
  except:
    - develop

cs_review:
  stage: test
  # Select image from https://hub.docker.com/_/php/
  image: php:7.1
  tags:
    - docker
  # Select what we should cache
  cache:
      paths:
      - vendor/
      - docroot/modules/contrib/
      - bin/
  before_script:
    # Install all project dependencies
    # ...
  script:
    - echo "Review module,php,install,js for Drupal standards"
    # - composer install
    -  ~/.composer/vendor/bin/phpcs --colors --standard=DrupalPractice --encoding=utf-8 -p --extensions=module/php,php,install/php,js,yml ./docroot/modules/custom/
    -  ~/.composer/vendor/bin/phpcs --colors --standard=Drupal --encoding=utf-8 -p --extensions=module/php,php,install/php,js ./docroot/modules/custom/
  only:
    - branches
  except:
    - develop
  allow_failure: true

deploy_dev:
 stage: deploy
 script:
   -  ssh ush@ushlogements.adyax.net 'bash -s' < ./scripts/ci/dev-deployment.sh
 only:
   - develop

review:
  stage: review
  script:
    - export COMPOSER_DISCARD_CHANGES=true
    - composer install --no-dev
    - rsync -av --delete ./ /var/www/review/$CI_BUILD_REF_SLUG
    - cd /var/www/review/$CI_BUILD_REF_SLUG/docroot
    # Create_DB
    - echo "CREATE DATABASE IF NOT EXISTS \`ushlogements_$CI_BUILD_REF_SLUG\`" | mysql -uush -paIqtYDqZAnm5I6F
    # Create_settings
    - sed -i -- "s/CI_BUILD_REF_SLUG/$CI_BUILD_REF_SLUG/g" ../environments/review/settings.php
    #- cp ../environments/review/settings.php ./sites/default/settings.php
    - mkdir drush
    - cp ../scripts/ci/logements.aliases.drushrc.php ./drush/logements.aliases.drushrc.php
    # Sync DB from Dev
    - drush sql-sync @logements.dev default -y
    - drush cr
    - drush cim -y
    - drush updb -y
    - drush entity-updates -y
  environment:
    name: review/$CI_BUILD_REF_NAME
    url: http://$CI_BUILD_REF_SLUG.review.ushlogements.adyax-dev.com
    on_stop: stop_review
  when: manual
  only:
    - branches
  except:
    - master
  tags:
    - nginx
    - review-apps
    - deploy
    - ush

stop_review:
  stage: review
  script:
    - rm -rf /var/www/review/$CI_BUILD_REF_SLUG
    # DROP_DB
    - echo "DROP database \`ushlogements_$CI_BUILD_REF_SLUG\`" | mysql -uush -paIqtYDqZAnm5I6F
  variables:
    GIT_STRATEGY: none
  when: manual
  environment:
    name: review/$CI_BUILD_REF_NAME
    action: stop
  tags:
    - nginx
    - review-apps
    - deploy
    - ush

https://code.adyax.com/snippets/39

Gitlab CI

runners

  • shell runner

  • ssh runner

  • docker runner

Code

Scrum teams care very much about their code quality.

 

Ensure the quality is above accepted threshold.

 

  • Coding Standards
  • Drupal Practice
  • Sonar (Cyclomatic Complexity, Cognitive complexity, Code smell, Bug, Vulnerability, etc)

Code Quality

Code Task

Code Quality

  • Control Git flow
  • Feature branching
  • Code review
    • automated
    • manual

Code Task

Code review

  • Pre-commit hook
    • Review Coding standards,
    • Review Drupal Practices
  • Merge Request
    • Sonar Code review

https://sites.google.com/a/adyax.com/knowledge-base/departments/development/standards/code-review

Code Task

Sonar

http://sonar.adyax-dev.com/

Continuous Code Quality

Code Task

Build

  • Download Dependencies
  • Compile CSS/JS
  • Multi-siting: build project tree with sub-projects
  • (optionally) Package the build artifact

Reviews App

What if I say

that you can do review on

a dynamic environment?

Adyax Gitlab - Reviews app

Deployment

Test

Devs write tests!

@api @d8
Feature: Language support
  In order to demonstrate the language integration
  As a developer for the Behat Extension
  I need to provide test cases for the language support

  Scenario: Enable multiple languages             # features/language.feature:11
    Given the following languages are available:  # Drupal\DrupalExtension\Context\DrupalContext::createLanguages()
      | languages |
      | en        |
      | fr        |
    When I visit "/"                              # Drupal\DrupalExtension\Context\MinkContext::assertAtPath()
    └─ @AfterStep # Devinci\DevinciExtension\Context\DebugContext::dumpAssetsAfterFailedStep()
    Then I should see "Username"                  # Drupal\DrupalExtension\Context\MinkContext::assertPageContainsText()
    Then I should see "Password"                  # Drupal\DrupalExtension\Context\MinkContext::assertPageContainsText()
    And I fill in the following:                  # Drupal\DrupalExtension\Context\MinkContext::fillFields()
      | Username | admin |
      | Password | admin |
    And press "Log in"                            # Drupal\DrupalExtension\Context\MinkContext::pressButton()
    When I go to "admin/config/regional/language" # Drupal\DrupalExtension\Context\MinkContext::visit()
    Then I should see "English"                   # Drupal\DrupalExtension\Context\MinkContext::assertPageContainsText()
    And I should see "French"

Test

Executed in CI

Others

  • Adyax Jenkins http://auto.adyax.com/

  • Adyax Zebra http://jenkins.proto.zebra.adyax-dev.com/

Continuous integration

By Ivan Tsekhmistro

Continuous integration

  • 809