Drupal extension template for development and testing in CI of your choice with mirroring to Drupal.org
Perform extension development in GitHub with testing in CI, and push code
committed only to the main branches (1.x
, 2.x
etc.)
to drupal.org.
- Turnkey CI configuration with artifacts and test results support.
- Tools:
- Develop locally using PHP running on your host using
identical
.devtools
scripts as in CI.- Uses drupal-composer/drupal-project
to create drupal site structure. Providing a custom fork of
drupal-project
is also supported. - Additional development dependenices provided in
composer.dev.json
. These are merged during the codebase build. - The extension can installed as a module or a theme: modify
type
property set in theinfo.yml
file. - Additional dependencies can be added for integration testing
between extensions: add dependency into
suggest
section ofcomposer.json
. - Patches can be applied to the dependencies: add a patch to the
patches
section ofcomposer.json
. Local patches will be sourced from thepatches
directory.
- Uses drupal-composer/drupal-project
to create drupal site structure. Providing a custom fork of
- Codings standards checking:
- PHP code standards checking against
Drupal
andDrupalPractice
standards. - PHP code static analysis with PHPStan (including PHPStan Drupal).
- PHP deprecated code analysis with Drupal Rector.
- Twig code analysis with Twig CS Fixer.
- PHP code standards checking against
- PHPUnit testing support
- Renovate configuration to keep your repository dependencies up-to-date.
- Develop locally using PHP running on your host using
identical
- Deployment:
- Mirroring of the repo to drupal.org (or any other git repo) on release.
- Deploy to a destination branch different from the source branch.
- Tags mirroring.
- This template is tested in the same way as a project using it.
GitHub Actions | CircleCI |
---|---|
- Create your extension's repository on GitHub.
- Download this extension's code by pressing 'Clone or download' button in GitHub UI.
- Copy the contents of the downloaded archive into your extension's repository.
- Run the initial setup script:
./init.sh
. - Commit and push to your new GitHub repo.
- Login to your CI and add your new GitHub repository. Your project build will start momentarily.
- Configure deployment to drupal.org (see below).
Configure deployment (click to expand)
The CI supports mirroring of main branches (1.x
, 10.x-1.x
etc.) to
drupal.org mirror of the project (to keep both repos in
sync).
The deployment job runs when commits are pushed to main branches
(1.x
, 2.x
, 10.x-1.x
etc.) or when release tags are created.
Example of deployment repository:
- from GitHub Actions: https://github.com/AlexSkrypnyk/drupal_extension_scaffold_destination_github
- from CircleCI: https://github.com/AlexSkrypnyk/drupal_extension_scaffold_destination_circleci
- Generate a new SSH key without pass phrase:
ssh-keygen -m PEM -t rsa -b 4096 -C "[email protected]"
- Add public key to your drupal.org account: https://git.drupalcode.org/-/profile/keys
- Add private key to your CI:
- CircleCI:
- Go to your project -> Settings -> SSH Permissions
- Put your private SSH key into the box. Leave Hostname empty.
- Copy the fingerprint string from the CircleCI User Interface. Then,
replace the
deploy_ssh_fingerprint
value in the.circleci/config.yml
file with this copied fingerprint string. - Push the code to your repository.
- In CI, use UI to add the following variables:
DEPLOY_USER_NAME
- the name of the user who will be committing to a remote repository (i.e., your name on drupal.org).DEPLOY_USER_EMAIL
- the email address of the user who will be committing to a remote repository (i.e., your email on drupal.org).DEPLOY_REMOTE
- your extensions remote drupal.org repository ( i.e.[email protected]:project/myextension.git
).DEPLOY_PROCEED
- set to1
once CI is working, and you are ready to deploy.
To debug SSH connection used by Git, add GIT_SSH_COMMAND
variable with value
ssh -vvv
. This will output verbose information about the SSH connection and
key used.