Back to blogs
How to integrate Phpcs with Drupal code standards on bitbucket pipelines
Submitted on: July 30 2024
Steps:
Create a new pipeline in the root of the project with the file name bitbucket-pipelines.yml
or if it exists add just the step and the trigger to the existed pipeline.
# These are yaml anchors, reused later
x-bash-env-steps:
- &bash_env_export export BASH_ENV="$BITBUCKET_CLONE_DIR/.bashrc"
- &bash_env_source source $BASH_ENV
# This is a larger yaml anchor, reused for each pipeline
pull_requests: &pull_requests
- step:
name: 'PHPCS'
image: wodby/drupal-php:7.4
script:
- composer install
- ./vendor/bin/phpcs -q --colors --standard=Drupal --extensions=php,module,inc,install,test,profile,theme ./web/modules/custom
- ./vendor/bin/phpcs -q --colors --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme ./web/modules/custom
- ./vendor/bin/phpcs -q --colors --standard=Drupal --extensions=php,module,inc,install,test,profile,theme --report=diff ./web/modules/custom
- ./vendor/bin/phpcs -q --colors --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme --report=diff ./web/modules/custom
- ./vendor/bin/phpcs -q --colors --standard=Drupal --extensions=php,module,inc,install,test,profile,theme ./web/themes/custom
- ./vendor/bin/phpcs -q --colors --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme ./web/themes/custom
- ./vendor/bin/phpcs -q --colors --standard=Drupal --extensions=php,module,inc,install,test,profile,theme --report=diff ./web/themes/custom
- ./vendor/bin/phpcs -q --colors --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme --report=diff ./web/themes/custom
options:
max-time: 30
pipelines:
pull-requests:
# Using the custom pull_request pipeline on each pull request created.
'**': *pull_requests