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
33 changes: 22 additions & 11 deletions .distignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
/.distignore
/.editorconfig
/.git
/.gitignore
/.github
/.phpcs.xml.dist
/composer.json
/package.json
/package-lock.json
/phpunit.xml.dist
/tests
# Directories
/.git/
/.github/
/bin/
/node_modules/
/tests/
/vendor/

# Files
.distignore
.editorconfig
.gitattributes
.gitignore
.phpcs.xml.dist
.wp-env.json
.wp-env.override.json
CHANGELOG.md
composer.json
composer.lock
package.json
package-lock.json
phpunit.xml.dist
46 changes: 46 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Configuration for Dependabot version updates
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
groups:
actions:
patterns: ["*"]
labels:
- "dependencies"
reviewers:
- "Automattic/vip-plugins"
commit-message:
prefix: "Actions"
include: "scope"
open-pull-requests-limit: 5

- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
day: "tuesday"
groups:
dev-dependencies:
patterns:
- "automattic/*"
- "dealerdirect/*"
- "php-parallel-lint/*"
- "phpcompatibility/*"
- "phpunit/*"
- "squizlabs/*"
- "yoast/*"
labels:
- "dependencies"
reviewers:
- "Automattic/vip-plugins"
commit-message:
prefix: "Composer"
include: "scope"
open-pull-requests-limit: 5
versioning-strategy: increase-if-necessary
92 changes: 92 additions & 0 deletions .github/workflows/cs-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CS & Lint

on:
pull_request:
paths:
- '.github/workflows/cs-lint.yml'
- '**.php'
- '.phpcs.xml.dist'
- 'phpunit.xml.dist'
- 'composer.json'
push:
branches:
- develop
- trunk
paths:
- '.github/workflows/cs-lint.yml'
- '**.php'
- '.phpcs.xml.dist'
- 'phpunit.xml.dist'
- 'composer.json'
workflow_dispatch:

permissions:
contents: read

jobs:
checkcs:
name: "Basic CS and QA checks"
runs-on: ubuntu-latest

env:
XMLLINT_INDENT: " "

strategy:
matrix:
php: ['8.2', 'latest', '8.5']
fail-fast: false

continue-on-error: ${{ matrix.php == '8.5' }}

steps:
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
with:
php-version: ${{ matrix.php }}
coverage: none
tools: cs2pr

# Show PHP lint violations inline in the file diff.
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
- name: Register PHP lint violations to appear as file diff comments
uses: korelstar/phplint-problem-matcher@cb2b753750ec7bf13a7cde0a476df8c5605bdfb1 # v1.2.0

# Show XML violations inline in the file diff.
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
- name: Register XML violations to appear as file diff comments
uses: korelstar/xmllint-problem-matcher@1bd292d642ddf3d369d02aaa8b262834d61198c0 # v1.2.0

- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false

# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- name: Validate Composer installation
run: composer validate --no-check-all

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1

# Lint PHP.
- name: Lint PHP against parse errors
run: composer lint-ci | cs2pr

# Needed as runs-on: system doesn't have xml-lint by default.
# @link https://github.com/marketplace/actions/xml-lint
- name: Lint phpunit.xml.dist
uses: ChristophWurst/xmllint-action@7c54ff113fc0f6d4588a15cb4dfe31b6ecca5212 # v1.2.1
with:
xml-file: ./phpunit.xml.dist
xml-schema-file: ./vendor/phpunit/phpunit/phpunit.xsd

# Check the code-style consistency of the PHP files.
- name: Check PHP code style
continue-on-error: true
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml

- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml
82 changes: 82 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Run PHPUnit

on:
pull_request:
paths:
- '.github/workflows/integration.yml'
- '**.php'
- 'phpunit.xml.dist'
- 'composer.json'
push:
branches:
- develop
- trunk
paths:
- '.github/workflows/integration.yml'
- '**.php'
- 'phpunit.xml.dist'
- 'composer.json'
workflow_dispatch:

permissions:
contents: read

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
runs-on: ubuntu-latest

