Skip to content

Commit b7ea72b

Browse files
committed
Merge remote-tracking branch 'origin' into fix/transients-filters
2 parents c5de37c + a67ac8e commit b7ea72b

36 files changed

+2373
-1432
lines changed

.github/workflows/lint.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323

2424
- name: Checkout
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2626

2727
# User PHP 7.4 here for compatibility with the WordPress codesniffer rules.
2828
- name: Setup PHP
@@ -32,32 +32,41 @@ jobs:
3232
coverage: none
3333
tools: composer, cs2pr
3434

35-
- uses: technote-space/get-diff-action@v6
35+
- uses: technote-space/get-diff-action@v6 # repo is archived.
3636
with:
37-
SUFFIX_FILTER: .php
37+
PATTERNS: ./**/*.php
3838

3939
- name: Get Composer cache directory
4040
id: composer-cache
4141
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
42-
if: "!! env.GIT_DIFF"
4342

4443
- name: Cache Composer vendor directory
45-
uses: actions/cache@v3
44+
uses: actions/cache@v4
4645
with:
4746
path: ${{ steps.composer-cache.outputs.dir }}
4847
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
4948
restore-keys: |
5049
${{ runner.os }}-composer-
51-
if: "!! env.GIT_DIFF"
5250
5351
- name: Validate composer.json and composer.lock
5452
run: composer validate
55-
if: "!! env.GIT_DIFF"
5653

5754
- name: Install dependencies
5855
run: composer install --no-progress --optimize-autoloader --prefer-dist
59-
if: "!! env.GIT_DIFF"
56+
57+
- name: Fix auto-fixable PHP Code Standards Violations
58+
continue-on-error: true
59+
run: vendor/bin/phpcbf --standard=phpcs.xml
60+
61+
- name: Commit PHPCBF changes on main
62+
if: ${{ github.ref == 'refs/heads/main' }} # only commit on main
63+
uses: stefanzweifel/git-auto-commit-action@v5
64+
with:
65+
commit_message: "🤖 PHPCBF"
66+
commit_options: ""
67+
env:
68+
GITHUB_TOKEN: "${{ github.token }}"
6069

6170
- name: Detecting PHP Code Standards Violations
62-
run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF }}
63-
if: "!! env.GIT_DIFF"
71+
run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF_FILTERED }} --report=checkstyle | cs2pr
72+
if: "!! env.GIT_DIFF_FILTERED"

.github/workflows/codecoverage-main.yml renamed to .github/workflows/unit-tests-and-coverage-report.yml

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Codecoverage-Main
1+
name: Unit tests + Code coverage report
22

33
# Runs PHPUnit unit and Codeception wp-browser wpunit tests, merges the code coverage, commits the html report to
44
# GitHub Pages, generates a README badge with the coverage percentage.
@@ -7,15 +7,20 @@ on:
77
push:
88
branches:
99
- main
10+
pull_request:
11+
types: [ opened, reopened, ready_for_review, synchronize ]
12+
branches:
13+
- main
14+
workflow_dispatch:
1015

1116
jobs:
1217

13-
codecoverage-main:
18+
unit-tests:
1419
runs-on: ubuntu-latest
1520

1621
services:
1722
mysql:
18-
image: mysql:8.0
23+
image: mysql:5.7
1924
env:
2025
MYSQL_ROOT_PASSWORD: password
2126
MYSQL_DATABASE: tests-wordpress
@@ -25,31 +30,36 @@ jobs:
2530

2631
strategy:
2732
matrix:
28-
php: [ '7.4' ]
33+
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
2934

3035
steps:
3136
- name: Checkout
3237
uses: actions/checkout@v3
33-
34-
- name: Check does gh-pages branch need to be created
35-
run: |
36-
if [[ $(git branch -l gh-pages) == "" ]]; then
37-
gh_pages_branch_needed=true
38-
else
39-
gh_pages_branch_needed=false
40-
fi
41-
echo "GH_PAGES_BRANCH_NEEDED=$gh_pages_branch_needed" >> $GITHUB_ENV;
42-
mkdir gh-pages
43-
44-
- name: Maybe create gh-pages branch
45-
if: ${{ env.GH_PAGES_BRANCH_NEEDED }}
46-
uses: peaceiris/actions-gh-pages@v4
4738
with:
48-
github_token: ${{ secrets.GITHUB_TOKEN }}
49-
publish_dir: ./gh-pages
50-
force_orphan: true
51-
allow_empty_commit: true
52-
commit_message: "🤖 Creating gh-pages branch"
39+
fetch-depth: 0 # attempting to get all branch names.
40+
41+
# - name: Check does gh-pages branch need to be created
42+
# run: |
43+
# git branch -l;
44+
# if [[ $(git branch -l gh-pages) == "" ]]; then
45+
# gh_pages_branch_needed=true;
46+
# echo "gh-pages branch is needed";
47+
# else
48+
# gh_pages_branch_needed=false
49+
# echo "gh-pages branch already exists";
50+
# fi
51+
# echo "GH_PAGES_BRANCH_NEEDED=$gh_pages_branch_needed" >> $GITHUB_ENV;
52+
# mkdir gh-pages
53+
#
54+
# - name: Maybe create gh-pages branch
55+
# if: ${{ env.GH_PAGES_BRANCH_NEEDED }}
56+
# uses: peaceiris/actions-gh-pages@v4
57+
# with:
58+
# github_token: ${{ secrets.GITHUB_TOKEN }}
59+
# publish_dir: ./gh-pages
60+
# force_orphan: true
61+
# allow_empty_commit: true
62+
# commit_message: "🤖 Creating gh-pages branch"
5363

