Skip to content

Commit cd1cece

Browse files
committed
feat: Add PHP Coding standards workflow
1 parent 671b14a commit cd1cece

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: PHP Coding standards
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
PHP_VERSION:
7+
description: PHP version with which the coding standards is to be executed.
8+
default: '8.2'
9+
required: false
10+
type: string
11+
COMPOSER_ARGS:
12+
description: Set of arguments passed to Composer.
13+
default: '--prefer-dist --no-scripts'
14+
required: false
15+
type: string
16+
PHPCS_ARGS:
17+
description: Set of arguments passed to PHP_CodeSniffer.
18+
default: '--report-full --report-checkstyle=./phpcs-report.xml'
19+
required: false
20+
type: string
21+
secrets:
22+
COMPOSER_AUTH_JSON:
23+
description: Authentication for privately hosted packages and repositories as a JSON formatted object.
24+
required: false
25+
26+
jobs:
27+
php-static-analysis:
28+
runs-on: ubuntu-latest
29+
env:
30+
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v5
34+
35+
- uses: mindkomm/workflows/.github/actions/composer@main
36+
with:
37+
PHP_VERSION: ${{ inputs.PHP_VERSION }}
38+
PHP_TOOLS: composer, cs2pr
39+
COMPOSER_CONFIG: ${{ vars.COMPOSER_CONFIG_JSON }}
40+
41+
- uses: tj-actions/changed-files@v46
42+
id: changed-files
43+
with:
44+
# Avoid using single or double quotes for multiline patterns
45+
files: |
46+
**.php
47+
48+
- name: Run PHP_CodeSniffer
49+
if: steps.changed-files.outputs.all_changed_files != ''
50+
run: ./vendor/bin/phpcs ${{ inputs.PHPCS_ARGS }} ${{ join(steps.changed-files.outputs.all_changed_files, ' ') }} | cs2pr

0 commit comments

Comments
 (0)