-
Notifications
You must be signed in to change notification settings - Fork 6
75 lines (67 loc) · 2.21 KB
/
coding-standards-php.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
name: Coding standards analysis PHP
on:
workflow_call:
inputs:
PHP_VERSION:
description: PHP version with which the scripts are executed.
default: '8.2'
required: false
type: string
COMPOSER_ARGS:
description: Set of arguments passed to Composer.
default: '--prefer-dist'
required: false
type: string
PHPCS_ARGS:
description: Set of arguments passed to PHP_CodeSniffer.
default: '--report-full --report-checkstyle=./phpcs-report.xml'
required: false
type: string
CS2PR_ARGS:
description: Set of arguments passed to cs2pr.
default: '--graceful-warnings ./phpcs-report.xml'
required: false
type: string
secrets:
COMPOSER_AUTH_JSON:
description: Authentication for privately hosted packages and repositories as a JSON formatted object.
required: false
ENV_VARS:
description: Additional environment variables as a JSON formatted object.
required: false
jobs:
coding-standards-php:
timeout-minutes: 5
runs-on: ubuntu-latest
env:
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up custom environment variables
env:
ENV_VARS: ${{ secrets.ENV_VARS }}
if: ${{ env.ENV_VARS }}
uses: actions/github-script@v7
with:
script: |
JSON
.parse(process.env.ENV_VARS)
.forEach(envVar => core.exportVariable(envVar.name, envVar.value));
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.PHP_VERSION }}
tools: composer, cs2pr
coverage: none
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
composer-options: ${{ inputs.COMPOSER_ARGS }}
- name: Run PHP_CodeSniffer
run: ./vendor/bin/phpcs ${{ inputs.PHPCS_ARGS }}
- name: Annotate PHP_CodeSniffer report
if: ${{ always() }}
run: cs2pr ${{ inputs.CS2PR_ARGS }}