5464
- name: Checkout GitHub Pages branch for code coverage report
5565
uses: actions/checkout@v3
@@ -83,10 +93,10 @@ jobs:
8393
mkdir gh-pages/phpunit || true;
8494
8595
- name: Run unit tests
86-
run: XDEBUG_MODE=coverage vendor/bin/phpunit --bootstrap tests/phpunit/bootstrap.php --coverage-php tests/_output/unit.cov || true;
96+
run: XDEBUG_MODE=coverage vendor/bin/phpunit --bootstrap tests/phpunit/bootstrap.php --coverage-php tests/_output/unit.cov
8797

8898
- name: Run wpunit tests
89-
run: XDEBUG_MODE=coverage vendor/bin/codecept run wpunit --coverage tests/_output/wpunit.cov --debug || true;
99+
run: XDEBUG_MODE=coverage vendor/bin/codecept run wpunit --coverage tests/_output/wpunit.cov --debug
90100

91101
- name: Merge code coverage
92102
run: vendor/bin/phpcov merge --clover gh-pages/phpunit/clover.xml --php gh-pages/phpunit/phpunit.cov --html gh-pages/phpunit/html/ tests/_output/;
@@ -102,6 +112,7 @@ jobs:
102112
run: php-coverage-badger gh-pages/phpunit/clover.xml gh-pages/phpunit/coverage.svg
103113

104114
- name: Commit code coverage to gh-pages
115+
if: ${{ github.ref == 'refs/heads/main' && matrix.php == '7.3' }} # only commit on main, on the PHP version we're using in production.
105116
uses: stefanzweifel/git-auto-commit-action@v5
106117
with:
107118
repository: gh-pages

bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
return;
2121
}
2222

23-
define( 'NFD_DATA_MODULE_VERSION', '2.6.5' );
23+
define( 'NFD_DATA_MODULE_VERSION', '2.6.6' );
2424

2525
if ( function_exists( 'is_admin' ) && is_admin() ) {
2626
$upgrade_handler = new UpgradeHandler(

composer.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"vendor/bin/phpcbf . --standard=phpcs.xml"
7272
],
7373
"cs-changes": [
74-
"updated_files=$( git status | grep '\\(new file\\|modified\\):\\s.*.php$' | cut -c14- | awk '{ printf(\"%s \", $0) }' ); echo \"\\nChecking\"$(git status | grep '\\(new file\\|modified\\):\\s.*.php$' | tail -n+2 | wc -l)\" files\"; phpcbf $(echo $updated_files); phpcs $(echo $updated_files);"
74+
"updated_files=$(echo $(git diff --name-only `git merge-base origin/main HEAD` | grep php)); if [ -n \"$updated_files\" ]; then phpcbf $(echo $updated_files); phpcs $(echo $updated_files); else echo \"No modified .php files for PHPCS.\"; fi;"
7575
],
7676
"lint": [
7777
"vendor/bin/phpcs . --standard=phpcs.xml -s"
@@ -84,6 +84,7 @@
8484
"codecept run wpunit"
8585
],
8686
"test-coverage": [
87+
"if [ -d \"tests/_output/merged.cov\" ]; then rm -rf tests/_output/merged.cov; fi;",
8788
"phpunit --bootstrap tests/phpunit/bootstrap.php --coverage-php tests/_output/unit.cov --coverage-text",
8889
"codecept run wpunit --coverage wpunit.cov",
8990
"phpcov merge --php tests/_output/merged.cov --html tests/_output/html tests/_output;",
@@ -113,15 +114,17 @@
113114
"wpscholar/url": "^1.2.2"
114115
},
115116
"require-dev": {
116-
"10up/wp_mock": "^0.4.2",
117+
"10up/wp_mock": "^0.5.0|^1.0.0",
117118
"bluehost/bluehost-wordpress-plugin": ">=3.1",
118119
"brianhenryie/composer-phpstorm": ">=0.4",
119120
"johnpbloch/wordpress": ">=6.5.3",
120121
"kporras07/composer-symlinks": "^1.2",
121122
"lucatume/wp-browser": "^3.5.8",
122123
"newfold-labs/wp-php-standards": "^1.2.3",
123-
"phpunit/phpcov": "^5.0",
124-
"wpackagist-plugin/woocommerce": ">=9"
124+
"phpunit/phpcov": "^8.2.1",
125+
"wpackagist-plugin/jetpack": "^14.0",
126+
"wpackagist-plugin/woocommerce": ">=9",
127+
"wpackagist-theme/twentytwentyfive": "*"
125128
},
126129
"extra": {
127130
"symlinks": {

0 commit comments

Comments
 (0)