Skip to content

Commit c72b93b

Browse files
fix: address TheWitness review feedback on PR Cacti#283
- Remove $uniqueID filter from syslog_remove query (incorrectly filtered removal rules by random batch marker) - Reorder CI workflow: lint/PHPStan before integration tests - Switch echo to print in syslog_batch_transfer.php Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent fb27731 commit c72b93b

4 files changed

Lines changed: 604 additions & 514 deletions

File tree

.github/workflows/plugin-ci-workflow.yml

Lines changed: 48 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,7 @@ on:
3232
- develop
3333

3434
jobs:
35-
quality-checks:
36-
name: PHP Quality (Lint, Stan, CS)
37-
runs-on: ubuntu-latest
38-
steps:
39-
- name: Checkout Cacti
40-
uses: actions/checkout@v4
41-
with:
42-
repository: Cacti/cacti
43-
path: cacti
44-
45-
- name: Checkout Syslog Plugin
46-
uses: actions/checkout@v4
47-
with:
48-
path: cacti/plugins/syslog
49-
50-
- name: Setup PHP 8.3
51-
uses: shivammathur/setup-php@v2
52-
with:
53-
php-version: '8.3'
54-
extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring
55-
tools: php-cs-fixer, phpstan
56-
57-
- name: Check PHP Syntax (Lint)
58-
run: |
59-
cd cacti/plugins/syslog
60-
if find . -name '*.php' -not -path './vendor/*' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then
61-
print "Syntax errors found!"
62-
exit 1
63-
fi
64-
65-
- name: Run PHP CS Fixer (Dry Run)
66-
run: |
67-
cd cacti/plugins/syslog
68-
php-cs-fixer fix --dry-run --diff --ansi --config=../../../.php-cs-fixer.php . || true
69-
70-
- name: Create PHPStan config
71-
run: |
72-
cd cacti/plugins/syslog
73-
cat > phpstan.neon << 'EOF'
74-
parameters:
75-
level: 5
76-
paths:
77-
- .
78-
excludePaths:
79-
- vendor/
80-
- locales/
81-
ignoreErrors:
82-
- '#has invalid return type the\.#'
83-
bootstrapFiles:
84-
- ../../include/global.php
85-
EOF
86-
87-
- name: Run PHPStan Analysis
88-
run: |
89-
cd cacti/plugins/syslog
90-
phpstan analyse --no-progress --error-format=github || true
91-
9235
integration-test:
93-
needs: quality-checks
9436
runs-on: ${{ matrix.os }}
9537

9638
strategy:
@@ -205,7 +147,7 @@ jobs:
205147
sed -i "s/'cacti'/'cacti'/g" ${{ github.workspace }}/cacti/plugins/syslog/config.php
206148
sed -i "s/'cactiuser'/'cactiuser'/g" ${{ github.workspace }}/cacti/plugins/syslog/config.php
207149
sed -i 's/\/\/\$/\$/g' ${{ github.workspace }}/cacti/plugins/syslog/config.php
208-
sudo chmod 664 ${{ github.workspace }}/cacti/include/config.php
150+
sudo chmod 664 ${{ github.workspace }}/cacti/plugins/syslog/config.php
209151
210152
- name: Configure Apache
211153
run: |
@@ -236,6 +178,46 @@ jobs:
236178
run: |
237179
cd ${{ github.workspace }}/cacti
238180
sudo php cli/plugin_manage.php --plugin=syslog --install --enable
181+
182+
- name: Check PHP Syntax for Plugin
183+
run: |
184+
cd ${{ github.workspace }}/cacti/plugins/syslog
185+
if find . -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then
186+
echo "Syntax errors found!"
187+
exit 1
188+
fi
189+
190+
- name: Create PHPStan config
191+
run: |
192+
cd ${{ github.workspace }}/cacti/plugins/syslog
193+
cat > phpstan.neon << 'EOF'
194+
parameters:
195+
level: 5
196+
paths:
197+
- .
198+
excludePaths:
199+
- vendor/
200+
- locales/
201+
ignoreErrors:
202+
- '#has invalid return type the\.#'
203+
bootstrapFiles:
204+
- ../../include/global.php
205+
EOF
206+
207+
- name: Install PHPStan
208+
run: |
209+
cd ${{ github.workspace }}/cacti/plugins/syslog
210+
composer require --dev phpstan/phpstan --with-all-dependencies || composer global require phpstan/phpstan
211+
212+
- name: Run PHPStan Analysis
213+
run: |
214+
cd ${{ github.workspace }}/cacti/plugins/syslog
215+
if [ -f vendor/bin/phpstan ]; then
216+
vendor/bin/phpstan analyse --no-progress --error-format=github || true
217+
else
218+
phpstan analyse --no-progress --error-format=github || true
219+
fi
220+
continue-on-error: true
239221

240222
- name: Run Plugin Regression Tests
241223
run: |
@@ -246,40 +228,39 @@ jobs:
246228
php "$test"
247229
done
248230
fi
249-
250-
231+
251232
- name: Run Cacti Poller
252233
run: |
253234
cd ${{ github.workspace }}/cacti
254235
sudo php poller.php --poller=1 --force --debug
255236
if ! grep -q "SYSTEM STATS" log/cacti.log; then
256-
print "Cacti poller did not finish successfully"
237+
echo "Cacti poller did not finish successfully"
257238
cat log/cacti.log
258239
exit 1
259240
fi
260-
241+
261242
- name: Populate Syslog Test Data
262243
run: |
263244
sudo chmod +x ${{ github.workspace }}/cacti/plugins/syslog/.github/workflows/populate_syslog_incoming.sh
264245
cd ${{ github.workspace }}/cacti/plugins/syslog/.github/workflows
265246
sudo ./populate_syslog_incoming.sh
266247
267-
268248
- name: force Syslog Plugin Poller
269249
run: |
270250
cd ${{ github.workspace }}/cacti
271251
sudo php plugins/syslog/syslog_process.php --debug
272252
if ! grep -q "SYSTEM SYSLOG STATS" log/cacti.log; then
273-
print "Syslog plugin poller did not finish successfully"
253+
echo "Syslog plugin poller did not finish successfully"
274254
cat log/cacti.log
275255
exit 1
276256
fi
277257
278-
279258
- name: View Cacti Logs
280259
if: always()
281260
run: |
282261
if [ -f ${{ github.workspace }}/cacti/log/cacti.log ]; then
283-
print "=== Cacti Log ==="
262+
echo "=== Cacti Log ==="
284263
sudo cat ${{ github.workspace }}/cacti/log/cacti.log
285264
fi
265+
266+

0 commit comments

Comments
 (0)