Skip to content
Merged
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
53 changes: 39 additions & 14 deletions .distignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
# Files and folders NOT shipped to WordPress.org.

# VCS / CI / editor
/.git
/.github
/.gitignore
/.gitattributes
/.distignore
/.editorconfig
/.vscode
/.idea
/xdebug
/.wp-env.json

# Tooling and tests
/tests
/scripts
/docs
/xdebug
/phpcs.xml.dist
/phpstan.neon.dist
/phpstan-baseline.neon
/phpunit.xml.dist
/phpunit-integration.xml.dist
/composer.json
/composer.lock
/package.json
/package-lock.json
/node_modules

# Caches and reports
/.phpstan.cache
/.phpunit.cache
/.phpunit.result.cache
/.phpunit-integration.result.cache
/coverage
/coverage.xml
/clover.xml

# Local / Docker
DOCKER_ENV
Dockerfile-php-build
output.log

.distignore
.gitignore
.gitattributes
.editorconfig
CONTRIBUTING.md
docker-compose.yaml
composer.json
composer.lock
Dockerfile.wordpress
docker-compose.yaml
docker_tag
phpcs.xml
output.log
phpcs.txt
phpunit.xml
ruleset.xml
CONTRIBUTING.md

# OS
.DS_Store
Thumbs.db
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yml,yaml,json,md,neon}]
indent_style = space
indent_size = 2

[*.{js,jsx,ts,tsx,scss,css}]
indent_style = tab
indent_size = 4

[*.md]
trim_trailing_whitespace = false
27 changes: 25 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# Auto detect text files and perform LF normalization
* text=auto
# Normalise line endings
* text=auto eol=lf

# Binary
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.zip binary

# Exclude from archive exports
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.distignore export-ignore
/.editorconfig export-ignore
/.wp-env.json export-ignore
/tests export-ignore
/scripts export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml.dist export-ignore
/phpunit-integration.xml.dist export-ignore
/package.json export-ignore
14 changes: 12 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,21 @@

## Coding Standards & Security

- WordPress Coding Standards via `ruleset.xml` (WordPress standard, but short array syntax `[]` is allowed and the `WordPress.Files.FileName` rule is disabled)
- WordPress Coding Standards (WPCS 3.x) via `phpcs.xml.dist`: short array syntax `[]` is allowed, Yoda conditions are not required, and the `WordPress.Files.FileName` rule is disabled
- Classes, folders and file names are PascalCase and follow PSR-4 (class `AddressCodec` lives in `src/EmailHealth/AddressCodec.php`); functions, methods and variables are `lower_snake_case`
- Escape all output (`esc_html`, `esc_attr`, `esc_url`), sanitize all input, use nonces and capability checks for admin actions, use `$wpdb->prepare()` for queries

## Releases & Tooling

- `scripts/bump-version.sh <version>` updates the version in `readme.txt`, the `scanfully.php` header, and the `SCANFULLY_VERSION` constant
- Releasing is done via the GitHub release workflow (`.github/workflows/release.yml`), which deploys to WordPress.org SVN
- There are no PHPUnit tests in this repo; verify changes manually in the local WP install
- `vendor/` is not committed; run `composer install` after cloning (the release workflow runs a no-dev install)

## Quality gates

- `composer lint` / `composer lint:fix` / `composer lint:strict`: PHPCS (errors only / auto-fix / including warnings)
- `composer stan`: PHPStan (config in `phpstan.neon.dist`, WordPress, WooCommerce and Action Scheduler symbols resolved). New baseline entries need a `# BASELINE:` justification
- `composer test`: PHPUnit unit suite under `tests/Unit` (Brain Monkey via `yoast/wp-test-utils`, no WordPress runtime). Test files are PascalCase and end in `Test.php`, e.g. `tests/Unit/EmailHealth/AddressCodecTest.php`
- `npm run env:start` then `npm run test:integration`: PHPUnit integration suite under `tests/Integration`, run inside wp-env (PHP 7.4, needs Docker)
- `composer qa`: lint, stan and unit tests in one go
- CI (`.github/workflows/qa.yml`) runs these on PHP 7.4 to 8.4
138 changes: 138 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: QA

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

concurrency:
group: qa-${{ github.ref }}
cancel-in-progress: true

jobs:
baseline-drift:
name: PHPStan baseline drift
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check phpstan-baseline.neon additions are justified
shell: bash
run: |
set -euo pipefail
BASE="origin/${{ github.base_ref }}"
git fetch origin "${{ github.base_ref }}" --depth=1

# Count lines added to the baseline that look like a new ignore entry.
# Commented lines (such as the example in the file header) are skipped.
ADDED=$(git diff "$BASE"...HEAD -- phpstan-baseline.neon \
| grep -E '^\+[[:space:]]*message:' \
| wc -l \
| tr -d ' ')

if [ "$ADDED" = "0" ]; then
echo "No new baseline entries. OK."
exit 0
fi

echo "Detected $ADDED new baseline entries; checking for matching BASELINE: blocks..."

JUSTIFIED=$(git diff "$BASE"...HEAD -- phpstan-baseline.neon \
| grep -E '^\+\s*#\s*BASELINE:' \
| wc -l \
| tr -d ' ')

if [ "$JUSTIFIED" -lt "$ADDED" ]; then
echo "::error::phpstan-baseline.neon grew by $ADDED entries but only $JUSTIFIED BASELINE: justifications were added."
echo "Add a '# BASELINE: <reason>' comment block per new entry, optionally followed by '# Upstream: <link>'."
exit 1
fi

echo "Baseline additions are justified. OK."

php:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- uses: actions/checkout@v4

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ matrix.php }}-

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

- name: PHPCS (errors only)
run: composer lint

- name: PHPCS (warnings) - informational
continue-on-error: true
run: composer lint:strict

- name: PHPStan
run: composer stan

- name: PHPUnit - Unit
run: composer test

- name: Upload coverage
if: matrix.php == '8.3'
uses: actions/upload-artifact@v4
with:
name: coverage
path: |
coverage/
coverage.xml
if-no-files-found: ignore

integration:
name: PHPUnit - Integration (wp-env)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

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

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install npm dependencies
run: npm install --no-audit --no-fund

- name: Start wp-env
run: npm run env:start

- name: Run integration suite
run: npm run test:integration
27 changes: 26 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Dependencies (installed by Composer; the release workflow runs a no-dev install)
/vendor/
/node_modules/

# PHPUnit
/.phpunit.cache/
/.phpunit.result.cache
/.phpunit-integration.result.cache
/coverage/
/coverage.xml
/clover.xml

# PHPStan
/.phpstan.cache/

# Local
/tmp/
/dev/
/.idea/
phpcs.txt

# OS / Editor
.DS_Store
Thumbs.db
.idea/
.vscode/
*.swp
*~

# Logs
*.log
13 changes: 13 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"core": "WordPress/WordPress#6.8",
"phpVersion": "7.4",
"plugins": [ "." ],
"themes": [],
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": false,
"SCRIPT_DEBUG": true
},
"mappings": {}
}
Loading
Loading