Skip to content

AI Proofread: Get and apply suggestions #61005

AI Proofread: Get and apply suggestions

AI Proofread: Get and apply suggestions #61005

# This Github Action is temporary, to run the development version of PHPCompatibility to test for PHP 8 issues.
#
# Once we're getting that by default (likely due to an upgrade of automattic/jetpack-codesniffer to pull a version of phpcompatibility/phpcompatibility-wp that pulls phpcompatibility/php-compatibility 10.0+),
# this action and .github/files/phpcompatibility-dev-phpcs.xml should be deleted.
name: PHP Compatibility
on: pull_request
concurrency:
group: phpcompatibility-dev-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
env:
COMPOSER_ROOT_VERSION: "dev-trunk"
jobs:
changed_files:
name: detect changed files
runs-on: ubuntu-latest
timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds.
outputs:
php: ${{ steps.filter.outputs.php }}
misc: ${{ steps.filter.outputs.misc }}
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
php:
# If any PHP file changed, they need checking.
- '**.php'
misc:
# If composer or phpcs config changed, there may be a new standard.
- 'composer.json'
- 'composer.lock'
- '.phpcs.config.xml'
- '.phpcs.xml.dist'
- '.phpcsignore'
- '**/.phpcs.dir.xml'
- '**/.phpcsignore'
# If other files used by this workflow changed, run it to test those changes.
- '.github/files/phpcompatibility-dev-phpcs.xml'
- '.github/matchers/phpcs-problem-matcher.json'
- '.github/workflows/phpcompatibility-dev.yml'
phpcompatibility:
name: dev branch for PHP 8.0
runs-on: ubuntu-latest
needs: changed_files
if: needs.changed_files.outputs.php == 'true' || needs.changed_files.outputs.misc == 'true'
timeout-minutes: 5 # 2021-01-18: Successful runs seem to take ~1 minute.
steps:
- uses: actions/checkout@v4
- name: Setup tools
uses: ./.github/actions/tool-setup
with:
node: false
- name: Install dependencies
run: composer install
- name: Upgrade PHPCompatibility
run: |
if [[ -e vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewNonCapturingCatchSniff.php ]]; then
echo "::error file=.github/workflows/phpcompatibility-dev.yml,line=4,col=1::It looks like PHPCompatibility is already at version 10.0, making this Github Action obsolete. Please remove it."
exit 1
fi
composer remove --dev --no-update automattic/jetpack-codesniffer
composer require --dev --no-update phpcompatibility/php-compatibility='dev-develop as 9.9999.9999'
composer require --dev --no-update phpcompatibility/phpcompatibility-wp=dev-master
# Update any other packages needing update now too.
composer update
# Even though we uninstalled our codesniffer package, we need the compat rulesets to be found.
vendor/bin/phpcs --config-set installed_paths "$(vendor/bin/phpcs --config-show | sed -n 's/^installed_paths: //p'),../../../projects/packages/codesniffer"
- name: Run phpcs for PHPCompatibility
run: |
echo "::add-matcher::.github/matchers/phpcs-problem-matcher.json"
vendor/bin/phpcs -p -s --report=emacs --standard=.github/files/phpcompatibility-dev-phpcs.xml
echo "::remove-matcher owner=phpcs"