Skip to content

Commit ea24d67

Browse files
authored
Merge pull request #27 from Automattic/standardize/add-dependabot
2 parents dcc21d4 + bfc4a76 commit ea24d67

File tree

15 files changed

+457
-29
lines changed

15 files changed

+457
-29
lines changed

.distignore

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
/.distignore
2-
/.editorconfig
3-
/.git
4-
/.gitignore
5-
/.github
6-
/.phpcs.xml.dist
7-
/composer.json
8-
/package.json
9-
/package-lock.json
10-
/phpunit.xml.dist
11-
/tests
1+
# Directories
2+
/.git/
3+
/.github/
4+
/bin/
5+
/node_modules/
6+
/tests/
7+
/vendor/
8+
9+
# Files
10+
.distignore
11+
.editorconfig
12+
.gitattributes
13+
.gitignore
14+
.phpcs.xml.dist
15+
.wp-env.json
16+
.wp-env.override.json
17+
CHANGELOG.md
18+
composer.json
19+
composer.lock
20+
package.json
21+
package-lock.json
22+
phpunit.xml.dist

.github/dependabot.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Configuration for Dependabot version updates
2+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
3+
4+
version: 2
5+
updates:
6+
- package-ecosystem: "github-actions"
7+
directory: "/"
8+
schedule:
9+
interval: "weekly"
10+
day: "monday"
11+
groups:
12+
actions:
13+
patterns: ["*"]
14+
labels:
15+
- "dependencies"
16+
reviewers:
17+
- "Automattic/vip-plugins"
18+
commit-message:
19+
prefix: "Actions"
20+
include: "scope"
21+
open-pull-requests-limit: 5
22+
23+
- package-ecosystem: "composer"
24+
directory: "/"
25+
schedule:
26+
interval: "weekly"
27+
day: "tuesday"
28+
groups:
29+
dev-dependencies:
30+
patterns:
31+
- "automattic/*"
32+
- "dealerdirect/*"
33+
- "php-parallel-lint/*"
34+
- "phpcompatibility/*"
35+
- "phpunit/*"
36+
- "squizlabs/*"
37+
- "yoast/*"
38+
labels:
39+
- "dependencies"
40+
reviewers:
41+
- "Automattic/vip-plugins"
42+
commit-message:
43+
prefix: "Composer"
44+
include: "scope"
45+
open-pull-requests-limit: 5
46+
versioning-strategy: increase-if-necessary

.github/workflows/cs-lint.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CS & Lint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/cs-lint.yml'
7+
- '**.php'
8+
- '.phpcs.xml.dist'
9+
- 'phpunit.xml.dist'
10+
- 'composer.json'
11+
push:
12+
branches:
13+
- develop
14+
- trunk
15+
paths:
16+
- '.github/workflows/cs-lint.yml'
17+
- '**.php'
18+
- '.phpcs.xml.dist'
19+
- 'phpunit.xml.dist'
20+
- 'composer.json'
21+
workflow_dispatch:
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
checkcs:
28+
name: "Basic CS and QA checks"
29+
runs-on: ubuntu-latest
30+
31+
env:
32+
XMLLINT_INDENT: " "
33+
34+
strategy:
35+
matrix:
36+
php: ['8.2', 'latest', '8.5']
37+
fail-fast: false
38+
39+
continue-on-error: ${{ matrix.php == '8.5' }}
40+
41+
steps:
42+
- name: Setup PHP ${{ matrix.php }}
43+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
44+
with:
45+
php-version: ${{ matrix.php }}
46+
coverage: none
47+
tools: cs2pr
48+
49+
# Show PHP lint violations inline in the file diff.
50+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
51+
- name: Register PHP lint violations to appear as file diff comments
52+
uses: korelstar/phplint-problem-matcher@cb2b753750ec7bf13a7cde0a476df8c5605bdfb1 # v1.2.0
53+
54+
# Show XML violations inline in the file diff.
55+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
56+
- name: Register XML violations to appear as file diff comments
57+
uses: korelstar/xmllint-problem-matcher@1bd292d642ddf3d369d02aaa8b262834d61198c0 # v1.2.0
58+
59+
- name: Checkout code
60+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
61+
with:
62+
persist-credentials: false
63+
64+
# Validate the composer.json file.
65+
# @link https://getcomposer.org/doc/03-cli.md#validate
66+
- name: Validate Composer installation
67+
run: composer validate --no-check-all
68+
69+
# Install dependencies and handle caching in one go.
70+
# @link https://github.com/marketplace/actions/install-composer-dependencies
71+
- name: Install Composer dependencies
72+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
73+
74+
# Lint PHP.
75+
- name: Lint PHP against parse errors
76+
run: composer lint-ci | cs2pr
77+
78+
# Needed as runs-on: system doesn't have xml-lint by default.
79+
# @link https://github.com/marketplace/actions/xml-lint
80+
- name: Lint phpunit.xml.dist
81+
uses: ChristophWurst/xmllint-action@7c54ff113fc0f6d4588a15cb4dfe31b6ecca5212 # v1.2.1
82+
with:
83+
xml-file: ./phpunit.xml.dist
84+
xml-schema-file: ./vendor/phpunit/phpunit/phpunit.xsd
85+
86+
# Check the code-style consistency of the PHP files.
87+
- name: Check PHP code style
88+
continue-on-error: true
89+
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
90+
91+
- name: Show PHPCS results in PR
92+
run: cs2pr ./phpcs-report.xml

