Set up environmental variables - dotherightthing/generator-wpdtrt-plugin-boilerplate GitHub Wiki

Summary

Status

  • Up to date @ 0.9.0

TODO clarify where these should be generated


Generate tokens

Cypress.io test recording

  1. Name: CYPRESS_RECORD_KEY
  2. Open the Cypress Test Runner: ./node_modules/.bin/cypress open
  3. Click on the Runs tab of your project
  4. Click Set up Project to Record
  5. Copy the string following --key
  6. Recordings are available locally and on https://dashboard.cypress.io/

See: Cypress.io - Set up a project to record

Github API token

An API token provides access to a higher rate limit for API requests, of 5000 requests per hour (usually 60 per hour). This prevents failures when running Composer installs with a lot of nested dependencies.

The API token also provides the necessary permissions for the CI to clone private repositories (using Composer) and to deploy the release zip.

  1. Name: GH_TOKEN
  2. View your Personal Access Tokens
  3. Generate new token e.g. GH_TOKEN for username/wpdtrt-yourpluginname, or reuse an existing token e.g. GH_PAT_WPDTRT_DBTH
  4. Select scopes: repo > public_repo (note: repo may be required, see https://github.com/dotherightthing/wpdtrt-npm-scripts/issues/54)
  5. Generate token
  6. Copy the generated token's value to your plugin repo's GH_TOKEN

MySQL credentials

These three MySQL credentials are required to create and manage databases.

  1. Name: WPUNIT_DB_HOST (DB_HOST in wp-config.php)
  2. Name: WPUNIT_DB_PASS (DB_PASSWORD in wp-config.php)
  3. Name: WPUNIT_DB_USER (DB_USER in wp-config.php)

Consult your local LAMP stack (or wp-config) for these values.

Tip: I have my WPUNIT_DB_HOST set to 127.0.0.1 rather than localhost. I'm not sure if this makes a difference or not.

See also DTRT WordPress Plugin Boilerplate: Testing & Debugging.

Tenon API key

An API token provides access to the Tenon.io accessibility testing engine.

  1. Name: TENON_API_KEY
  2. Register, if you don't already have an account
  3. View your API Key
  4. Copy the token

Store the tokens on your local system

This allows you to run builds and use the Yeoman generator on your local system.

  1. Open Terminal
  2. Open your bash profile:
nano ~/.bash_profile
  1. Add these lines to store the tokens there (exporting a variable causes it to be inherited by subsequently started processes in the shell session):
export CYPRESS_RECORD_KEY="your_value"
export GH_TOKEN="your_value"
export TENON_API_KEY="your_value"
export WPUNIT_DB_HOST="your_value"
export WPUNIT_DB_PASS="your_value"
export WPUNIT_DB_USER="your_value"
  1. Save the changes and exit nano: CONTROL+X, Y(es), ENTER
  2. Close and reopen the Terminal

Store the tokens in Github

This allows you to run CI builds.

See: Set up Github Actions CI