-
Notifications
You must be signed in to change notification settings - Fork 6
82 lines (74 loc) · 2.62 KB
/
static-analysis-php.yml
File metadata and controls
82 lines (74 loc) · 2.62 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Static code 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
DEPENDENCY_VERSIONS:
description: Whether the job should install the locked, highest, or lowest versions of Composer dependencies.
default: 'locked'
required: false
type: string
PSALM_ARGS:
description: Set of arguments passed to Psalm.
default: '--output-format=github --no-cache'
required: false
type: string
PHPSTAN_ARGS:
description: Set of arguments passed to PHPStan.
default: '--no-progress --memory-limit=1G'
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:
static-analysis-php:
timeout-minutes: 5
runs-on: ubuntu-latest
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
env:
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
with:
composer-options: ${{ inputs.COMPOSER_ARGS }}
dependency-versions: ${{ inputs.DEPENDENCY_VERSIONS }}
- name: Run Psalm
if: ${{ hashFiles('psalm.xml', 'psalm.xml.dist') != '' }}
run: ./vendor/bin/psalm --php-version="${{ inputs.PHP_VERSION }}" ${{ inputs.PSALM_ARGS }}
- name: Run PHPStan
if: ${{ hashFiles('phpstan.dist.neon', 'phpstan.neon', 'phpstan.neon.dist') != '' }}
run: ./vendor/bin/phpstan ${{ inputs.PHPSTAN_ARGS }}