2020-10-19 10:52:24 +00:00
|
|
|
name: PHP Coding Standards
|
|
|
|
|
|
|
|
on:
|
2022-03-23 07:41:43 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- trunk
|
|
|
|
pull_request:
|
2020-10-19 10:52:24 +00:00
|
|
|
|
|
|
|
jobs:
|
2022-03-23 07:41:43 +00:00
|
|
|
# Runs PHP coding standards checks.
|
|
|
|
# Note: Inspired by https://github.com/WordPress/wordpress-develop/blob/master/.github/workflows/coding-standards.yml
|
|
|
|
#
|
|
|
|
# Violations are reported inline with annotations.
|
|
|
|
#
|
|
|
|
# Performs the following steps:
|
|
|
|
# - Checks out the repository.
|
|
|
|
# - Configures caching for Composer.
|
|
|
|
# - Sets up PHP.
|
|
|
|
# - Logs debug information.
|
|
|
|
# - Installs Composer dependencies (from cache if possible).
|
|
|
|
# - Logs PHP_CodeSniffer debug information.
|
|
|
|
# - Runs PHPCS on the full codebase with warnings suppressed.
|
|
|
|
# - todo: Configure Slack notifications for failing scans.
|
|
|
|
phpcs:
|
|
|
|
name: PHP coding standards
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v3
|
2020-10-19 10:52:24 +00:00
|
|
|
|
2022-03-23 07:41:43 +00:00
|
|
|
- name: Get Composer cache directory
|
|
|
|
id: composer-cache
|
2022-11-18 15:41:30 +00:00
|
|
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
|
|
|
|
2020-10-19 10:52:24 +00:00
|
|
|
|
2022-03-23 07:41:43 +00:00
|
|
|
- name: Set up Composer caching
|
2022-11-18 15:41:30 +00:00
|
|
|
uses: actions/cache@v3
|
2022-03-23 07:41:43 +00:00
|
|
|
env:
|
|
|
|
cache-name: cache-composer-dependencies
|
|
|
|
with:
|
|
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-composer-
|
|
|
|
- name: Set up PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
2022-11-09 15:28:08 +00:00
|
|
|
php-version: '8.0'
|
2022-03-23 07:41:43 +00:00
|
|
|
coverage: none
|
|
|
|
tools: composer, cs2pr
|
2020-10-19 10:52:24 +00:00
|
|
|
|
2022-03-23 07:41:43 +00:00
|
|
|
- name: Log debug information
|
|
|
|
run: |
|
|
|
|
php --version
|
|
|
|
composer --version
|
|
|
|
- name: Install Composer dependencies
|
|
|
|
run: |
|
|
|
|
composer install --prefer-dist --no-suggest --no-progress --no-ansi --no-interaction
|
|
|
|
echo "${PWD}/vendor/bin" >> $GITHUB_PATH
|
|
|
|
- name: Log PHPCS debug information
|
|
|
|
run: phpcs -i
|
2020-10-19 10:52:24 +00:00
|
|
|
|
2022-03-23 07:41:43 +00:00
|
|
|
- name: Run PHPCS on all files
|
2023-06-21 10:51:30 +00:00
|
|
|
run: phpcs ./src -n --report=checkstyle | cs2pr
|