Giter VIP home page Giter VIP logo

drupal_extension_scaffold's Introduction

Yourproject logo

Drupal extension scaffold

GitHub Issues GitHub Pull Requests CircleCI GitHub release (latest by date) LICENSE Renovate

Drupal 9 Drupal 10


Drupal extension template for development and testing in CI of your choice with mirroring to Drupal.org

Use case

Perform extension development in GitHub with testing in CI, and push code committed only to main branches (1.x, 2.x etc.) to drupal.org.

Features

  • Turnkey CI configuration with artifacts and test results support.
    • PHP version matrix for 8.2 and 8.1.
    • Drupal version matrix: stable, next and last EOL version.
    • CI providers:
  • 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 the info.yml file.
      • Additional dependencies can be added for integration testing between extensions: add dependency into suggest section of composer.json.
        Build process
    • Codings standards checking:
      • PHP code standards checking against Drupal and DrupalPractice standards.
      • PHP code static analysis with PHPStan (including PHPStan Drupal).
      • PHP deprecated code analysis with Drupal Rector.
      • Twig code analysis with TwigCS. Lint process
    • Drupal's Simpletest testing support - runs tests in the same way as drupal.org's Drupal CI bot (core/scripts/run-tests.sh). Test process
    • Renovate configuration to keep your repository dependencies up-to-date.
  • 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.

Screenshot of CI jobs

Setup

  1. Create your extension's repository on GitHub.
  2. Download this extension's code by pressing 'Clone or download' button in GitHub UI.
  3. Copy the contents of the downloaded archive into your extension's repository.
  4. Adjust the codebase:
    1. Replace your_extension with the machine name of your extension:
    2. Update type: theme in the info.yml file if your extension is a theme.
    3. Adjust several lines in .gitattributes.
    4. Remove .github/test-scaffold.yml file.
    5. Remove this content from README.md file.
  5. Commit and push to your new GitHub repo.
  6. Login to your CI and add your new GitHub repository. Your project build will start momentarily.
  7. 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: https://github.com/AlexSkrypnyk/drupal_extension_scaffold_destination

  1. Generate a new SSH key without pass phrase:
ssh-keygen -m PEM -t rsa -b 4096 -C "[email protected]"
  1. Add public key to your drupal.org account: https://git.drupalcode.org/-/profile/keys
  2. 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.
  1. In CI, UI 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 to 1 once CI is working, and you are ready to deploy.

Below is a content of the README.md file that will be added to your project.

The content above this line should be removed.


Yourproject logo

Your extension

GitHub Issues GitHub Pull Requests CircleCI GitHub release (latest by date) LICENSE Renovate

Drupal 9 Drupal 10


Few lines describing your project.

Features

  • Your first feature as a list item
  • Your second feature as a list item
  • Your third feature as a list item

Local development

Provided that you have PHP installed locally, you can develop an extension using the provided scripts.

Build

Run .devtools/build-codebase.sh (or ahoy build-codebase if Ahoy is installed) to start inbuilt PHP server locally and run the same commands as in CI, plus installing a site and your extension automatically.

Code linting

Run tools individually (or ahoy lint to run all tools if Ahoy is installed) to lint your code according to the Drupal coding standards.

cd build

vendor/bin/phpcs
vendor/bin/phpstan
vendor/bin/rector --clear-cache --dry-run
vendor/bin/phpmd . text phpmd.xml
vendor/bin/twigcs

Tests

Run .devtools/test.sh (or ahoy test if Ahoy is installed) to run all test for your extension.

Browsing SQLite database

To browse the contents of created SQLite database (located at /tmp/site_[EXTENSION_NAME].sqlite), use DB Browser for SQLite.

drupal_extension_scaffold's People

Contributors

alexskrypnyk avatar tannguyen04 avatar renovate[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.