|
32 | 32 | - develop |
33 | 33 |
|
34 | 34 | 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 | +
|
35 | 92 | integration-test: |
| 93 | + needs: quality-checks |
36 | 94 | runs-on: ${{ matrix.os }} |
37 | 95 |
|
38 | 96 | strategy: |
@@ -147,7 +205,7 @@ jobs: |
147 | 205 | sed -i "s/'cacti'/'cacti'/g" ${{ github.workspace }}/cacti/plugins/syslog/config.php |
148 | 206 | sed -i "s/'cactiuser'/'cactiuser'/g" ${{ github.workspace }}/cacti/plugins/syslog/config.php |
149 | 207 | 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 |
151 | 209 | |
152 | 210 | - name: Configure Apache |
153 | 211 | run: | |
@@ -178,14 +236,6 @@ jobs: |
178 | 236 | run: | |
179 | 237 | cd ${{ github.workspace }}/cacti |
180 | 238 | 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 | 239 |
|
190 | 240 | - name: Run Plugin Regression Tests |
191 | 241 | run: | |
@@ -233,38 +283,3 @@ jobs: |
233 | 283 | echo "=== Cacti Log ===" |
234 | 284 | sudo cat ${{ github.workspace }}/cacti/log/cacti.log |
235 | 285 | 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 | | - |
|
0 commit comments