Giter VIP home page Giter VIP logo

alexskrypnyk / drupal_extension_scaffold Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 2.0 8.17 MB

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

Home Page: http://drupal-extension-scaffold.alexskrypnyk.com/

License: GNU General Public License v3.0

PHP 13.45% Shell 73.84% JavaScript 6.89% MDX 0.22% CSS 1.63% Makefile 3.97%
circleci drupal testing template simpletest circleci2

drupal_extension_scaffold's Introduction

Drupal extension scaffold

Drupal extension scaffold

GitHub Issues GitHub Pull Requests Build, test and deploy CircleCI codecov GitHub release (latest by date) LICENSE Renovate

Drupal 10 Drupal 11


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 the main branches (1.x, 2.x etc.) to drupal.org.

Features

  • 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 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 Twig CS Fixer. Lint process
    • PHPUnit testing support 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.
GitHub Actions CircleCI
Screenshot of CI jobs in GitHub Actions Screenshot of CI jobs in CircleCi

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. Run the initial setup script: ./init.sh. Init process
  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:

  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, 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 to 1 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.

drupal_extension_scaffold's People

Contributors

alexskrypnyk avatar renovate[bot] avatar tannguyen04 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

drupal_extension_scaffold's Issues

Error when missing 'jq'

==> Install additional dev dependencies from module's composer.json
./.circleci/build.sh: line 36: jq: command not found

Installed jq, problem solved.

Add BATs tests for `ahoy` operations

Once #110 implemented, we want to have tests that execute the same activities as a developer would do locally.

We also want to make sure that lint and test failures are picked up by scripts, meaning that we want to have a test where we introduce a failure, running a tool (phpcs, phpstan etc.) and asserting that they have indeed failed.

See https://github.com/AlexSkrypnyk/scaffold/tree/main/tests/scaffold for an example on how to setup tests. (Note that the location in that repo for Scaffold's tests is not correct - the tests should be in .scaffold/tests dir, not tests/scaffold - there is a ticket to fix that in that repo).

Please note that you would need to install ahoy into container - see https://github.com/ahoy-cli/ahoy

Add support for installing FE deps

If module provides FE deps - add support to install them.

if [ -f "build/web/modules/custom/${module}/package-lock.json" ]; then
  pushd "build/web/modules/custom/${module}/" > /dev/null || exit 1
  echo "  > Installing theme assets."
  [ -f ".nvm" ] && nvm use || true
  [ ! -d "node_modules" ] && npm ci || true
  popd > /dev/null || exit 1
fi

Add publishing of the documentation site for the scaffold to GH pages

This is about providing the documentation for this scaffold repo, not the repo being scaffolded.

  1. Get docs app setup as in https://github.com/AlexSkrypnyk/scaffold into .scaffold/docs dir. Update paths as required.
  2. Add empty sections as Markdown files:
  • Introduction (use README.md as this is a first page)
  • Setup
  • Usage
  • FAQs
  1. Add GHA integration to publish to GH pages using the default GH domain.

Note: proper domain will be added in a separate ticket.

Update repo configs from https://getscaffold.dev/

