-
Notifications
You must be signed in to change notification settings - Fork 41
48 lines (44 loc) · 2.12 KB
/
Copy pathphpcs.yml
File metadata and controls
48 lines (44 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- master
pull_request:
types: [ opened, labeled, synchronize ]
name: Inspections
# Cancel superseded runs for the same branch. The group is named explicitly
# rather than derived from github.workflow: several files share the workflow
# name `Inspections` and would otherwise cancel each other.
concurrency:
group: formidable-phpcs-${{ github.ref }}
cancel-in-progress: true
jobs:
runPHPCSInspection:
if: contains(github.event.pull_request.labels.*.name, 'run analysis')
name: Run PHPCS inspection
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
# Install only what this job runs, instead of every require-dev package.
# phpcs.xml references WordPress, WordPressVIPMinimum and SlevomatCodingStandard;
# wpcs also pulls phpcsextra/phpcsutils and the dealerdirect installer that
# registers all three standards with phpcs.
# The guard fails the job if a package is renamed or dropped from
# composer.json, rather than silently narrowing to nothing.
- name: Install PHPCS and its standards
run: |
NEED='squizlabs/php_codesniffer wp-coding-standards/wpcs automattic/vipwpcs slevomat/coding-standard'
for pkg in $NEED; do
jq -e --arg pkg "$pkg" '."require-dev" | has($pkg)' composer.json > /dev/null \
|| { echo "::error::composer.json has no require-dev entry for $pkg"; exit 1; }
done
jq '{require, autoload, config, "require-dev": (."require-dev" | with_entries(select(.key as $k | $ARGS.positional | index($k))))}' \
composer.json --args $NEED > composer.ci.json
COMPOSER=composer.ci.json composer install --prefer-dist --no-progress
- name: Register custom PHPCS sniffs
run: |
CURRENT_PATHS=$(./vendor/bin/phpcs --config-show | grep 'installed_paths' | cut -d' ' -f2)
./vendor/bin/phpcs --config-set installed_paths "$CURRENT_PATHS,../../../phpcs-sniffs"
- name: PHPCS check
run: ./vendor/bin/phpcs --parallel=10 ./