env:
WP_VERSION: ${{ matrix.wordpress }}

strategy:
matrix:
include:
# Check lowest supported WP version, with the lowest supported PHP.
- wordpress: '6.6'
php: '8.2'
# Check latest WP with the highest supported PHP.
- wordpress: 'latest'
php: 'latest'
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false

- name: Install wordpress environment
run: npm install -g @wordpress/env

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
with:
php-version: ${{ matrix.php }}

- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
with:
composer-options: --ignore-platform-req=php+

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Setup wp-env
run: wp-env start
env:
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wordpress == 'latest' && 'master' || matrix.wordpress }}

- name: Run integration tests (single site)
run: composer test:integration

- name: Run integration tests (multisite)
run: composer test:integration-ms
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
/.phpunit.cache/
/phpunit.xml
# Dependencies
/node_modules/
/vendor/

# Composer
/composer.lock

# Tests
/.phpunit.cache/

# Local config overrides
/.phpcs.xml
/phpcs.xml
/composer.lock
/phpunit.xml
/.wp-env.override.json
1 change: 1 addition & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@

<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
</ruleset>
37 changes: 23 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
"require-dev": {
"automattic/vipwpcs": "^3",
"php-parallel-lint/php-parallel-lint": "^1.0",
"phpcompatibility/phpcompatibility-wp": "^2.1"
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^9.6",
"yoast/wp-test-utils": "^1.2"
},
"autoload-dev": {
"psr-4": {
"Automattic\\BuddyPressVIPGo\\Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
Expand All @@ -35,25 +42,27 @@
"sort-packages": true
},
"scripts": {
"cs": [
"@php ./vendor/bin/phpcs -q"
],
"cs-fix": [
"@php ./vendor/bin/phpcbf -q"
],
"coverage": "@php ./vendor/bin/phpunit --coverage-html ./build/coverage-html",
"coverage-ci": "@php ./vendor/bin/phpunit",
"cs": "@php ./vendor/bin/phpcs -q",
"cs-fix": "@php ./vendor/bin/phpcbf -q",
"i18n": "@php wp i18n make-pot . ./languages/buddypress-vip-go.pot",
"lint": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
],
"lint-ci": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle"
]
"lint": "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git",
"lint-ci": "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle",
"test:unit": "@php ./vendor/bin/phpunit --testsuite Unit",
"test:integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/buddypress-vip-go ./vendor/bin/phpunit --testsuite WP_Tests",
"test:integration-ms": "wp-env run tests-cli --env-cwd=wp-content/plugins/buddypress-vip-go /bin/bash -c 'WP_MULTISITE=1 ./vendor/bin/phpunit --testsuite WP_Tests'"
},
"scripts-descriptions": {
"coverage": "Run tests with code coverage reporting",
"coverage-ci": "Run tests with code coverage reporting and send results to stdout",
"cs": "Run PHP Code Sniffer",
"cs-fix": "Run PHP Code Sniffer and fix violations",
"i18n": "Generate a POT file for translation",
"lint": "Run PHP linting",
"lint-ci": "Run PHP linting and send results to stdout"
"lint-ci": "Run PHP linting and send results to stdout",
"test:unit": "Run unit tests",
"test:integration": "Run integration tests",
"test:integration-ms": "Run integration tests in multisite mode"
}
}
2 changes: 1 addition & 1 deletion files.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ function vipbp_handle_avatar_capture( $_, $data, $item_id ) {
// Figure out the MIME type.
$finfo = finfo_open( FILEINFO_MIME_TYPE );
$mime_type = finfo_file( $finfo, $tmp_name );
finfo_close( $finfo );
// Note: finfo_close() removed as it's deprecated in PHP 8.5+.

$new_tmp_name = str_replace( '.tmp', '.' . array_search( $mime_type, get_allowed_mime_types(), true ), $tmp_name );
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_rename
Expand Down
33 changes: 33 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
>
<testsuites>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
<testsuite name="WP_Tests">
<directory>./tests/Integration</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">./</directory>
</include>
<exclude>
<directory>./node_modules</directory>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
</phpunit>
Loading