Download the latest code from Scaffold repo (actual code, not the release).

  • Update composer.json with the structure from Scaffold. Preserve the values of the existing fields, but order the fields as per Scaffold's composer.json. Add missing fields. Do not add scripts. This is an example file to use for the Drupal module itself. It is not meant to be used as a composer install. So just make sure that the order is correct.
  • Add Renovate config from Scaffold
  • Add/update all GitHub actions and configs to be per Scaffold. Note that the test GHA workflow should NOT be used.
  • Update readme to use the structure from Scaffold, including the generated logo (circle). Do not change the contents of the sections, just the structure.
  • Do not add PHPStan or PHPCS packages - these are added automatically when the site is built. We will need to add the config files, but this will be handled in the separate issue (#79).
  • Reformat composer.json to have indents and sorting as per the Scaffold.

Make sure that CI passes.

Similar task for reference: AlexSkrypnyk/shellvar#17

Add init script to make onboarding easier

We need to simplify the setup process as per https://github.com/AlexSkrypnyk/drupal_extension_scaffold?tab=readme-ov-file#setup

The questions themselves should be adjusted for this repo:

  1. namespace
  2. name
  3. machine_name
  4. type: module or theme
  5. ci_provider - GitHub Actions or CircleCI

Make `build.sh` more readable

create local shorthand functions like below and update the rest of the script

drush() { "${BUILD_DIR}/vendor/bin/drush" -y "$@"; }

Add support for custom patches

something like

echo "  > Adding custom patches."
cat <<< "$(jq --indent 4 '.extra.patches = {"drupal/core": {"Builds failing on missing layout column plugin": "https://www.drupal.org/files/issues/2023-07-16/3204271-20-missing-layout-exception.patch"}}' "${BUILD_DIR}/composer.json")" > "${BUILD_DIR}/composer.json"

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.


Warning

Renovate failed to look up the following dependencies: Failed to look up packagist package drupal/autologout.

Files affected: composer.json


This repository currently has no open or pending branches.

Detected dependencies

composer
composer.json
  • php >=8.2
  • drupal/autologout ^2
github-actions
.github/workflows/assign-author.yml
  • toshimaru/auto-author-assign v2.1.0
.github/workflows/deploy.yml
  • actions/checkout v4
  • shimataro/ssh-key-action v2
  • ubuntu 22.04
.github/workflows/draft-release-notes.yml
  • release-drafter/release-drafter v6
.github/workflows/scaffold-release.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/configure-pages v5
  • actions/upload-pages-artifact v3
  • actions/deploy-pages v4
.github/workflows/scaffold-test.yml
  • actions/checkout v4
  • shivammathur/setup-php v2
  • luizm/action-sh-checker v0.8.0
  • actions/setup-node v4
  • actions/upload-artifact v4
  • codecov/codecov-action v4
  • actions/checkout v4
  • actions/checkout v4
  • actions/setup-node v4
  • nwtgck/actions-netlify v3.0
.github/workflows/test.yml
  • actions/checkout v4
  • actions/cache v4
  • shivammathur/setup-php v2
  • actions/upload-artifact v4
  • actions/upload-artifact v4
  • codecov/codecov-action v4
  • ubuntu 22.04
npm
.scaffold/docs/package.json
  • @docusaurus/core 3.4.0
  • @docusaurus/plugin-google-gtag ^3.1.1
  • @docusaurus/preset-classic 3.4.0
  • @docusaurus/theme-mermaid ^3.1.1
  • @easyops-cn/docusaurus-search-local ^0.44.0
  • @mdx-js/react ^3.0.0
  • clsx ^2.0.0
  • prism-react-renderer ^2.3.0
  • raw-loader ^4.0.2
  • react ^18.0.0
  • react-dom ^18.0.0
  • @docusaurus/module-type-aliases 3.4.0
  • @docusaurus/types 3.4.0
  • cspell ^8.6.1
  • node >=18.0
.scaffold/tests/package.json
  • bats-helpers ^1.2
package.json
  • npm >=8.0.0
  • node >=16.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Add GitHub Actions support

Add GitHub Actions support. Once this is implemented, this project would allow the user to choose which CI provider they would want to use.

  1. Use only scripts from .devtools, but feel free to modify them, if required.
  2. Use the same PHP versions matrix as for CircleCI
  3. Use the same Drupal versions matrix as for CircleCI
  4. Use the format and naming convention of a workflow and jobs from https://github.com/AlexSkrypnyk/scaffold/blob/main/.github/workflows/test-php.yml

See an existing CI implementation: https://github.com/drupal-composer/drupal-project/blob/10.x/.github/workflows/ci.yml

Add code quality checks configurations

The built artefact created in build directory has PHPCS and PHPStan added as a part of the build.

But there are no config files added for these tools AND there is no way to point the tools to use those configs (unless the tool can somehow discover the config automatically).

We need to do 4 things here:

  1. Update .circleci/build.sh part echo " > Installing other dev dependencies." to use:
php -d memory_limit=-1 "$(command -v composer)" --working-dir="${BUILD_DIR}" require --dev \
  dealerdirect/phpcodesniffer-composer-installer \
  phpspec/prophecy-phpunit:^2 \
  mglaman/phpstan-drupal:^1.2 \
  palantirnet/drupal-rector:^0.18 \
  friendsoftwig/twigcs:^6.2 
  1. Copy configs from https://github.com/drevops/drevops/tree/main for PHPC, PHPStan, Rector and TWIGCS and update them accordingly.
  2. Assess if we need to update .circleci/lint.sh with paths to configurations (based on the tool).
  3. Update README.md file with a newly added list of tools (TWIGCS).

I don't understand the deployment process to sync with drupal.

Sorry, but I can't understand what to do in the step 2 in CircleCI, I need to create a new key?, if that was the case, what I need to put in hostname?.

In the step 3, where I can obtain the fingerprint?, in github?, sorry but I'm very confused, please give me a clue.

Add `make` support

  • Add support for make to be a command parity to ahoy.yml.
  • Add tests. May need to install make into container.

Only implement this after #126 is done

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.