wp-cli / wp-cli-dev

🛠 WP-CLI development environment that allows for easy development across all packages
36 stars 36 forks source link

[Discussion] Add Lando? #44

Open leoloso opened 1 year ago

leoloso commented 1 year ago

Talking to @schlessera in WordCamp Asia, we discussed adding support for Lando. As we don't know if contributors would agree, we first create this issue to ask for feedback.

The idea is not to lock development to using Lando, but to use it as a sort of "progressive enhancement": If you have Lando, you can benefit from it; if not, nothing happens.

Main benefit

Within the same Lando instance, we can play with the wp command under development, and contrast it against the latest stable wp command:

# SSH into the Lando instance
$ lando ssh

# Execute a command against ALPHA
# This prints "WP-CLI 2.8.0-alpha"
$ wp --version

# Execute a command against STABLE
# This prints "WP-CLI 2.7.1"
$ /usr/local/bin/wp --version

By having this quick feedback, we can have a better idea of how well the code is doing, before/while writing the Behat test.

Advantages

Drawbacks

Potential implementation

Place file .lando.yml in the root folder:

name: wp-cli-tests
recipe: wordpress
config:
  webroot: wordpress
  php: '8.1'
  ssl: true
services:
  database:
    portforward: true

Then WordPress must be installed. That includes:

lando init --source remote --remote-url https://wordpress.org/latest.tar.gz --recipe wordpress --webroot wordpress --name wp-cli-tests
$ wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=database --skip-check --force --path=/app/wordpress
$ wp core install --url="wp-cli-dev.lndo.site" --title="WP-CLI DEV" --admin_user=admin --admin_password=admin --admin_email=admin@example.com --path=/app/wordpress 

In order to keep this process in a single contained file, these commands can be stored in composer.json, and executed via Composer scripts "build-server" (the first time the Lando server is built) and "init-server" (to initialize it from then on). The logic can be stored in .sh files placed in a lando folder

marioy47 commented 1 year ago

The process of downloading and installing WordPress can be included in the .lando.yml file. I've modified @leoloso to include this steps.

The drawback is that I have to add a 10 second "sleep" and that seems a bit hacky

danielbachhuber commented 1 year ago

What is the advantage of having the YAML file bundled in wp-cli-dev, vs. something that someone can simply copy from a page?

The disadvantage is that it becomes something we need to "officially" support, to some degree. Given there are numerous development environments out there, I'm not sure what advantage we gain by putting effort towards Lando.

marioy47 commented 1 year ago

The reasoning behind adding a .lando.yml file to the dev environment was to offer a fast alternative to setting up a development environment.

@leoloso came up with this idea after we spent almost an entire day at the last WordConf Asia 2023 just setting up the wp-cli dev environment of the participants of the wp-cli working group.

The resulting yml file is not that big (sorry I haven't submitted a PR) so supporting it shouldn't be such a hassle. And I'm not sure if we need to "officially" support it since is just for setting up a development environment, not even for developing.