Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 62 additions & 48 deletions .github/workflows/plugin-ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,65 @@ on:
- develop

jobs:
quality-checks:
name: PHP Quality (Lint, Stan, CS)
runs-on: ubuntu-latest
steps:
- name: Checkout Cacti
uses: actions/checkout@v4
with:
repository: Cacti/cacti
path: cacti

- name: Checkout Syslog Plugin
uses: actions/checkout@v4
with:
path: cacti/plugins/syslog

- name: Setup PHP 8.3
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring
tools: php-cs-fixer, phpstan

- name: Check PHP Syntax (Lint)
run: |
cd cacti/plugins/syslog
if find . -name '*.php' -not -path './vendor/*' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then
print "Syntax errors found!"
exit 1
fi

- name: Run PHP CS Fixer (Dry Run)
run: |
cd cacti/plugins/syslog
php-cs-fixer fix --dry-run --diff --ansi --config=../../../.php-cs-fixer.php . || true

- name: Create PHPStan config
run: |
cd cacti/plugins/syslog
cat > phpstan.neon << 'EOF'
parameters:
level: 5
paths:
- .
excludePaths:
- vendor/
- locales/
ignoreErrors:
- '#has invalid return type the\.#'
bootstrapFiles:
- ../../include/global.php
EOF

- name: Run PHPStan Analysis
run: |
cd cacti/plugins/syslog
phpstan analyse --no-progress --error-format=github || true

integration-test:
needs: quality-checks
runs-on: ${{ matrix.os }}

strategy:
Expand Down Expand Up @@ -104,7 +162,6 @@ jobs:
- name: Create MySQL Config
run: |
echo -e "[client]\nuser = root\npassword = cactiroot\nhost = 127.0.0.1\n" > ~/.my.cnf
cat ~/.my.cnf

- name: Initialize Cacti Database
env:
Expand Down Expand Up @@ -148,7 +205,7 @@ jobs:
sed -i "s/'cacti'/'cacti'/g" ${{ github.workspace }}/cacti/plugins/syslog/config.php
sed -i "s/'cactiuser'/'cactiuser'/g" ${{ github.workspace }}/cacti/plugins/syslog/config.php
sed -i 's/\/\/\$/\$/g' ${{ github.workspace }}/cacti/plugins/syslog/config.php
sudo chmod 664 ${{ github.workspace }}/cacti/plugins/syslog/config.php
sudo chmod 664 ${{ github.workspace }}/cacti/include/config.php

- name: Configure Apache
run: |
Expand Down Expand Up @@ -179,14 +236,6 @@ jobs:
run: |
cd ${{ github.workspace }}/cacti
sudo php cli/plugin_manage.php --plugin=syslog --install --enable

- name: Check PHP Syntax for Plugin
run: |
cd ${{ github.workspace }}/cacti/plugins/syslog
if find . -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then
echo "Syntax errors found!"
exit 1
fi

- name: Run Plugin Regression Tests
run: |
Expand All @@ -204,7 +253,7 @@ jobs:
cd ${{ github.workspace }}/cacti
sudo php poller.php --poller=1 --force --debug
if ! grep -q "SYSTEM STATS" log/cacti.log; then
echo "Cacti poller did not finish successfully"
print "Cacti poller did not finish successfully"
cat log/cacti.log
exit 1
fi
Expand All @@ -221,7 +270,7 @@ jobs:
cd ${{ github.workspace }}/cacti
sudo php plugins/syslog/syslog_process.php --debug
if ! grep -q "SYSTEM SYSLOG STATS" log/cacti.log; then
echo "Syslog plugin poller did not finish successfully"
print "Syslog plugin poller did not finish successfully"
cat log/cacti.log
exit 1
fi
Expand All @@ -231,41 +280,6 @@ jobs:
if: always()
run: |
if [ -f ${{ github.workspace }}/cacti/log/cacti.log ]; then
echo "=== Cacti Log ==="
print "=== Cacti Log ==="
sudo cat ${{ github.workspace }}/cacti/log/cacti.log
fi


- name: Create PHPStan config
run: |
cd ${{ github.workspace }}/cacti/plugins/syslog
cat > phpstan.neon << 'EOF'
parameters:
level: 5
paths:
- .
excludePaths:
- vendor/
- locales/
ignoreErrors:
- '#has invalid return type the\.#'
bootstrapFiles:
- ../../include/global.php
EOF

- name: Install PHPStan
run: |
cd ${{ github.workspace }}/cacti/plugins/syslog
composer require --dev phpstan/phpstan --with-all-dependencies || composer global require phpstan/phpstan

- name: Run PHPStan Analysis
run: |
cd ${{ github.workspace }}/cacti/plugins/syslog
if [ -f vendor/bin/phpstan ]; then
vendor/bin/phpstan analyse --no-progress --error-format=github || true
else
phpstan analyse --no-progress --error-format=github || true
fi
continue-on-error: true


Loading