Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tests/
phpunit.xml.dist
wp-tests-config-sample.php
phpcs.xml.dist
phpstan.dist.neon
composer.json
composer.lock
package.json
Expand Down
42 changes: 12 additions & 30 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- main
pull_request:

workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed.
Expand All @@ -20,44 +19,27 @@ concurrency:
permissions: {}

jobs:
# Runs the PHP coding standards checks.
#
# Violations are reported inline with annotations.
#
# Performs the following steps:
# - Checks out the repository.
# - Sets up PHP.
# - Installs Composer dependencies.
# - Make Composer packages available globally.
# - Runs PHPCS on the full codebase (warnings excluded).
# - Ensures version-controlled files are not modified or deleted.
phpcs:
lint:
name: Run coding standards checks
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 20

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v6

- name: Setup cache
uses: actions/cache@v5
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
key: ${{ runner.os }}-${{ hashFiles('composer.json') }} # Note that lock file will change between runs.
path: .cache

- name: Set up PHP
uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
with:
coverage: none

- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1

- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH

- name: Run PHPCS on all files
id: phpcs-files
run: phpcs . -n --report-full
- name: Install dependencies
run: composer install

- name: Ensure version-controlled files are not modified during the checks
run: git diff --exit-code
- name: Lint PHP
run: composer run lint
16 changes: 15 additions & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,26 @@ jobs:
- name: Checkout code
uses: actions/checkout@master

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer

- name: Install Composer dependencies
run: composer install --no-dev --optimize-autoloader --no-interaction

- name: Get tag
id: tag
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Build project
run: git archive -o /tmp/${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.zip --prefix=${{ github.event.repository.name }}/ ${{ steps.tag.outputs.tag }}
run: |
git archive -o /tmp/${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.zip --prefix=${{ github.event.repository.name }}/ ${{ steps.tag.outputs.tag }}
mkdir -p /tmp/vendor-stage/${{ github.event.repository.name }}
cp -r vendor /tmp/vendor-stage/${{ github.event.repository.name }}/vendor
cd /tmp/vendor-stage
zip -r /tmp/${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.zip ${{ github.event.repository.name }}/vendor/

- name: Create WP distribution files
run: bin/bundle.sh
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
*.bak
/.vscode
/vendor/
.wp-env.override.json
.phpunit.result.cache
phpunit.xml
phpcs.xml
phpstan.neon
/tests/phpunit/cache
/tests/phpunit/coverage
wp-tests-config.php
*.swp

# Track placeholders so that empty directories stay in the repo.
!.gitkeep
33 changes: 22 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@ $ git commit -s -m 'My commit message.'

This plugin is ready to use with wp-env for local development, with a default configuration included in the repository. `npm run env` is an alias for `wp-env`:

```sh
# Install wp-env and other dependencies.
$ npm install
- `npm install` to install wp-env and other dependencies.
- `npm run env start` to start the development server. Run `npm run env start -- --xdebug=coverage` to enable Xdebug with test coverage reporting.
- `npm run env logs` to get the logs.
- `npm run env stop` to stop the development server.
- `npm run cli` to run any CLI commands inside the environment, such as `npm run cli -- wp plugin list`.

# Start the development server
$ npm run env start
By default wp-env is configured with PHP 7.4 (our minimum supported version), as well as Airplane Mode to avoid inadvertent requests.

# Get the logs
$ npm run env logs
For linting and static analysis:

# Stop the development server
$ npm run env stop
```
- `npm run lint:php:phpcs` to run PHPCS (configured in [`phpcs.xml.dist`](phpcs.xml.dist)).
- `npm run lint:php:phpstan` to run PHPStan (configured in [`phpstan.dist.neon`](phpstan.dist.neon)).
- `npm run format:php:phpcs` to automatically fix PHPCS issues.
- `npm run format:php:phpstan` to automatically fix PHPStan issues.
- `npm run cli -- composer phpstan-baseline` to update the PHPStan baseline [`tests/phpstan-baseline.neon`](tests/phpstan-baseline.neon) as you fix the reported issues.

### Configuring PHP and WP Versions

By default, wp-env is configured with PHP 7.4 (our minimum supported version), as well as Airplane Mode to avoid inadvertent requests.
To run a specific version of PHP or WP with your local development environment, create a `.wp-env.override.json` file in the root of the repository with the following contents:

```json
{
"phpVersion": "8.5",
"core": "https://wordpress.org/wordpress-6.9.zip"
}
```
Loading
Loading