Skip to content

[Discussion] Add Lando? #44

Open
Open
@leoloso

Description

@leoloso

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 --admin_email=admin@example.com --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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions