Migrate to wp-env v11, require Node 20+, remove lock files #37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: | |
| - trunk | |
| - 'copilot/**' | |
| pull_request: | |
| branches: | |
| - trunk | |
| - 'copilot/**' | |
| jobs: | |
| # --------------------------------------------------------------------------- | |
| # JavaScript unit tests (Jest, no Docker needed) | |
| # --------------------------------------------------------------------------- | |
| js-tests: | |
| name: JS Unit Tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| # No cache — lock file is not committed. | |
| - name: Install dependencies | |
| run: npm install --legacy-peer-deps | |
| - name: Run JS unit tests | |
| run: npm run test:unit | |
| # --------------------------------------------------------------------------- | |
| # PHP unit tests — run inside wp-env (Docker) | |
| # --------------------------------------------------------------------------- | |
| php-tests: | |
| name: "PHP ${{ matrix.php }} Tests (wp-env)" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| # No cache — lock file is not committed. | |
| - name: Install dependencies | |
| run: npm install --legacy-peer-deps | |
| - name: Override PHP version | |
| run: | | |
| echo '{ "phpVersion": "${{ matrix.php }}" }' > .wp-env.override.json | |
| - name: Start wp-env | |
| run: npx wp-env start | |
| env: | |
| # wp-env pulls Docker images; increase timeout for CI. | |
| WP_ENV_LIFECYCLE_TIMEOUT: 300 | |
| - name: Install Composer dependencies | |
| run: npx wp-env run cli --env-cwd=wp-content/plugins/multi-author-posts -- composer install --no-interaction | |
| - name: Run PHP tests via wp-env | |
| run: npx wp-env run cli --env-cwd=wp-content/plugins/multi-author-posts -- vendor/bin/phpunit | |
| - name: Stop wp-env | |
| if: always() | |
| run: npx wp-env stop |