Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooling: Allow Chaining of Custom Tooling Commands #31

Open
AaronFeledy opened this issue Mar 27, 2020 · 13 comments
Open

Tooling: Allow Chaining of Custom Tooling Commands #31

AaronFeledy opened this issue Mar 27, 2020 · 13 comments

Comments

@AaronFeledy
Copy link
Member

AaronFeledy commented Mar 27, 2020

As a Lando user who frequently builds custom tooling to execute common tasks, I find that some of those tasks get repeated within more than one command.
For example:

tooling:
  install-deps:
    description: Install project dependencies
    cmd:
      - appserver: cd /app/drupal && COMPOSER_PROCESS_TIMEOUT=600 composer install
      - nodejs: yarn install
  install-db:
    description: Download and install project database
    cmd:
      - appserver: /app/drupal && platform db:dump --gzip --environment=develop --file=db_dump.sql.gz --yes
      - database: cd /app/drupal && /helpers/sql-import.sh db_dump.sql.gz
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush updatedb --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush user:login
  install-everything:
    description: Download and install project dependencies and database
    cmd:
      - appserver: cd /app/drupal && COMPOSER_PROCESS_TIMEOUT=600 composer install
      - nodejs: yarn install
      - appserver: /app/drupal && platform db:dump --gzip --environment=develop --file=db_dump.sql.gz --yes
      - database: cd /app/drupal && /helpers/sql-import.sh db_dump.sql.gz
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush updatedb --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush user:login

services:
  appserver:
    run:
      - appserver: cd /app/drupal && COMPOSER_PROCESS_TIMEOUT=600 composer install
      - nodejs: yarn install
      - appserver: /app/drupal && platform db:dump --gzip --environment=develop --file=db_dump.sql.gz --yes
      - database: cd /app/drupal && /helpers/sql-import.sh db_dump.sql.gz
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush updatedb --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
      - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush user:login

So much repetition there.

Lando can help solve this problem by allowing the chaining of tooling commands from within the command definition. More simply, this means allowing one Lando command to call another. In a perfect world, this would work, not only for custom tooling commands, but built-in tooling and build steps as well. This would allow reduced duplication of commands and the above functionality could be defined more like this:

services:
  appserver:
    run: -install-everything

tooling:
  install-deps:
    description: Install project dependencies
    cmd:
      - appserver: cd /app/drupal && COMPOSER_PROCESS_TIMEOUT=600 composer install
      - nodejs: yarn install
  install-db:
    description: Download and install project database
    cmd:
    - appserver: /app/drupal && platform db:dump --gzip --environment=develop --file=db_dump.sql.gz --yes
    - lando: db-import /app/drupal/db_dump.sql.gz
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush updatedb --yes
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush config:import --yes
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush cache:rebuild
    - appserver: cd /app/drupal && /app/drupal/vendor/bin/drush user:login

  install-everything:
    description: Download and install project dependencies and database
    cmd:
      - lando: install-deps
      - lando: install-db
@pirog
Copy link
Member

pirog commented Mar 27, 2020

I'm not against this feature but i will note that this likely would be very difficult to implement and i personally do not have the bandwidth to do it

@RichardDavies
Copy link

+1 on this feature request. I would like to be able to have this feature too.

@iainp999
Copy link

+1 from me too. I have similar situation with regards to repetition.

@stale
Copy link

stale bot commented Nov 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@edurenye
Copy link

This would help a lot to simplify things, also when you have a tool with a long list of commands and one of the commands needs a different user, then you could have another tool with that user and just reference to it.

@julien-langlois
Copy link

I agree with what has already been said. I'm currently working on a large Drupal project with several separate databases and Git projects, being able to chain Lando's tooling commands would make my job much easier.

Do we have any idea how to implement this feature?

@klonos
Copy link

klonos commented Oct 28, 2021

Yup, we could also use this as a workaround for lando/docs#47.

@DuaelFr
Copy link

DuaelFr commented Dec 13, 2021

That would be great!
It could work like composer does (https://getcomposer.org/doc/articles/scripts.md#referencing-scripts) I guess.
I hope it will be implemented some day. (I have no idea how to help with that though)

@LucyTurtle
Copy link

I would like this ability!

@pirog
Copy link
Member

pirog commented Apr 17, 2023

moving this ticket to the https://github.com/lando/core-next repo since it will be addressed in Lando 4

@pirog pirog transferred this issue from lando/lando Apr 17, 2023
@AlexSkrypnyk
Copy link

@pirog
Lando 4 is being in the works for several years, but we could really benefit from this feature in Lando 3.

The use case is quite significant: having a "build" or "full-build" command defined that would use other existing tooling commands so that devs could have a single command to get from "0 to 100".

In other non-lando projects, we are using Ahoy and Task that do allow these things.
Lando not having this capability makes people have to use another wrapper (like that Ahoy or Task) around Lando which makes things more complicated than they should be.

Is it possible to develop this and bring it to v3 of Lando if this is a sponsored work?

test-bdd:
    service: appserver
    description: Run BDD tests
    cmd: vendor/bin/behat

  test-unit:
    service: appserver
    description: Run unit tests
    cmd: vendor/bin/phpunit

  test:  <- something like this but without sub-process
    cmd: |
      lando test-unit
      lando test-bdd

@reynoldsalec
Copy link
Member

@AlexSkrypnyk drop me a line in the Lando Slack (https://www.launchpass.com/devwithlando) or talk to @AaronFeledy on the Drupal Slack (sounds like you've already reached out there).

@edurenye
Copy link

Calling tools from events should be part of the fix also since the issue about that lando/lando#751 has been closed as a duplicate of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests