Skip to content

Commit eef4af0

Browse files
authored
Updating workflow to include code validation PHP8.4 and MariaDB 10.6 (#145)
* Adding GitHub Workflows * Spelling issue * Fixing Renderer csfixer issues
1 parent 6bd041c commit eef4af0

2 files changed

Lines changed: 217 additions & 1 deletion

File tree

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# +-------------------------------------------------------------------------+
2+
# | Copyright (C) 2004-2025 The Cacti Group |
3+
# | |
4+
# | This program is free software; you can redistribute it and/or |
5+
# | modify it under the terms of the GNU General Public License |
6+
# | as published by the Free Software Foundation; either version 2 |
7+
# | of the License, or (at your option) any later version. |
8+
# | |
9+
# | This program is distributed in the hope that it will be useful, |
10+
# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11+
# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12+
# | GNU General Public License for more details. |
13+
# +-------------------------------------------------------------------------+
14+
# | Cacti: The Complete RRDtool-based Graphing Solution |
15+
# +-------------------------------------------------------------------------+
16+
# | This code is designed, written, and maintained by the Cacti Group. See |
17+
# | about.php and/or the AUTHORS file for specific developer information. |
18+
# +-------------------------------------------------------------------------+
19+
# | http://www.cacti.net/ |
20+
# +-------------------------------------------------------------------------+
21+
22+
name: Plugin Integration Tests
23+
24+
on:
25+
push:
26+
branches:
27+
- main
28+
- develop
29+
pull_request:
30+
branches:
31+
- main
32+
- develop
33+
34+
jobs:
35+
integration-test:
36+
runs-on: ${{ matrix.os }}
37+
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
php: ['8.1', '8.2', '8.3', '8.4']
42+
os: [ubuntu-latest]
43+
44+
services:
45+
mariadb:
46+
image: mariadb:10.6
47+
env:
48+
MYSQL_ROOT_PASSWORD: cactiroot
49+
MYSQL_DATABASE: cacti
50+
MYSQL_USER: cactiuser
51+
MYSQL_PASSWORD: cactiuser
52+
ports:
53+
- 3306:3306
54+
options: >-
55+
--health-cmd="mysqladmin ping"
56+
--health-interval=10s
57+
--health-timeout=5s
58+
--health-retries=3
59+
60+
name: PHP ${{ matrix.php }} Integration Test on ${{ matrix.os }}
61+
62+
steps:
63+
- name: Checkout Cacti
64+
uses: actions/checkout@v4
65+
with:
66+
repository: Cacti/cacti
67+
path: cacti
68+
69+
- name: Checkout Routerconfigs Plugin
70+
uses: actions/checkout@v4
71+
with:
72+
path: cacti/plugins/routerconfigs
73+
74+
- name: Install PHP ${{ matrix.php }}
75+
uses: shivammathur/setup-php@v2
76+
with:
77+
php-version: ${{ matrix.php }}
78+
extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring
79+
ini-values: "post_max_size=256M, max_execution_time=60, date.timezone=America/New_York"
80+
81+
- name: Check PHP version
82+
run: php -v
83+
84+
- name: Run apt-get update
85+
run: sudo apt-get update
86+
87+
- name: Install System Dependencies
88+
run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping libapache2-mod-php${{ matrix.php }}
89+
90+
- name: Start SNMPD Agent and Test
91+
run: |
92+
sudo systemctl start snmpd
93+
sudo snmpwalk -c public -v2c -On localhost .1.3.6.1.2.1.1
94+
95+
- name: Setup Permissions
96+
run: |
97+
sudo chown -R www-data:runner ${{ github.workspace }}/cacti
98+
sudo find ${{ github.workspace }}/cacti -type d -exec chmod 775 {} \;
99+
sudo find ${{ github.workspace }}/cacti -type f -exec chmod 664 {} \;
100+
sudo chmod +x ${{ github.workspace }}/cacti/cmd.php
101+
sudo chmod +x ${{ github.workspace }}/cacti/poller.php
102+
103+
- name: Create MySQL Config
104+
run: |
105+
echo -e "[client]\nuser = root\npassword = cactiroot\nhost = 127.0.0.1\n" > ~/.my.cnf
106+
cat ~/.my.cnf
107+
108+
- name: Initialize Cacti Database
109+
env:
110+
MYSQL_AUTH_USR: '--defaults-file=~/.my.cnf'
111+
run: |
112+
mysql $MYSQL_AUTH_USR -e 'CREATE DATABASE IF NOT EXISTS cacti;'
113+
mysql $MYSQL_AUTH_USR -e "CREATE USER IF NOT EXISTS 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';"
114+
mysql $MYSQL_AUTH_USR -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';"
115+
mysql $MYSQL_AUTH_USR -e "GRANT SELECT ON mysql.time_zone_name TO 'cactiuser'@'localhost';"
116+
mysql $MYSQL_AUTH_USR -e "FLUSH PRIVILEGES;"
117+
mysql $MYSQL_AUTH_USR cacti < ${{ github.workspace }}/cacti/cacti.sql
118+
mysql $MYSQL_AUTH_USR -e "INSERT INTO settings (name, value) VALUES ('path_php_binary', '/usr/bin/php')" cacti
119+
120+
- name: Validate composer files
121+
run: |
122+
cd ${{ github.workspace }}/cacti
123+
if [ -f composer.json ]; then
124+
composer validate --strict || true
125+
fi
126+
127+
- name: Install Composer Dependencies
128+
run: |
129+
cd ${{ github.workspace }}/cacti
130+
if [ -f composer.json ]; then
131+
sudo composer install --prefer-dist --no-progress
132+
fi
133+
134+
- name: Create Cacti config.php
135+
run: |
136+
cat ${{ github.workspace }}/cacti/include/config.php.dist | \
137+
sed -r "s/localhost/127.0.0.1/g" | \
138+
sed -r "s/'cacti'/'cacti'/g" | \
139+
sed -r "s/'cactiuser'/'cactiuser'/g" | \
140+
sed -r "s/'cactiuser'/'cactiuser'/g" > ${{ github.workspace }}/cacti/include/config.php
141+
sudo chmod 664 ${{ github.workspace }}/cacti/include/config.php
142+
143+
- name: Configure Apache
144+
run: |
145+
cat << 'EOF' | sed 's#GITHUB_WORKSPACE#${{ github.workspace }}#g' > /tmp/cacti.conf
146+
<VirtualHost *:80>
147+
ServerAdmin webmaster@localhost
148+
DocumentRoot GITHUB_WORKSPACE/cacti
149+
150+
<Directory GITHUB_WORKSPACE/cacti>
151+
Options Indexes FollowSymLinks
152+
AllowOverride All
153+
Require all granted
154+
</Directory>
155+
156+
ErrorLog ${APACHE_LOG_DIR}/error.log
157+
CustomLog ${APACHE_LOG_DIR}/access.log combined
158+
</VirtualHost>
159+
EOF
160+
sudo cp /tmp/cacti.conf /etc/apache2/sites-available/000-default.conf
161+
sudo systemctl restart apache2
162+
163+
- name: Install Cacti via CLI
164+
run: |
165+
cd ${{ github.workspace }}/cacti
166+
sudo php cli/install_cacti.php --accept-eula --install --force
167+
168+
- name: Install Routerconfigs Plugin
169+
run: |
170+
cd ${{ github.workspace }}/cacti
171+
sudo php cli/plugin_manage.php --plugin=routerconfigs --install --enable
172+
173+
- name: Check PHP Syntax for Plugin
174+
run: |
175+
cd ${{ github.workspace }}/cacti/plugins/routerconfigs
176+
if find . -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then
177+
echo "Syntax errors found!"
178+
exit 1
179+
fi
180+
181+
- name: Remove the plugins directory exclusion from the .phpstan.neon
182+
run: sed '/plugins/d' -i .phpstan.neon
183+
working-directory: ${{ github.workspace }}/cacti
184+
185+
- name: Mark composer scripts executable
186+
run: sudo chmod +x ${{ github.workspace }}/cacti/include/vendor/bin/*
187+
188+
- name: Run Linter on base code
189+
run: composer run-script lint ${{ github.workspace }}/cacti/plugins/routerconfigs
190+
working-directory: ${{ github.workspace }}/cacti
191+
192+
- name: Checking coding standards on base code
193+
run: composer run-script phpcsfixer ${{ github.workspace }}/cacti/plugins/routerconfigs
194+
working-directory: ${{ github.workspace }}/cacti
195+
196+
# - name: Run PHPStan at Level 6 on base code outside of Composer due to technical issues
197+
# run: ./include/vendor/bin/phpstan analyze --level 6 ${{ github.workspace }}/cacti/plugins/routerconfigs
198+
# working-directory: ${{ github.workspace }}/cacti
199+
200+
- name: Run Cacti Poller
201+
run: |
202+
cd ${{ github.workspace }}/cacti
203+
sudo php poller.php --poller=1 --force --debug
204+
if ! grep -q "SYSTEM STATS" log/cacti.log; then
205+
echo "Cacti poller did not finish successfully"
206+
cat log/cacti.log
207+
exit 1
208+
fi
209+
210+
- name: View Cacti Logs
211+
if: always()
212+
run: |
213+
if [ -f ${{ github.workspace }}/cacti/log/cacti.log ]; then
214+
echo "=== Cacti Log ==="
215+
sudo cat ${{ github.workspace }}/cacti/log/cacti.log
216+
fi

Text/Diff/Renderer/Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ protected function _changed($orig, $final) {
156156

157157
// Get the diff in inline format.
158158
$renderer = new Horde_Text_Diff_Renderer_inline(array_merge($this->getParams(),
159-
['split_level' => $this->_split_characters ? 'characters' : 'words']));
159+
['split_level' => $this->_split_characters ? 'characters' : 'words']));
160160

161161
// Run the diff and get the output.
162162
return str_replace($nl, "\n", $renderer->render($diff)) . "\n";

0 commit comments

Comments
 (0)