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

[Discussion] Add Lando? #44

Open
leoloso opened this issue Feb 17, 2023 · 3 comments
Open

[Discussion] Add Lando? #44

leoloso opened this issue Feb 17, 2023 · 3 comments

Comments

@leoloso
Copy link

leoloso commented Feb 17, 2023

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

  • Quick test against alpha and stable wp
  • The MySql database created by Lando can be used to run the Behat tests, thus removing the manual step (eg: file startdb shared by Alain)

Drawbacks

  • We don't want to force contributors to using Lando, so this development may only be available to a subset of contributors
  • Lando is based on Docker, which is now a commercial tool

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:

  • Running this command to download the WordPress files:
lando init --source remote --remote-url https://wordpress.org/latest.tar.gz --recipe wordpress --webroot wordpress --name wp-cli-tests
  • Installing WordPress:
$ 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 [email protected] --path=/app/wordpress 
  • (Optional) Configure WordPress (eg: permalink structure)
  • (Optional) Seed the DB with data

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
Copy link

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
Copy link
Member

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
Copy link

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.

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

3 participants