diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml index bdbd889..b71a010 100644 --- a/.github/workflows/plugin-ci-workflow.yml +++ b/.github/workflows/plugin-ci-workflow.yml @@ -64,6 +64,7 @@ jobs: uses: actions/checkout@v4 with: repository: Cacti/cacti + ref: release/1.2.31 path: cacti - name: Checkout mactrack Plugin @@ -85,7 +86,7 @@ jobs: run: sudo apt-get update - name: Install System Dependencies - run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping libapache2-mod-php${{ matrix.php }} + run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping - name: Start SNMPD Agent and Test run: | @@ -182,24 +183,40 @@ jobs: - name: Check PHP Syntax for Plugin run: | cd ${{ github.workspace }}/cacti/plugins/mactrack - if find . -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then - echo "Syntax errors found!" - exit 1 - fi - + find . -path './vendor' -prune -o -name '*.php' -print0 | xargs -0 -n1 php -l + + # Cacti 1.2.31 has no .phpstan.neon / lint scripts; only touch them when present. - name: Remove the plugins directory exclusion from the .phpstan.neon - run: sed '/plugins/d' -i .phpstan.neon + run: | + if [ -f .phpstan.neon ]; then + sed '/plugins/d' -i .phpstan.neon + else + echo '.phpstan.neon not present; skipping' + fi working-directory: ${{ github.workspace }}/cacti - name: Mark composer scripts executable - run: sudo chmod +x ${{ github.workspace }}/cacti/include/vendor/bin/* + run: | + if [ -d "${{ github.workspace }}/cacti/include/vendor/bin" ]; then + sudo find "${{ github.workspace }}/cacti/include/vendor/bin" -maxdepth 1 -type f -exec chmod +x {} + + fi - name: Run Linter on base code - run: composer run-script lint ${{ github.workspace }}/cacti/plugins/mactrack + run: | + if composer run-script --list | grep -qE '^ lint'; then + composer run-script lint ${{ github.workspace }}/cacti/plugins/mactrack + else + echo 'Composer lint script is not defined; skipping.' + fi working-directory: ${{ github.workspace }}/cacti - name: Checking coding standards on base code - run: composer run-script phpcsfixer ${{ github.workspace }}/cacti/plugins/mactrack + run: | + if composer run-script --list | grep -qE '^ phpcsfixer'; then + composer run-script phpcsfixer ${{ github.workspace }}/cacti/plugins/mactrack + else + echo 'Composer phpcsfixer script is not defined; skipping.' + fi working-directory: ${{ github.workspace }}/cacti # - name: Run PHPStan at Level 6 on base code outside of Composer due to technical issues