-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (56 loc) · 2.76 KB
/
php-phpcs.yml
File metadata and controls
61 lines (56 loc) · 2.76 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
49
50
51
52
53
54
55
56
57
58
59
60
61
name: 'PHP CodeSniffer'
on: workflow_call
jobs:
phpcs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
# ------------------------------------------------------------------------------
# Prepare our cache directories
# ------------------------------------------------------------------------------
- name: Get Composer Cache Directory
id: get-composer-cache-dir
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: composer-cache
with:
path: ${{ steps.get-composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: "shivammathur/setup-php@v2"
with:
php-version: 8.0
- name: Setup third party repos with composer
env:
LICENSE_GRAVITY_FORMS: ${{ secrets.LICENSE_GRAVITY_FORMS }}
LICENSE_BEAVER_BUILDER: ${{ secrets.LICENSE_BEAVER_BUILDER }}
run: |
composer config --global http-basic.composer.gravity.io $LICENSE_GRAVITY_FORMS https://github-ci.gf.local
composer config --global repositories.beaver-builder composer "https://composer.wpbeaverbuilder.com/$LICENSE_BEAVER_BUILDER"
- uses: "ramsey/composer-install@v2"
- name: "Give permissions"
run: |
sudo chown -R root:root $GITHUB_WORKSPACE
# ------------------------------------------------------------------------------
# Get changed files
# ------------------------------------------------------------------------------
- name: Get list of changed files
id: files
run: |
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '\.php$' | tr '\n' ' ')" >> $GITHUB_ENV
# ------------------------------------------------------------------------------
# PHPCS
# ------------------------------------------------------------------------------
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest # Optional. [latest,nightly,v.X.Y.Z]
- name: Run reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
run: |
vendor/bin/phpcs --report=json ${CHANGED_FILES} | jq -r ' .files | to_entries[] | .key as $path | .value.messages[] as $msg | "\($path):\($msg.line):\($msg.column):`\($msg.source)`<br>\($msg.message)" ' | reviewdog -efm="%f:%l:%c:%m" -name="phpcs" -filter-mode="added" -fail-on-error=true -reporter=github-pr-review