.github/workflows/integration.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Run PHPUnit
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/integration.yml'
7+
- '**.php'
8+
- 'phpunit.xml.dist'
9+
- 'composer.json'
10+
push:
11+
branches:
12+
- develop
13+
- trunk
14+
paths:
15+
- '.github/workflows/integration.yml'
16+
- '**.php'
17+
- 'phpunit.xml.dist'
18+
- 'composer.json'
19+
workflow_dispatch:
20+
21+
permissions:
22+
contents: read
23+
24+
# Cancels all previous workflow runs for the same branch that have not yet completed.
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: true
28+
29+
jobs:
30+
test:
31+
name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
32+
runs-on: ubuntu-latest
33+
34+
env:
35+
WP_VERSION: ${{ matrix.wordpress }}
36+
37+
strategy:
38+
matrix:
39+
include:
40+
# Check lowest supported WP version, with the lowest supported PHP.
41+
- wordpress: '6.6'
42+
php: '8.2'
43+
# Check latest WP with the highest supported PHP.
44+
- wordpress: 'latest'
45+
php: 'latest'
46+
fail-fast: false
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
51+
with:
52+
persist-credentials: false
53+
54+
- name: Install wordpress environment
55+
run: npm install -g @wordpress/env
56+
57+
- name: Setup PHP ${{ matrix.php }}
58+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
59+
with:
60+
php-version: ${{ matrix.php }}
61+
62+
- name: Install Composer dependencies
63+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1
64+
with:
65+
composer-options: --ignore-platform-req=php+
66+
67+
- name: Setup problem matchers for PHP
68+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
69+
70+
- name: Setup problem matchers for PHPUnit
71+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
72+
73+
- name: Setup wp-env
74+
run: wp-env start
75+
env:
76+
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wordpress == 'latest' && 'master' || matrix.wordpress }}
77+
78+
- name: Run integration tests (single site)
79+
run: composer test:integration
80+
81+
- name: Run integration tests (multisite)
82+
run: composer test:integration-ms

.gitignore

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
/.phpunit.cache/
2-
/phpunit.xml
1+
# Dependencies
32
/node_modules/
43
/vendor/
4+
5+
# Composer
6+
/composer.lock
7+
8+
# Tests
9+
/.phpunit.cache/
10+
11+
# Local config overrides
512
/.phpcs.xml
613
/phpcs.xml
7-
/composer.lock
14+
/phpunit.xml
15+
/.wp-env.override.json

.phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535

