Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into fix/transients-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHenryIE committed Nov 19, 2024
2 parents c5de37c + a67ac8e commit b7ea72b
Show file tree
Hide file tree
Showing 36 changed files with 2,373 additions and 1,432 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

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

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

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

- name: Cache Composer vendor directory
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
if: "!! env.GIT_DIFF"
- name: Validate composer.json and composer.lock
run: composer validate
if: "!! env.GIT_DIFF"

- name: Install dependencies
run: composer install --no-progress --optimize-autoloader --prefer-dist
if: "!! env.GIT_DIFF"

- name: Fix auto-fixable PHP Code Standards Violations
continue-on-error: true
run: vendor/bin/phpcbf --standard=phpcs.xml

- name: Commit PHPCBF changes on main
if: ${{ github.ref == 'refs/heads/main' }} # only commit on main
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "🤖 PHPCBF"
commit_options: ""
env:
GITHUB_TOKEN: "${{ github.token }}"

- name: Detecting PHP Code Standards Violations
run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF }}
if: "!! env.GIT_DIFF"
run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF_FILTERED }} --report=checkstyle | cs2pr
if: "!! env.GIT_DIFF_FILTERED"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Codecoverage-Main
name: Unit tests + Code coverage report

# Runs PHPUnit unit and Codeception wp-browser wpunit tests, merges the code coverage, commits the html report to
# GitHub Pages, generates a README badge with the coverage percentage.
Expand All @@ -7,15 +7,20 @@ on:
push:
branches:
- main
pull_request:
types: [ opened, reopened, ready_for_review, synchronize ]
branches:
- main
workflow_dispatch:

jobs:

codecoverage-main:
unit-tests:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: tests-wordpress
Expand All @@ -25,31 +30,36 @@ jobs:

strategy:
matrix:
php: [ '7.4' ]
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check does gh-pages branch need to be created
run: |
if [[ $(git branch -l gh-pages) == "" ]]; then
gh_pages_branch_needed=true
else
gh_pages_branch_needed=false
fi
echo "GH_PAGES_BRANCH_NEEDED=$gh_pages_branch_needed" >> $GITHUB_ENV;
mkdir gh-pages
- name: Maybe create gh-pages branch
if: ${{ env.GH_PAGES_BRANCH_NEEDED }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
force_orphan: true
allow_empty_commit: true
commit_message: "🤖 Creating gh-pages branch"
fetch-depth: 0 # attempting to get all branch names.

# - name: Check does gh-pages branch need to be created
# run: |
# git branch -l;
# if [[ $(git branch -l gh-pages) == "" ]]; then
# gh_pages_branch_needed=true;
# echo "gh-pages branch is needed";
# else
# gh_pages_branch_needed=false
# echo "gh-pages branch already exists";
# fi
# echo "GH_PAGES_BRANCH_NEEDED=$gh_pages_branch_needed" >> $GITHUB_ENV;
# mkdir gh-pages
#
# - name: Maybe create gh-pages branch
# if: ${{ env.GH_PAGES_BRANCH_NEEDED }}
# uses: peaceiris/actions-gh-pages@v4
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./gh-pages
# force_orphan: true
# allow_empty_commit: true
# commit_message: "🤖 Creating gh-pages branch"

- name: Checkout GitHub Pages branch for code coverage report
uses: actions/checkout@v3
Expand Down Expand Up @@ -83,10 +93,10 @@ jobs:
mkdir gh-pages/phpunit || true;
- name: Run unit tests
run: XDEBUG_MODE=coverage vendor/bin/phpunit --bootstrap tests/phpunit/bootstrap.php --coverage-php tests/_output/unit.cov || true;
run: XDEBUG_MODE=coverage vendor/bin/phpunit --bootstrap tests/phpunit/bootstrap.php --coverage-php tests/_output/unit.cov

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

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

- name: Commit code coverage to gh-pages
if: ${{ github.ref == 'refs/heads/main' && matrix.php == '7.3' }} # only commit on main, on the PHP version we're using in production.
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: gh-pages
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
return;
}

define( 'NFD_DATA_MODULE_VERSION', '2.6.5' );
define( 'NFD_DATA_MODULE_VERSION', '2.6.6' );

if ( function_exists( 'is_admin' ) && is_admin() ) {
$upgrade_handler = new UpgradeHandler(
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"vendor/bin/phpcbf . --standard=phpcs.xml"
],
"cs-changes": [
"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);"
"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;"
],
"lint": [
"vendor/bin/phpcs . --standard=phpcs.xml -s"
Expand All @@ -84,6 +84,7 @@
"codecept run wpunit"
],
"test-coverage": [
"if [ -d \"tests/_output/merged.cov\" ]; then rm -rf tests/_output/merged.cov; fi;",
"phpunit --bootstrap tests/phpunit/bootstrap.php --coverage-php tests/_output/unit.cov --coverage-text",
"codecept run wpunit --coverage wpunit.cov",
"phpcov merge --php tests/_output/merged.cov --html tests/_output/html tests/_output;",
Expand Down Expand Up @@ -113,15 +114,17 @@
"wpscholar/url": "^1.2.2"
},
"require-dev": {
"10up/wp_mock": "^0.4.2",
"10up/wp_mock": "^0.5.0|^1.0.0",
"bluehost/bluehost-wordpress-plugin": ">=3.1",
"brianhenryie/composer-phpstorm": ">=0.4",
"johnpbloch/wordpress": ">=6.5.3",
"kporras07/composer-symlinks": "^1.2",
"lucatume/wp-browser": "^3.5.8",
"newfold-labs/wp-php-standards": "^1.2.3",
"phpunit/phpcov": "^5.0",
"wpackagist-plugin/woocommerce": ">=9"
"phpunit/phpcov": "^8.2.1",
"wpackagist-plugin/jetpack": "^14.0",
"wpackagist-plugin/woocommerce": ">=9",
"wpackagist-theme/twentytwentyfive": "*"
},
"extra": {
"symlinks": {
Expand Down
Loading

0 comments on commit b7ea72b

Please sign in to comment.