Skip to content

Fix Plugin Check workflow: initialize wp-env before running plugin check#39

Closed
Copilot wants to merge 3 commits into
developfrom
copilot/fix-plugin-check-workflow
Closed

Fix Plugin Check workflow: initialize wp-env before running plugin check#39
Copilot wants to merge 3 commits into
developfrom
copilot/fix-plugin-check-workflow

Conversation

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

The Plugin Check workflow was failing with Environment not initialized. Run \wp-env start` first.becauseWordPress/plugin-check-action@v1` requires a running WordPress environment that was never started.

Changes

  • .github/workflows/plugin-check.yml
    • Add npx wp-env start step immediately before Run Plugin Check
    • Add npx wp-env stop teardown step after, guarded with if: always() to ensure cleanup on failure
- name: Start WordPress environment
  run: npx wp-env start

- name: Run Plugin Check
  uses: WordPress/plugin-check-action@v1
  ...

- name: Stop WordPress environment
  if: always()
  run: npx wp-env stop
Original prompt

The GitHub Actions job at https://github.com/HandyPlugins/security-txt-manager/actions/runs/26724040736/job/78756128009 is failing in the Plugin Check workflow.

Repository: HandyPlugins/security-txt-manager

Observed failure:

  • Workflow file: .github/workflows/plugin-check.yml
  • The failing log shows: Environment not initialized. Run \wp-env start` first.`
  • The failure occurs before or during the Run Plugin Check step that uses WordPress/plugin-check-action@v1.

Relevant context gathered:

  • Current workflow installs Composer dependencies, installs NPM dependencies, builds assets, then runs WordPress/plugin-check-action@v1.
  • The workflow does not currently start a WordPress environment before running plugin check.
  • package.json already uses Node-based tooling and should support invoking npx wp-env in CI.

Please create a pull request that fixes the workflow by ensuring the required WordPress environment is initialized before the plugin check runs. Prefer the minimal safe change.

Implementation guidance:

  • Update .github/workflows/plugin-check.yml.
  • Add a step before Run Plugin Check to start the environment, e.g. npx wp-env start.
  • If appropriate, add a cleanup step such as npx wp-env stop guarded with if: always().
  • Keep the rest of the workflow unchanged unless another small adjustment is clearly required for this fix.
  • Ensure the workflow syntax remains valid.

Acceptance criteria:

  • The workflow explicitly initializes the environment required by plugin check.
  • The change is limited to the workflow fix.
  • A pull request is opened with the fix.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is caused by the job invoking a WordPress environment check without first starting the environment:

Fix

Initialize wp-env before the Run Plugin Check step.

Suggested workflow change

Update .github/workflows/plugin-check.yml to add a setup step before line 40:

name: Plugin Check

on:
  pull_request:
  push:
    branches:
      - main
      - develop

jobs:
  plugin-check:
    name: Plugin Check
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4'
          coverage: none

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install Composer dependencies
        run: composer install --no-dev --prefer-dist --no-progress --no-interaction

      - name: Install NPM dependencies
        run: npm ci --no-audit

      - name: Build assets
        run: npm run build

      - name: Start WordPress environment
        run: npx wp-env start

      - name: Run Plugin Check
        uses: WordPress/plugin-check-action@v1
        with:
          build-dir: '.'
          exclude-directories: 'node_modules,vendor,.git,.github,.wordpress-org,.husky,tests'
          exclude-files: '.browserslistrc,.distignore,.editorconfig,.eslintignore,.eslintrc.json,.gitignore,.lintstagedrc.json,.npmrc,.nvmrc,.stylelintignore,.stylelintrc,babel.config.js,composer.json,composer.lock,package-lock.json,package.json,phpcs.xml.dist,phpunit.xml.dist,webpack.config.js'

Why this fixes it

The action at .github/workflows/plugin-check.yml#L40-L45 runs in an environment that expects wp-env to already be running. Right now, the workflow installs dependencies and builds assets, but never starts WordPress.

Optional hardening

To avoid leftover containers and make failures easier to debug, you can wrap cleanup with if: always():

      - name: Start WordPress environment
        run: npx wp-env start

      - name: Run Plugin Check
        uses: WordPress/plugin-check-action@v1
        with:
          build-dir: '.'
          exclude-directories: 'node_modules,vendor,.git,.github,.wordpress-org,.husky,tests'

      - name: Stop WordPress environment
        if: always()
        run: npx wp-env stop

Related file

Your package.json already uses the 10up toolk...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix workflow to initialize WordPress environment for plugin check Fix Plugin Check workflow: initialize wp-env before running plugin check Jun 4, 2026
Copilot AI requested a review from mustafauysal June 4, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants