wunderio / drupal-project

Wunder's template for Drupal projects designed to work automatically with Lando, CircleCI and Helm.
GNU General Public License v2.0
35 stars 6 forks source link

Make Code Quality aware of DDEV #393

Open hkirsman opened 7 months ago

hkirsman commented 7 months ago

If you install DDEV to this project and try to commit, Code Quality tool (GrumPHP) will start Lando instead because we have this in code:

  git_hook_variables:
    EXEC_GRUMPHP_COMMAND: lando php

Either we keep this as is as Lando can handle starting up only the the needed containers on demand, or we add some logic to decide what to run.

Unfortunately we're quite limited on writing some advanced code here but I've come up with this logic:

  1. We assume our projects can have both Lando and DDEV setups for now.
  2. We assume developer uses either Lando or DDEV, but not both. So this means every developer has the project set up with either Lando or DDEV only.
    1. So based on these assumptions, DDEV creates different folders under .ddev if it has been started. These are not there if you clone the project. So the trick is to check if .ddev/traefik/ folder exists and if so then start Code Quality with DDEV, if not then with Lando.
      grumphp:
      git_hook_variables:
      EXEC_GRUMPHP_COMMAND:  "[ -d .ddev/traefik/ ] && GRUMPHP_COMMAND='ddev php' || GRUMPHP_COMMAND='lando php' && $GRUMPHP_COMMAND"

On existing projects this needs to be run: ddev grumphp git:init

Wondering also if I should instead create some automatic update to wunderio/ddev-drupal package.