3636
<exclude-pattern>*/node_modules/*</exclude-pattern>
3737
<exclude-pattern>*/vendor/*</exclude-pattern>
38+
<exclude-pattern>*/tests/*</exclude-pattern>
3839
</ruleset>

composer.json

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
"require-dev": {
2626
"automattic/vipwpcs": "^3",
2727
"php-parallel-lint/php-parallel-lint": "^1.0",
28-
"phpcompatibility/phpcompatibility-wp": "^2.1"
28+
"phpcompatibility/phpcompatibility-wp": "^2.1",
29+
"phpunit/phpunit": "^9.6",
30+
"yoast/wp-test-utils": "^1.2"
31+
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"Automattic\\BuddyPressVIPGo\\Tests\\": "tests/"
35+
}
2936
},
3037
"config": {
3138
"allow-plugins": {
@@ -35,25 +42,27 @@
3542
"sort-packages": true
3643
},
3744
"scripts": {
38-
"cs": [
39-
"@php ./vendor/bin/phpcs -q"
40-
],
41-
"cs-fix": [
42-
"@php ./vendor/bin/phpcbf -q"
43-
],
45+
"coverage": "@php ./vendor/bin/phpunit --coverage-html ./build/coverage-html",
46+
"coverage-ci": "@php ./vendor/bin/phpunit",
47+
"cs": "@php ./vendor/bin/phpcs -q",
48+
"cs-fix": "@php ./vendor/bin/phpcbf -q",
4449
"i18n": "@php wp i18n make-pot . ./languages/buddypress-vip-go.pot",
45-
"lint": [
46-
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
47-
],
48-
"lint-ci": [
49-
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle"
50-
]
50+
"lint": "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git",
51+
"lint-ci": "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle",
52+
"test:unit": "@php ./vendor/bin/phpunit --testsuite Unit",
53+
"test:integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/buddypress-vip-go ./vendor/bin/phpunit --testsuite WP_Tests",
54+
"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'"
5155
},
5256
"scripts-descriptions": {
57+
"coverage": "Run tests with code coverage reporting",
58+
"coverage-ci": "Run tests with code coverage reporting and send results to stdout",
5359
"cs": "Run PHP Code Sniffer",
5460
"cs-fix": "Run PHP Code Sniffer and fix violations",
5561
"i18n": "Generate a POT file for translation",
5662
"lint": "Run PHP linting",
57-
"lint-ci": "Run PHP linting and send results to stdout"
63+
"lint-ci": "Run PHP linting and send results to stdout",
64+
"test:unit": "Run unit tests",
65+
"test:integration": "Run integration tests",
66+
"test:integration-ms": "Run integration tests in multisite mode"
5867
}
5968
}

files.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ function vipbp_handle_avatar_capture( $_, $data, $item_id ) {
456456
// Figure out the MIME type.
457457
$finfo = finfo_open( FILEINFO_MIME_TYPE );
458458
$mime_type = finfo_file( $finfo, $tmp_name );
459-
finfo_close( $finfo );
459+
// Note: finfo_close() removed as it's deprecated in PHP 8.5+.
460460

461461
$new_tmp_name = str_replace( '.tmp', '.' . array_search( $mime_type, get_allowed_mime_types(), true ), $tmp_name );
462462
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_rename

phpunit.xml.dist

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
5+
bootstrap="tests/bootstrap.php"
6+
backupGlobals="false"
7+
colors="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
beStrictAboutTestsThatDoNotTestAnything="true"
12+
beStrictAboutOutputDuringTests="true"
13+
>
14+
<testsuites>
15+
<testsuite name="Unit">
16+
<directory>./tests/Unit</directory>
17+
</testsuite>
18+
<testsuite name="WP_Tests">
19+
<directory>./tests/Integration</directory>
20+
</testsuite>
21+
</testsuites>
22+
23+
<coverage>
24+
<include>
25+
<directory suffix=".php">./</directory>
26+
</include>
27+
<exclude>
28+
<directory>./node_modules</directory>
29+
<directory>./tests</directory>
30+
<directory>./vendor</directory>
31+
</exclude>
32+
</coverage>
33+
</phpunit>

0 commit comments

Comments
 (0)