Skip to content

ci: add Dependabot config and Pest unit-test framework - #96

Merged
TheWitness merged 10 commits into
mainfrom
ci/unit-test-framework
Sep 12, 2026
Merged

TheWitness merged 10 commits into
mainfrom
ci/unit-test-framework

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Summary

  • Add enterprise Dependabot configuration (.github/dependabot.yml) for weekly GitHub Actions updates.
  • CI workflow (.github/workflows/plugin-ci-workflow.yml):
    • Test PHP 8.2-8.4 against Cacti (dropped 8.1) and add the ppa:ondrej/php PPA.
    • Stop installing apache2/libapache2-mod-php, already provided by the PPA.
    • Pin the Cacti checkout to env.CACTI (1.2.x) to match this plugin's compatibility target.
    • Add the snmp PHP extension.
    • Install Pest (pestphp/pest, pestphp/pest-plugin-drift) as dev dependencies.
    • Add steps to set the expected Cacti version and run Pest unit tests, guarded so they skip cleanly until tests/Security and phpunit.xml are added in a follow-up PR.
    • Upload coverage report artifact.
    • Gate linter/phpcsfixer/PHPStan steps behind env.CACTI != '1.2.x', mirroring Cacti/plugin_evidence.
  • Add tests/ directory (TestCase.php, Pest.php, bootstrap-unit.php, .cacti-version), adapted from Cacti/plugin_evidence's test bootstrap for use with servcheck (evidence_test_load() renamed to servcheck_test_load()).

Actual Security test cases and phpunit.xml will follow in a separate PR.

somethingwithproof and others added 6 commits July 14, 2026 10:51
Cacti core now requires PHP >= 8.2, so the 8.1 integration job fails the
composer platform check; Ubuntu Noble also lacks libapache2-mod-php for
non-native versions without the ondrej PPA.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Copilot AI lite review requested due to automatic review settings September 12, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved CI configuration and test-bootstrap issues include a critical Apache PHP runtime problem.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds Dependabot automation and Pest unit-test scaffolding while updating CI for supported PHP and Cacti versions.

Changes:

  • Adds weekly GitHub Actions Dependabot updates.
  • Updates CI for PHP 8.2–8.4, Cacti 1.2.x, SNMP, Pest, and coverage.
  • Adds test bootstrap files and Cacti version validation.
File summaries
File Summary Findings
tests/TestCase.php Adds the base test case. No findings.
tests/Pest.php Adds Pest configuration. Restore the full GPLv2 header (nit, 2 votes).
tests/bootstrap-unit.php Adds Cacti-compatible test bootstrap and stubs. Add credential-setting stubs; rename the generic source-reading helper; match required Cacti function signatures (moderate, 1–2 votes each).
tests/.cacti-version Defines the expected Cacti version. No findings.
.github/workflows/plugin-ci-workflow.yml Expands CI and Pest integration. Register the PPA before PHP setup (moderate, 1 vote); install the Apache PHP module or configure PHP-FPM (critical, 1 vote).
.github/dependabot.yml Configures weekly GitHub Actions updates. No findings.
Review details

Suppressed comments (5)

.github/workflows/plugin-ci-workflow.yml:82

  • The Ondřej PHP PPA is added only after setup-php has already installed PHP and all requested extensions, so this step cannot make the PHP 8.4/snmp packages available during extension setup. Move the PPA registration and apt-get update before the Install PHP step; otherwise the new matrix can still fail before the repository is configured.
        extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring, snmp

tests/bootstrap-unit.php:168

  • Loading includes/functions.php and exercising servcheck_encrypt_credential() will call read_user_setting() and set_user_setting(), but neither Cacti helper is defined by this bootstrap. The first credential-security test that reaches this path will therefore fail with an undefined-function error instead of testing encryption; add deterministic in-memory stubs for both helpers.
if (!function_exists('read_config_option')) {
	function read_config_option($name, $force = false) {
		return '';
	}
}

tests/bootstrap-unit.php:123

  • This stub accepts only two arguments, but the existing plugin calls db_fetch_row_prepared() with a third $log flag in servcheck_restapi.php:266. Under the PHP 8 CI matrix, exercising that path will fail with an argument-count error before the plugin logic runs; mirror Cacti's optional third parameter.
	function db_fetch_row_prepared($sql, $params = array()) {

tests/bootstrap-unit.php:228

  • The stub has only one parameter, while existing plugin validation paths pass a filter and an options array (for example, servcheck_restapi.php:211-235). Tests that invoke those paths will hit an argument-count error instead of the Cacti validation behavior; match the three-argument Cacti signature.
	function get_filter_request_var($name) {

tests/bootstrap-unit.php:182

  • Cacti's __() helper accepts formatting/domain arguments, and this plugin already passes three arguments in places such as setup.php:662 and servcheck_test.php:475. The two-parameter stub will fail when those paths are exercised; make the test double variadic while retaining the safe default return.
	function __($text, $domain = '') {
  • Files reviewed: 6/6 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/plugin-ci-workflow.yml
Comment thread tests/bootstrap-unit.php Outdated
Comment thread tests/Pest.php
@TheWitness
TheWitness merged commit f0860c4 into main Sep 12, 2026
3 checks passed
@TheWitness
TheWitness deleted the ci/unit-test-framework branch September 12, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants