QA: Fixing #6331 - Incorrect calculation for profile_id #4191
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # +-------------------------------------------------------------------------+ | |
| # | Copyright (C) 2004-2024 The Cacti Group | | |
| # | | | |
| # | This program is free software; you can redistribute it and/or | | |
| # | modify it under the terms of the GNU General Public License | | |
| # | as published by the Free Software Foundation; either version 2 | | |
| # | of the License, or (at your option) any later version. | | |
| # | | | |
| # | This program is distributed in the hope that it will be useful, | | |
| # | but WITHOUT ANY WARRANTY; without even the implied warranty of | | |
| # | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | |
| # | GNU General Public License for more details. | | |
| # +-------------------------------------------------------------------------+ | |
| # | Cacti: The Complete RRDtool-based Graphing Solution | | |
| # +-------------------------------------------------------------------------+ | |
| # | This code is designed, written, and maintained by the Cacti Group. See | | |
| # | about.php and/or the AUTHORS file for specific developer information. | | |
| # +-------------------------------------------------------------------------+ | |
| # | http://www.cacti.net/ | | |
| # +-------------------------------------------------------------------------+ | |
| name: Cacti Commit Audit | |
| on: | |
| push: | |
| branches: [ 1.2.x ] | |
| pull_request: | |
| branches: [ 1.2.x ] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: build-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| php: ['7.0','7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] | |
| experimental: [false] | |
| services: | |
| mysql: | |
| image: mysql:latest | |
| env: | |
| MYSQL_DATABASE: cacti | |
| MYSQL_HOST: 127.0.0.1 | |
| MYSQL_USER: cactiuser | |
| MYSQL_PASSWORD: cactiuser | |
| MYSQL_ROOT_PASSWORD: cactiroot | |
| ports: | |
| - 3306:3306 | |
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
| name: PHP ${{ matrix.php }} Test on ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Install PHP ${{ matrix.php }} | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring #optional | |
| ini-values: "post_max_size=256M, max_execution_time=60, date.timezone=America/New_York" #optional | |
| - name: Check PHP version | |
| run: php -v | |
| - name: Checkout Thold Plugin | |
| uses: GuillaumeFalourd/clone-github-repo-action@v2 | |
| with: | |
| owner: 'Cacti' | |
| repository: 'plugin_thold' | |
| - name: Checkout Monitor Plugin | |
| uses: GuillaumeFalourd/clone-github-repo-action@v2 | |
| with: | |
| owner: 'Cacti' | |
| repository: 'plugin_monitor' | |
| - name: Checkout MacTrack Plugin | |
| uses: GuillaumeFalourd/clone-github-repo-action@v2 | |
| with: | |
| owner: 'Cacti' | |
| repository: 'plugin_mactrack' | |
| - name: Checkout Intropage Plugin | |
| uses: GuillaumeFalourd/clone-github-repo-action@v2 | |
| with: | |
| owner: 'Cacti' | |
| repository: 'plugin_intropage' | |
| - name: Checkout FlowView Plugin | |
| uses: GuillaumeFalourd/clone-github-repo-action@v2 | |
| with: | |
| owner: 'Cacti' | |
| repository: 'plugin_flowview' | |
| - name: Checkout Audit Plugin | |
| uses: GuillaumeFalourd/clone-github-repo-action@v2 | |
| with: | |
| owner: 'Cacti' | |
| repository: 'plugin_audit' | |
| - name: Checkout Syslog Plugin | |
| uses: GuillaumeFalourd/clone-github-repo-action@v2 | |
| with: | |
| owner: 'Cacti' | |
| repository: 'plugin_syslog' | |
| - name: Move Plugins to Plugin Directory | |
| run: | | |
| mv plugin_thold ${{ github.workspace }}/plugins/thold | |
| mv plugin_monitor ${{ github.workspace }}/plugins/monitor | |
| mv plugin_mactrack ${{ github.workspace }}/plugins/mactrack | |
| mv plugin_audit ${{ github.workspace }}/plugins/audit | |
| mv plugin_flowview ${{ github.workspace }}/plugins/flowview | |
| mv plugin_intropage ${{ github.workspace }}/plugins/intropage | |
| mv plugin_syslog ${{ github.workspace }}/plugins/syslog | |
| # With syslog we have to enable batch installs using the lines below | |
| cd ${{ github.workspace }}/plugins/syslog | |
| cp -p config.php.dist config.php | |
| sed -i 's/\/\/\$syslog_install_options/\$syslog_install_options/g' config.php | |
| - name: Move plugin config files | |
| run: | | |
| cp -p ${{ github.workspace }}/plugins/flowview/config.php.dist ${{ github.workspace }}/plugins/flowview/config.php | |
| cp -p ${{ github.workspace }}/plugins/syslog/config.php.dist ${{ github.workspace }}/plugins/syslog/config.php | |
| sed -i 's/\/\/\$/\$/g' ${{ github.workspace }}/plugins/syslog/config.php | |
| - name: Check PHP syntax | |
| run: if find ${{ github.workspace }} -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then exit 1; fi | |
| - name: Run and apt-get update | |
| run: sudo apt-get update | |
| - name: Install Apache and Tools | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: sudo apt-get install apache2 snmp snmpd rrdtool libapache2-mod-php${{ matrix.php }} | |
| - name: Start SNMPD Agent and Test Agent | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| sudo systemctl start snmpd | |
| sudo snmpwalk -c public -v2c -On localhost .1.3.6.1.2.1.1 | |
| - name: Link Web Root and Fix Permissions and Disable Apparmor | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| sudo ln -s /home/runner/work/cacti/cacti /var/www/html | |
| sudo find /home/runner/work/cacti -type d -exec chmod 777 {} \; | |
| sudo find /home/runner/work/cacti -type f -exec chmod 777 {} \; | |
| sudo systemctl stop apparmor | |
| sudo systemctl disable apparmor | |
| sudo chown -R www-data:runner /home/runner/work/cacti | |
| sudo chmod o+x /home | |
| sudo chmod o+x /home/runner | |
| sudo chmod o+x /home/runner/work | |
| sudo chmod o+x /home/runner/work/cacti | |
| sudo chmod o+x /home/runner/work/cacti/cacti | |
| - name: Configure Apache Site | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cat ${{ github.workspace }}/tests/tools/cacti.conf | sed -r 's#GITHUB_WORKSPACE#${{ github.workspace }}#g' > /tmp/cacti.conf | |
| sudo cp /tmp/cacti.conf /etc/apache2/sites-available/000-default.conf | |
| - name: Restart Apache2 | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: sudo systemctl restart apache2 | |
| - name: Create and Initialize Database | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| env: | |
| MYSQL_AUTH_USR: '--defaults-file=~/.my.cnf' | |
| run: | | |
| echo -e "[client]\nuser = root\npassword = cactiroot\nhost = 127.0.0.1\n" >> ~/.my.cnf | |
| cat ~/.my.cnf | |
| mysql $MYSQL_AUTH_USR -e 'CREATE DATABASE IF NOT EXISTS cacti;' | |
| mysql $MYSQL_AUTH_USR -e "CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';" | |
| mysql $MYSQL_AUTH_USR -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';" | |
| mysql $MYSQL_AUTH_USR -e "FLUSH PRIVILEGES;" | |
| mysql $MYSQL_AUTH_USR cacti < ${{ github.workspace }}/cacti.sql | |
| mysql $MYSQL_AUTH_USR -e "INSERT INTO settings (name, value) VALUES ('path_php_binary', '/bin/php')" cacti | |
| - name: Prime Cacti config.php File | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cat ${{ github.workspace }}/include/config.php.dist | sed -r "s/localhost/127.0.0.1/g" > ${{ github.workspace }}/include/config.php | |
| sudo chmod 777 ${{ github.workspace }}/include/config.php | |
| cat ${{ github.workspace}}/include/config.php | |
| - name: Setup Cacti Daemon | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| sudo cp ${{ github.workspace }}/tests/tools/cactid.service /etc/systemd/system/cactid.service | |
| sudo systemctl enable cactid | |
| sudo systemctl start cactid | |
| sudo systemctl status cactid | |
| if ! systemctl is-active --quiet cactid; then | |
| echo "Cacti daemon failed to start" | |
| exit 1 | |
| fi | |
| - name: Check install code for validity | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cd ${{ github.workspace }} | |
| sudo php -q tests/tools/check_install_code.php | |
| - name: Check that all CLI scripts have a valid --version flag | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cd ${{ github.workspace }} | |
| sudo bash tests/tools/check_cli_version.sh | |
| - name: Install Cacti through the CLI | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cd ${{ github.workspace }} | |
| sudo php cli/install_cacti.php --accept-eula --install --force | |
| - name: Audit the Installation Schema | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cd ${{ github.workspace }} | |
| sudo php cli/audit_database.php --report | |
| - name: Install and Enable Plugins | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cd ${{ github.workspace }} | |
| sudo php cli/plugin_manage.php --plugin=thold --plugin=intropage --plugin=monitor --plugin=mactrack --plugin=audit --plugin=flowview --plugin=syslog --install --enable --allperms | |
| - name: Add Device for Moc Test, Check CLI scripts for Errors | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cd ${{ github.workspace }} | |
| sudo php cli/add_device.php --description=test_device --ip=127.0.0.1 --template=24 | |
| sudo php cli/rebuild_poller_cache.php --debug | |
| sudo php cli/poller_reindex_hosts.php --id=all --debug | |
| - name: Run Cacti poller | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| sudo php ${{ github.workspace }}/poller.php --poller=1 --force --debug | |
| if ! grep -q "SYSTEM STATS" ${{ github.workspace }}/log/cacti.log; then | |
| echo "Cacti poller did not finish successfully" | |
| exit 1 | |
| fi | |
| - name: Check All Pages Using Recursive wget | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: | | |
| cd ${{ github.workspace }} | |
| echo -e "[client]\nuser = root\npassword = cactiroot\nhost = 127.0.0.1\n" > ${{ github.workspace }}/.my.cnf | |
| sudo tests/tools/check_all_pages.sh | |
| - name: View Contents of Logs | |
| if: ${{ '5.4' != matrix.php && '7.0' != matrix.php }} # removed old php from page tests | |
| run: sudo cat ${{ github.workspace }}/log/cacti.log | |
| # - name: Validate composer.json and composer.lock | |
| # run: composer validate --strict | |
| # - name: Cache Composer packages | |
| # id: composer-cache | |
| # uses: actions/cache@v3 | |
| # with: | |
| # path: vendor | |
| # key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-php- | |
| # | |
| # - name: Install dependencies | |
| # run: composer install --prefer-dist --no-progress | |
| # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" | |
| # Docs: https://getcomposer.org/doc/articles/scripts.md | |
| # | |
| # - name: Run test suite | |
| # run: composer run-script test |