-
Notifications
You must be signed in to change notification settings - Fork 10
120 lines (118 loc) · 4.4 KB
/
phpstan.yml
File metadata and controls
120 lines (118 loc) · 4.4 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Run PHPStan
on:
workflow_call:
secrets:
env:
required: false
inputs:
extensionName:
description: "Your extension name"
required: true
type: string
shopwareVersion:
description: |
With the default `.auto`, the workflow tries to find a shopware version using the shopware-version action.
For example, if the current ref is next-1234, it will try to find the ref next-1234 in shopware/shopware. If there's no matching ref, it will use shopwareVersionFallback
required: false
type: string
default: ".auto"
shopwareVersionFallback:
required: false
type: string
default: trunk
shopware-repository:
description: The shopware repository to checkout
type: string
default: shopware/shopware
composerRootVersion:
required: false
type: string
default: ".auto"
dependencies:
required: false
type: string
runner:
required: false
type: string
default: ubuntu-latest
env:
SHOPWARE_TOOL_CACHE_PHPSTAN: ${{ github.workspace }}/var/phpstan
jobs:
run:
name: Static Analyse
runs-on: ${{ inputs.runner }}
steps:
- uses: shopware/github-actions/shopware-version@main
with:
fallback: ${{ inputs.shopwareVersionFallback }}
repo: ${{ inputs.shopware-repository }}
id: version
if: ${{ inputs.shopwareVersion == '.auto' || inputs.shopwareVersion == '' }}
- name: Setup Shopware
uses: shopware/setup-shopware@main
with:
shopware-version: ${{ steps.version.outputs.shopware-version || inputs.shopwareVersion }}
shopware-repository: ${{ inputs.shopware-repository }}
composer-root-version: ${{ inputs.composerRootVersion }}
php-version: 8.2
env: prod
install: "true"
allow-insecure-versions: true
- name: Clone Extension
uses: actions/checkout@v6
with:
path: custom/plugins/${{ inputs.extensionName }}
- name: Clone Dependencies
if: inputs.dependencies
env:
DEPS: ${{ inputs.dependencies }}
run: |
IFS=$'\n'
for token in $(echo "${{secrets.env}}"); do
export $token
done
for dep in $(echo "$DEPS" | envsubst | jq -c '.[]'); do
dep_name=$(echo "$dep" | jq -r '.name')
dep_repo=$(echo "$dep" | jq -r '.repo')
git clone "$dep_repo" "custom/plugins/$dep_name"
done
- name: Install dependencies with Composer
if: inputs.dependencies
env:
DEPS: ${{ inputs.dependencies }}
run: |
IFS=$'\n'
for dep in $(echo "$DEPS" | envsubst | jq -c '.[]'); do
dep_name=$(echo "$dep" | jq -r '.name')
composer require $(composer -d "custom/plugins/$dep_name" config name)
done
- name: Install extension with Composer
run: composer require $(composer -d custom/plugins/${{ inputs.extensionName }} config name)
- name: Create phpstan.neon
working-directory: custom/plugins/${{ inputs.extensionName }}
run: |
printf "parameters:\n tmpDir: ${{ env.SHOPWARE_TOOL_CACHE_PHPSTAN }}\nincludes:\n - phpstan.neon.dist" > phpstan.neon
- name: PHPStan cache
uses: actions/cache@v5
with:
path: ${{ env.SHOPWARE_TOOL_CACHE_PHPSTAN }}
key: ${{ runner.OS }}-${{ github.repository }}-phpstan-${{ github.sha }}
restore-keys: |
${{ runner.OS }}-${{ github.repository }}-phpstan-
- name: Refresh
run: bin/console plugin:refresh
- name: Install extension dependencies
if: inputs.dependencies
run: |
IFS=$'\n'
for dep in $(echo "$DEPS" | envsubst | jq -c '.[]'); do
dep_name=$(echo "$dep" | jq -r '.name')
bin/console plugin:install --activate $dep_name
done
- name: Install Extension
run: bin/console plugin:install --activate ${{ inputs.extensionName }}
- name: Build PHPStan Bootstrap
run: php ${{ github.workspace }}/src/Core/DevOps/StaticAnalyze/phpstan-bootstrap.php
- name: Run PHPStan
working-directory: custom/plugins/${{ inputs.extensionName }}
run: ${{ github.workspace }}/vendor/bin/phpstan analyze --error-format=github --no-progress