-
-
Notifications
You must be signed in to change notification settings - Fork 117
229 lines (198 loc) · 11.3 KB
/
static-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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: Static Analysis
on:
push:
branches: [main, temp]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
repository_dispatch:
types: [baseline-command] # triggered by /baseline PR comment
env:
writable: ${{ (github.event_name == 'repository_dispatch' || github.ref == 'refs/heads/temp' || github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') && 1 || 0 }}
permissions:
contents: read
jobs:
psalm:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event_name != 'repository_dispatch' || github.event.client_payload.slash_command.args.unnamed.all == '' || contains(github.event.client_payload.slash_command.args.unnamed.all, 'psalm')
permissions:
contents: write # for stefanzweifel/git-auto-commit-action to push code in repo
steps:
- name: Add action run link to trigger comment
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
edit-mode: replace
body: |
${{ github.event.client_payload.github.payload.comment.body }}
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Checkout
uses: actions/checkout@v4
if: env.writable == 1 && github.event_name != 'repository_dispatch'
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.BOT_TOKEN }}
- name: Checkout fork
uses: actions/checkout@v4
if: env.writable == 0
- name: Checkout on chat commnad
uses: actions/checkout@v4
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: gd, intl, imagick
coverage: none # disable xdebug, pcov
- name: Composer install
uses: ramsey/composer-install@v3
- name: Run psalm analysis
if: github.event_name != 'repository_dispatch'
run: vendor/bin/psalm --show-info=false --shepherd --diff --output-format=github
- name: Check psalm baseline and show type coverage
id: baseline
run: |
vendor/bin/psalm --set-baseline=.tools/psalm/baseline.xml --stats
git diff --exit-code .tools/psalm/baseline.xml || (echo "::error file=.tools/psalm/baseline.xml,line=1,col=1::Psalm baseline file is outdated and must be regenerated via \`composer psalm:baseline\`." && exit 1)
- name: Git pull
if: failure() && steps.baseline.conclusion != 'skipped' && github.event_name == 'repository_dispatch'
run: git pull --ff-only --no-tags --depth=1
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v5
if: failure() && steps.baseline.conclusion != 'skipped' && env.writable == 1
with:
commit_message: Update psalm baseline
commit_user_name: rex-bot
commit_user_email: rex-bot@users.noreply.github.com
file_pattern: .tools/psalm/baseline.xml
psalm-taint:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event.pull_request.draft == false && (github.event_name != 'repository_dispatch' || github.event.client_payload.slash_command.args.unnamed.all == '' || contains(github.event.client_payload.slash_command.args.unnamed.all, 'taint'))
permissions:
contents: write # for stefanzweifel/git-auto-commit-action to push code in repo
steps:
- name: Add action run link to trigger comment
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
edit-mode: replace
body: |
${{ github.event.client_payload.github.payload.comment.body }}
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Checkout
uses: actions/checkout@v4
if: env.writable == 1 && github.event_name != 'repository_dispatch'
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.BOT_TOKEN }}
- name: Checkout fork
uses: actions/checkout@v4
if: env.writable == 0
- name: Checkout on chat commnad
uses: actions/checkout@v4
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: gd, intl, imagick
coverage: none # disable xdebug, pcov
- name: Composer install
uses: ramsey/composer-install@v3
- name: Run psalm taint analysis
if: github.event_name != 'repository_dispatch'
run: vendor/bin/psalm --use-baseline=.tools/psalm/baseline-taint.xml --taint-analysis --no-cache
- name: Check psalm baseline
id: baseline
run: |
composer taint:baseline
git diff --exit-code .tools/psalm/baseline-taint.xml || (echo "::error file=.tools/psalm/baseline-taint.xml,line=1,col=1::Psalm taint baseline file is outdated and must be regenerated via \`composer taint:baseline\`." && exit 1)
- name: Git pull
if: failure() && steps.baseline.conclusion != 'skipped' && github.event_name == 'repository_dispatch'
run: git pull --ff-only --no-tags --depth=1
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v5
if: failure() && steps.baseline.conclusion != 'skipped' && env.writable == 1
with:
commit_message: Update psalm taint baseline
commit_user_name: rex-bot
commit_user_email: rex-bot@users.noreply.github.com
file_pattern: .tools/psalm/baseline-taint.xml
phpstan:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event_name != 'repository_dispatch' || github.event.client_payload.slash_command.args.unnamed.all == '' || contains(github.event.client_payload.slash_command.args.unnamed.all, 'phpstan')
permissions:
contents: write # for Git to git apply
steps:
- name: Add action run link to trigger comment
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
edit-mode: replace
body: |
${{ github.event.client_payload.github.payload.comment.body }}
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Checkout
uses: actions/checkout@v4
if: github.event_name != 'repository_dispatch'
- name: Checkout on chat commnad
uses: actions/checkout@v4
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: gd, intl, imagick, pdo_mysql
coverage: none # disable xdebug, pcov
- name: Composer install
uses: ramsey/composer-install@v3
- name: Setup REDAXO
run: |
sudo /etc/init.d/mysql start
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo6;'
php redaxo/bin/console setup:run -n --lang=de_de --db-host=127.0.0.1 --db-name=redaxo6 --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword --error-email=test@redaxo.invalid --ansi -v
php redaxo/bin/console config:set --type boolean debug.enabled true -v
php redaxo/bin/console config:set --type boolean debug.throw_always_exception true -v
- name: Run phpstan analysis
if: github.event_name != 'repository_dispatch'
run: vendor/bin/phpstan analyse --ansi
- name: Check phpstan baseline
if: github.event_name == 'repository_dispatch'
id: baseline
run: |
composer phpstan:baseline
git diff --exit-code .tools/phpstan/baseline.neon || (echo "::error file=.tools/phpstan/baseline.neon,line=1,col=1::PHPStan baseline file is outdated and must be regenerated via \`composer phpstan:baseline\`." && exit 1)
- name: Git pull
if: failure() && steps.baseline.conclusion != 'skipped' && github.event_name == 'repository_dispatch'
run: git pull --ff-only --no-tags --depth=1
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v5
if: failure() && steps.baseline.conclusion != 'skipped' && env.writable == 1
with:
commit_message: Update phpstan baseline
commit_user_name: rex-bot
commit_user_email: rex-bot@users.noreply.github.com
file_pattern: .tools/phpstan/baseline.neon