-
Notifications
You must be signed in to change notification settings - Fork 20
81 lines (69 loc) · 2.8 KB
/
phpcs.yml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: PHP Composer, Codesniffer, and Static Analysis
on: pull_request
jobs:
sniff:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.0' ]
env:
cache_version: 0 # increment to flush all caches
php_extensions: tokenizer, xmlwriter, simplexml
steps:
- uses: actions/checkout@v3
- name: Add GitHub oAuth
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: composer config --global github-oauth.github.com $TOKEN
- name: Detect File Changes
uses: dorny/paths-filter@v2
id: filter
with:
list-files: shell
filters: |
wpcontent:
- added|modified: 'wp-content/plugins/core/**/*.php'
- added|modified: 'wp-content/themes/core/**/*.php'
- added|modified: 'wp-content/mu-plugins/**/*.php'
- name: Set up PHP extension cache
if: ${{ steps.filter.outputs.wpcontent == 'true' }}
id: cache-php-extensions
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.php_extensions }}
key: ${{ matrix.operating-system }}-${{ env.cache_version }}-php-extensions-${{ matrix.php-versions }}
- name: Cache PHP extensions
if: ${{ steps.filter.outputs.wpcontent == 'true' }}
uses: actions/cache@v3
with:
path: ${{ steps.cache-php-extensions.outputs.dir }}
key: ${{ steps.cache-php-extensions.outputs.key }}
restore-keys: ${{ steps.cache-php-extensions.outputs.key }}
- name: Set up PHP
if: ${{ steps.filter.outputs.wpcontent == 'true' }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.php_extensions }}
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate composer.json and composer.lock
if: ${{ steps.filter.outputs.wpcontent == 'true' }}
run: composer validate
- name: Configure composer
if: ${{ steps.filter.outputs.wpcontent == 'true' }}
run: echo "${{ secrets.COMPOSER_ENV }}" > .env
- name: Install composer dependencies
if: ${{ steps.filter.outputs.wpcontent == 'true' }}
uses: ramsey/composer-install@v2
with:
composer-options: "--prefer-dist --no-progress --optimize-autoloader"
- name: PHPCS
if: ${{ steps.filter.outputs.wpcontent == 'true' }}
run: ./vendor/bin/phpcs --standard=./phpcs.xml.dist ${{ steps.filter.outputs.wpcontent_files }}
- name: Static Analysis
if: ${{ steps.filter.outputs.wpcontent == 'true' }}
run: ./vendor/bin/phpstan --memory-limit=-1