Skip to content

Commit b163448

Browse files
ci: extract quality-checks job and standardize test output
Move lint, PHP CS Fixer, and PHPStan into a dedicated quality-checks job that gates integration-test. Remove duplicate steps from the integration job. Standardize regression test output to use print instead of echo. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent bf55698 commit b163448

7 files changed

Lines changed: 65 additions & 50 deletions

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

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,65 @@ 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+
echo "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+
3592
integration-test:
93+
needs: quality-checks
3694
runs-on: ${{ matrix.os }}
3795

3896
strategy:
@@ -147,7 +205,7 @@ jobs:
147205
sed -i "s/'cacti'/'cacti'/g" ${{ github.workspace }}/cacti/plugins/syslog/config.php
148206
sed -i "s/'cactiuser'/'cactiuser'/g" ${{ github.workspace }}/cacti/plugins/syslog/config.php
149207
sed -i 's/\/\/\$/\$/g' ${{ github.workspace }}/cacti/plugins/syslog/config.php
150-
sudo chmod 664 ${{ github.workspace }}/cacti/plugins/syslog/config.php
208+
sudo chmod 664 ${{ github.workspace }}/cacti/include/config.php
151209
152210
- name: Configure Apache
153211
run: |
@@ -178,14 +236,6 @@ jobs:
178236
run: |
179237
cd ${{ github.workspace }}/cacti
180238
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
189239
190240
- name: Run Plugin Regression Tests
191241
run: |
@@ -233,38 +283,3 @@ jobs:
233283
echo "=== Cacti Log ==="
234284
sudo cat ${{ github.workspace }}/cacti/log/cacti.log
235285
fi
236-
237-
238-
- name: Create PHPStan config
239-
run: |
240-
cd ${{ github.workspace }}/cacti/plugins/syslog
241-
cat > phpstan.neon << 'EOF'
242-
parameters:
243-
level: 5
244-
paths:
245-
- .
246-
excludePaths:
247-
- vendor/
248-
- locales/
249-
ignoreErrors:
250-
- '#has invalid return type the\.#'
251-
bootstrapFiles:
252-
- ../../include/global.php
253-
EOF
254-
255-
- name: Install PHPStan
256-
run: |
257-
cd ${{ github.workspace }}/cacti/plugins/syslog
258-
composer require --dev phpstan/phpstan --with-all-dependencies || composer global require phpstan/phpstan
259-
260-
- name: Run PHPStan Analysis
261-
run: |
262-
cd ${{ github.workspace }}/cacti/plugins/syslog
263-
if [ -f vendor/bin/phpstan ]; then
264-
vendor/bin/phpstan analyse --no-progress --error-format=github || true
265-
else
266-
phpstan analyse --no-progress --error-format=github || true
267-
fi
268-
continue-on-error: true
269-
270-

tests/regression/issue252_xss_output_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
exit(1);
4343
}
4444

45-
echo "issue252_xss_output_test passed\n";
45+
print "issue252_xss_output_test passed\n";

tests/regression/issue254_partition_table_locking_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,4 @@
186186
exit(1);
187187
}
188188

189-
echo "issue254_partition_table_locking_test passed\n";
189+
print "issue254_partition_table_locking_test passed\n";

tests/regression/issue259_csrf_purge_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@
103103
exit(1);
104104
}
105105

106-
echo "issue259_csrf_purge_test passed\n";
106+
print "issue259_csrf_purge_test passed\n";

tests/regression/issue260_remove_eval_callback_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
exit(1);
4343
}
4444

45-
echo "issue260_remove_eval_callback_test passed\n";
45+
print "issue260_remove_eval_callback_test passed\n";

tests/regression/issue261_domain_strip_parameterized_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
exit(1);
2525
}
2626

27-
echo "issue261_domain_strip_parameterized_test passed\n";
27+
print "issue261_domain_strip_parameterized_test passed\n";

tests/regression/issue270_mariadb_detection_strict_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
exit(1);
2121
}
2222

23-
echo "issue270_mariadb_detection_strict_test passed\n";
23+
print "issue270_mariadb_detection_strict_test passed\n";

0 commit comments

Comments
 (0)