-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 2.42 KB
/
phpcs.yml
File metadata and controls
67 lines (59 loc) · 2.42 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
62
63
64
65
66
67
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: PHPCS check
on:
workflow_call:
jobs:
phpcs:
name: PHPCS check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Check for composer.json
id: composer_json_check
run: |
if [ ! -f composer.json ]; then
echo "composer.json not found. Skipping Composer install."
echo "skip_composer=true" >> $GITHUB_OUTPUT
else
echo "skip_composer=false" >> $GITHUB_OUTPUT
fi
- name: Check for PHP file changes
id: check-php-files
run: |
git fetch origin ${{ github.base_ref }}
git fetch origin ${{ github.head_ref }}
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }} origin/${{ github.head_ref }} -- | grep '\.php$' || true)
if [ -z "$CHANGED_FILES" ]; then
echo "No PHP files changed"
echo "changed_files=false" >> "$GITHUB_OUTPUT"
else
echo "PHP files changed"
echo "changed_files=true" >> "$GITHUB_OUTPUT"
fi
- name: Setup PHP
if: steps.composer_json_check.outputs.skip_composer == 'false' && steps.check-php-files.outputs.changed_files == 'true'
uses: "shivammathur/setup-php@master"
with:
php-version: "latest"
ini-values: memory_limit=256M'
coverage: none
tools: cs2pr
- name: Install Composer dependencies
if: steps.composer_json_check.outputs.skip_composer == 'false' && steps.check-php-files.outputs.changed_files == 'true'
uses: "ramsey/composer-install@v4"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Run PHPCS Beautifier
id: phpcbf
if: steps.composer_json_check.outputs.skip_composer == 'false' && steps.check-php-files.outputs.changed_files == 'true'
continue-on-error: true
run: composer phpcbf
- name: Run PHPCS checks
id: phpcs
if: steps.composer_json_check.outputs.skip_composer == 'false' && steps.check-php-files.outputs.changed_files == 'true'
run: composer phpcs
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml