-
Notifications
You must be signed in to change notification settings - Fork 2
131 lines (114 loc) · 5.66 KB
/
php-code-analysis.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
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
121
122
123
124
125
126
127
128
129
130
131
name: PHP code analysis
on:
workflow_call:
inputs:
plugin-name:
required: true
type: string
legacy-plugin:
required: false
type: boolean
default: false
# Target can be: Core, Frontend, Backend. Requires legacy-plugin to be true
legacy-plugin-target:
required: false
type: string
jobs:
php-code-analysis:
concurrency:
group: php_code-analysis-${{ inputs.plugin-name }}-${{ github.head_ref || github.ref }}-${{ github.workflow }}
cancel-in-progress: true
name: Code analysis for ${{ inputs.plugin-name }}
runs-on: ubuntu-latest
env:
PLUGIN_NAME: ${{ inputs.plugin-name }}
LEGACY_PLUGIN: ${{ inputs.legacy-plugin }}
LEGACY_PLUGIN_TARGET: ${{ inputs.legacy-plugin-target }}
container:
image: ghcr.io/shopware5/docker-images-testing/install:shopware_5.7_8.0_7.4_none
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:
- name: Check if plugin is legacy with target
run: |
targets="Core Frontend Backend"
if [ ${{ env.LEGACY_PLUGIN }} = true ]; then
if [ ! -z "${{ env.LEGACY_PLUGIN_TARGET }}" ]; then
for target in $targets; do
if [ $target = ${{ env.LEGACY_PLUGIN_TARGET }} ]
then
echo "Target set!"
exit 0
fi
done
echo 'Wrong target has been set! Please set the github action input "legacy-plugin-target" to "Core", "Backend", "Frontend"'
exit 1
fi
echo 'No target has been set! Please set the github action input "legacy-plugin-target" to "Core", "Backend", "Frontend"'
exit 1
fi
echo "Not a legacy plugin"
- run: /usr/bin/supervisord -c /etc/supervisord.conf &
- name: Checkout ${{ env.PLUGIN_NAME }}
uses: actions/checkout@v4
with:
path: plugin
- name: Move plugin
run: |
if [ ${{ env.LEGACY_PLUGIN }} = true ]; then
mv "$(pwd)/plugin" /shopware/engine/Shopware/Plugins/Local/${{ env.LEGACY_PLUGIN_TARGET }}/${{ env.PLUGIN_NAME }}
else
mv "$(pwd)/plugin" /shopware/custom/plugins/${{ env.PLUGIN_NAME }}
fi
- name: Get Composer Cache Directory
id: composer-cache
run: |
if [ ${{ env.LEGACY_PLUGIN }} = true ]; then
cd /shopware/engine/Shopware/Plugins/Local/${{ env.LEGACY_PLUGIN_TARGET }}/${{ env.PLUGIN_NAME }}
else
cd /shopware/custom/plugins/${{ env.PLUGIN_NAME }}
fi
echo "plugin-dir=$(pwd)" >> $GITHUB_OUTPUT
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('${{ steps.composer-cache.outputs.plugin-dir }}/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup ${{ env.PLUGIN_NAME }}
run: |
if [ ${{ env.LEGACY_PLUGIN }} = true ]; then
cd /shopware/engine/Shopware/Plugins/Local/${{ env.LEGACY_PLUGIN_TARGET }}/${{ env.PLUGIN_NAME }}
else
cd /shopware/custom/plugins/${{ env.PLUGIN_NAME }}
fi
if [ "$(make -p | grep 'composer-install:')" = "composer-install:" ]; then
make composer-install
else
echo "No composer-install command found. This is fine if you do not expect that command to exist!"
fi
make install-plugin
- name: Execute PHP Code-Style-fixer
run: |
if [ ${{ env.LEGACY_PLUGIN }} = true ]; then
cd /shopware/engine/Shopware/Plugins/Local/${{ env.LEGACY_PLUGIN_TARGET }}/${{ env.PLUGIN_NAME }}
else
cd /shopware/custom/plugins/${{ env.PLUGIN_NAME }}
fi
make fix-cs-dry
- name: Execute PHP-Stan
run: |
cd /shopware
php bin/console -e production -q # Initialise DIC (var/cache/production____REVISION____) for phpstan
if [ ${{ env.LEGACY_PLUGIN }} = true ]; then
cd /shopware/engine/Shopware/Plugins/Local/${{ env.LEGACY_PLUGIN_TARGET }}/${{ env.PLUGIN_NAME }}
else
cd /shopware/custom/plugins/${{ env.PLUGIN_NAME }}
fi
if [ "$(make -p | grep 'phpstan:')" = "phpstan:" ]; then
make phpstan
else
echo "No phpstan command found in the Makefile. If the command is declared in the Makefile you have an error!"
fi