My WordPress environment for vetting Codeable experts

I have been vetting experts, reviewing both front-end and full-stack (plugin) submissions since 2019 at Codeable. The internal process changed throughout the years, but our commitment to give a fair review remained unchanged.

Part of providing a fair review is making sure we are testing the applicants' code in a "clean" environment. Clean, in this case, means barebones, an environment as typical as a WordPress installation can be.

To achieve this, I'm using wp-env to spin up a "brand new" WordPress installation before every review. As the wp-env reference page says, "it's simple to install and requires no configuration", as long as you have the prerequisites: Docker and Node.js installed.

The process

I start by cloning my boilerplate for the environment. This consists only of a few files:

.
├── .gitignore
├── .wp-env.json.example
├── package.json
├── phpcs
└── setup

Next, I make the initial setup script executable, then run it:

chmod +x ./setup
./setup

It's a simple script but it saves some repetition:

#!/bin/bash
cp .wp-env.json.example .wp-env.json
npm install
chmod +x ./phpcs

In my package.json, I don't have anything besides the wp-env dependency:

{
    "devDependencies": {
        "@wordpress/env": "^4.5.0"
    }
}

One of our selected services for managing the application process is CodeScreen. It's a "developer assessment platform, allowing us to accelerate our hiring by screening developers fairly, quickly, and accurately."

CodeScreen makes the code submission available in a GitHub repo. For this reason, I can clone it in the environment's directory:

git clone git@github.com:codescreen/CodeScreen_xxx.git CodeScreen_xxx

Depending on the application type, I map the plugin or the theme to the WordPress instance. I do this by editing the .wp-env.json file:

{
    "mappings": {
        "wp-content/plugins/xxx": "./CodeScreen_xxx/wp-content/plugins/xxx"
    }
}

At this point, everything is set up, and I can start the local WordPress environment by:

npx wp-env start

We require candidates to follow a coding standard. If they don't explicitly state which one they follow, we assume they are using the WordPress Coding Standard (WPCS). To check the results, I use my helper script:

./phpcs ./CodeScreen_xxx/wp-content/plugins/xxx

This runs the PHPCS with the preinstalled and configured WPCS using a Docker image. This is just a "shortcut script" for:

#!/bin/bash
CMD=$*

if [[ -z ${CMD} ]]; then
    echo "No path provided for the PHPCS. Do it?"
    exit 1
fi

docker run -it --rm -v $(pwd):/app willhallonline/wordpress-phpcs:alpine phpcs "$CMD"

When I'm done with the review, I stop and destroy the local environment with:

npx wp-env stop
npx wp-env destroy