Skip to content

Commit

Permalink
Merge pull request #2303 from 10up/feature/php-compatibility-gh-action
Browse files Browse the repository at this point in the history
PHP Compatibility GH Action
  • Loading branch information
felipeelia authored Aug 12, 2021
2 parents da4ca4d + 2b055c5 commit 0bceec4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 10 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: PHP Compatibility

env:
COMPOSER_VERSION: "1"
COMPOSER_CACHE: "${{ github.workspace }}/.composer-cache"

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- develop
- master
pull_request:
branches:
- develop

jobs:
php_compatibility:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]

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

- name: Set standard 10up cache directories
run: |
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}"
- name: Prepare composer cache
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: prestissimo, composer:v1

- name: Install dependencies
run: composer install

- name: Check PHP Compatibility
run: ./vendor/bin/phpcs -p elasticpress.php includes --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion ${{ matrix.php }}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"10up/phpcs-composer": "dev-master",
"wpackagist-plugin/woocommerce":"*",
"phpunit/phpunit": "^7",
"10up/wpacceptance": "dev-master"
"10up/wpacceptance": "dev-master",
"phpcompatibility/phpcompatibility-wp": "*"
},
"scripts": {
"lint": "phpcs elasticpress.php includes",
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/classes/Indexable/Comment/QueryIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function maybe_filter_query( $results, WP_Comment_Query $query ) {
* @return array
*/
protected function format_hits_as_comments( $comments, $new_comments, $query_vars ) {
$hierarchical = $query_vars['hierarchical'] ?? false;
$hierarchical = isset( $query_vars['hierarchical'] ) ? $query_vars['hierarchical'] : false;

foreach ( $comments as $comment_array ) {
$comment = new \WP_Comment( (object) $comment_array );
Expand Down

0 comments on commit 0bceec4

Please sign in to comment.