Skip to content

Feature/setup ci cd - #3

Merged
raphaelsuzuki merged 9 commits into
mainfrom
feature/setup-ci-cd
Feb 22, 2026
Merged

raphaelsuzuki merged 9 commits into
mainfrom
feature/setup-ci-cd

Conversation

@raphaelsuzuki

@raphaelsuzuki raphaelsuzuki commented Feb 18, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Chores

    • Enabled weekly Dependabot updates with grouped PRs.
    • Added CI pipelines for linting and matrixed unit tests and overall CI orchestration.
    • Added composer metadata and development tooling.
  • Style

    • Introduced PHP coding standards configuration and updated ignore patterns.
  • Tests

    • Added PHPUnit configuration, test bootstrap, test environment config, and a sample unit test.
  • Documentation

    • Updated README with CI badges and Dependabot notes.
    • Added CONTRIBUTING with development and testing guidelines.

@coderabbitai

coderabbitai Bot commented Feb 18, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds CI/CD and developer tooling: GitHub Actions workflows (CI, PHPCS, PHPUnit), Dependabot config, Composer manifest, PHPCS/phpunit configs, PHPUnit bootstrap and sample test, CONTRIBUTING/README updates, and .gitignore entries for common artifacts.

Changes

Cohort / File(s) Summary
GitHub Actions Workflows
.github/workflows/ci.yml, .github/workflows/phpcs.yml, .github/workflows/phpunit.yml
Adds CI workflows: combined CI and separate PHPCS/PHPUnit pipelines. PHPUnit workflow runs a PHP matrix (8.0, 8.1) with WordPress, uses a MySQL 5.7 service, sets up PHP extensions/Xdebug, caches Composer, bootstraps WP test environment, and runs composer test.
Dependabot & Composer manifest
.github/dependabot.yml, composer.json
Adds Dependabot config for Composer (weekly, PR limit 5, production/dev groups) and a new composer.json declaring package metadata, dev dependencies (PHPCS, WPCS, PHPUnit, polyfills) and scripts for linting/testing.
Code Quality & Test Config
phpcs.xml.dist, phpunit.xml.dist
Adds PHPCS ruleset (WordPress-Extra base, PHP >=8.0, exclusions, parallel jobs, text domain) and PHPUnit config (bootstrap, test suite, coverage includes/excludes, convert warnings/notices to exceptions).
Tests & Bootstrap
tests/bootstrap.php, tests/test-sample.php, tests/wp-tests-config.php
Adds WP PHPUnit bootstrap and test config; loads Composer autoloader, resolves WP tests path/env, registers plugin loader, and includes WP test bootstrap. Adds a sample WP_UnitTestCase with basic assertions and a tests config for CI env vars.
Repository Docs & Ignores
CONTRIBUTING.md, README.md, .gitignore
Adds CONTRIBUTING with contribution/CI/testing instructions, updates README (badges, features, Dependabot mention), and updates .gitignore to exclude vendor/, node_modules/, and common test/coverage/config files.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Dev as GitHub Runner
participant Repo as Repository
participant PHP as PHP Environment
participant Composer as Composer
participant MySQL as MySQL 5.7 Service
participant WP as WordPress Test Setup
participant PHPUnit as Test Executor

Dev->>Repo: checkout code
Dev->>PHP: setup PHP (matrix: 8.0/8.1) with extensions/Xdebug
Dev->>Composer: restore/cache dependencies
Composer->>Dev: install dev dependencies
Dev->>MySQL: start service
Dev->>WP: download/configure WP test files
WP->>Dev: export WP_* test env vars
Dev->>PHPUnit: run composer test (executes tests/bootstrap.php -> runs tests)
PHPUnit->>Dev: report results

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Feature/setup ci cd' is vague and uses non-descriptive conventions; it lacks clarity about what CI/CD setup was implemented. Consider a more descriptive title like 'Add GitHub Actions workflows and development tooling for PHP linting and testing' to clearly convey the main changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/setup-ci-cd

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (5)
.github/workflows/phpcs.yml (2)

1-39: Redundant workflow - consolidate with ci.yml.

This entire workflow duplicates the phpcs job already defined in .github/workflows/ci.yml. Both workflows trigger on the same events and perform identical checks, which wastes CI resources and creates duplicate status checks on PRs.

Consider removing this standalone workflow and relying on ci.yml for PHPCS checks, or vice versa - remove the PHPCS job from ci.yml if you prefer separate workflow files.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/phpcs.yml around lines 1 - 39, The PHPCS workflow is
redundant with the phpcs job in ci.yml; remove or consolidate it by deleting
this workflow file (the workflow named "PHPCS") or by removing the duplicate job
"phpcs" from the other workflow so there is a single source of truth; ensure the
chosen workflow still includes the same steps (Checkout code, Set up PHP,
Install dependencies, Run PHPCS) and retains the run command "./vendor/bin/phpcs
-n" and any required cache/setup steps to preserve behavior.

18-18: Consider pinning third-party actions to full commit SHA.

The shivammathur/setup-php@v2 action is referenced by tag rather than a full commit SHA. Pinning to a specific commit SHA provides better security by ensuring the action code cannot change unexpectedly.

This is a security best practice but involves a trade-off with maintainability (you'll need to manually update SHAs for security patches).

🔒 Example with pinned SHA
      - name: Set up PHP
-       uses: shivammathur/setup-php@v2
+       uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
        with:
          php-version: '8.1'

Note: Verify the latest commit SHA for the version you want to use.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/phpcs.yml at line 18, Update the GitHub Action reference
to pin the third-party action to a specific commit SHA instead of the tag:
replace the uses entry "shivammathur/setup-php@v2" with the same action
referenced by its full commit SHA (e.g.,
"shivammathur/setup-php@<full-commit-sha>") so the workflow uses an immutable
version; locate the line containing uses: shivammathur/setup-php@v2 in the
workflow file and substitute the tag with the exact commit SHA for the desired
v2 release.
.github/workflows/phpunit.yml (2)

36-36: Consider pinning third-party actions to full commit SHA.

Same recommendation as for the PHPCS workflow - shivammathur/setup-php@v2 should ideally be pinned to a specific commit SHA for security.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/phpunit.yml at line 36, Replace the floating action tag
shivammathur/setup-php@v2 with a pinned full commit SHA to avoid supply-chain
risk: locate the uses entry referencing "shivammathur/setup-php@v2" and update
it to "shivammathur/setup-php@<full-commit-sha>" (you can find the exact SHA on
the action's GitHub tags or commit history), then commit the change and
optionally add a short comment noting the pinned SHA for future updates.

1-73: Redundant workflow - consolidate with ci.yml.

This workflow duplicates the phpunit job already defined in .github/workflows/ci.yml. Both use the same matrix, MySQL service configuration, and test execution steps. Consider consolidating to avoid redundant CI runs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/phpunit.yml around lines 1 - 73, This workflow duplicates
the phpunit job defined in .github/workflows/ci.yml (the job named "phpunit" /
workflow name "PHPUnit"); remove or consolidate it by deleting this file and/or
moving its matrix, services (mysql), setup steps and the Run PHPUnit step into
the existing ci.yml job so tests run once; ensure the matrix keys (php-versions,
wordpress-versions), service configuration (mysql image and env), and the Run
PHPUnit invocation (composer test with WP_CORE_DIR) are preserved in ci.yml and
update any workflow triggers to avoid redundant CI runs.
.github/workflows/ci.yml (1)

18-18: Consider pinning third-party actions to full commit SHA.

The shivammathur/setup-php@v2 action at lines 18 and 67 should ideally be pinned to a specific commit SHA. This applies to all instances in this workflow.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml at line 18, Replace the floating tag
"shivammathur/setup-php@v2" with a pinned full commit SHA reference (e.g.,
"shivammathur/setup-php@<commit-sha>") for every occurrence in the workflow to
ensure immutability; locate instances of the action string
"shivammathur/setup-php@v2" and update both occurrences (the one at the top and
the one later) to use the exact commit SHA from the action's repository, and
verify no other third-party actions remain unpinned.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 38-39: The CI runs are inconsistent because ci.yml invokes
"composer phpcs" (composer script "phpcs") while phpcs.yml uses
"./vendor/bin/phpcs -n"; update the composer script named "phpcs" in
composer.json to include the -n flag (e.g., make the "phpcs" script run
"./vendor/bin/phpcs -n") or alternatively change ci.yml to call the exact same
command used in phpcs.yml so both workflows invoke "./vendor/bin/phpcs -n" and
produce identical PHPCS output.

In `@phpcs.xml.dist`:
- Around line 22-23: The comment above the testVersion config is inaccurate: it
says "Set minimum PHP version to 7.4" while the <config name="testVersion"
value="8.0-"/> sets PHP 8.0 as the minimum; update the comment to reflect the
actual configured version (e.g., "Set minimum PHP version to 8.0") so the
human-readable note matches the testVersion entry.

In `@tests/bootstrap.php`:
- Around line 41-43: The DB_PASSWORD constant is currently populated from
getenv('WP_DB_PASS') which is inconsistent with the other WP_DB_* vars and
common CI naming; update the DB_PASSWORD initialization to check for
getenv('WP_DB_PASSWORD') first and fall back to getenv('WP_DB_PASS') (and then
to empty string) so both environment names are supported (i.e., replace the
getenv('WP_DB_PASS') call used when defining DB_PASSWORD with a lookup that
prefers 'WP_DB_PASSWORD' then 'WP_DB_PASS').

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Line 18: Replace the floating tag "shivammathur/setup-php@v2" with a pinned
full commit SHA reference (e.g., "shivammathur/setup-php@<commit-sha>") for
every occurrence in the workflow to ensure immutability; locate instances of the
action string "shivammathur/setup-php@v2" and update both occurrences (the one
at the top and the one later) to use the exact commit SHA from the action's
repository, and verify no other third-party actions remain unpinned.

In @.github/workflows/phpcs.yml:
- Around line 1-39: The PHPCS workflow is redundant with the phpcs job in
ci.yml; remove or consolidate it by deleting this workflow file (the workflow
named "PHPCS") or by removing the duplicate job "phpcs" from the other workflow
so there is a single source of truth; ensure the chosen workflow still includes
the same steps (Checkout code, Set up PHP, Install dependencies, Run PHPCS) and
retains the run command "./vendor/bin/phpcs -n" and any required cache/setup
steps to preserve behavior.
- Line 18: Update the GitHub Action reference to pin the third-party action to a
specific commit SHA instead of the tag: replace the uses entry
"shivammathur/setup-php@v2" with the same action referenced by its full commit
SHA (e.g., "shivammathur/setup-php@<full-commit-sha>") so the workflow uses an
immutable version; locate the line containing uses: shivammathur/setup-php@v2 in
the workflow file and substitute the tag with the exact commit SHA for the
desired v2 release.

In @.github/workflows/phpunit.yml:
- Line 36: Replace the floating action tag shivammathur/setup-php@v2 with a
pinned full commit SHA to avoid supply-chain risk: locate the uses entry
referencing "shivammathur/setup-php@v2" and update it to
"shivammathur/setup-php@<full-commit-sha>" (you can find the exact SHA on the
action's GitHub tags or commit history), then commit the change and optionally
add a short comment noting the pinned SHA for future updates.
- Around line 1-73: This workflow duplicates the phpunit job defined in
.github/workflows/ci.yml (the job named "phpunit" / workflow name "PHPUnit");
remove or consolidate it by deleting this file and/or moving its matrix,
services (mysql), setup steps and the Run PHPUnit step into the existing ci.yml
job so tests run once; ensure the matrix keys (php-versions,
wordpress-versions), service configuration (mysql image and env), and the Run
PHPUnit invocation (composer test with WP_CORE_DIR) are preserved in ci.yml and
update any workflow triggers to avoid redundant CI runs.

Comment thread .github/workflows/ci.yml
Comment on lines +38 to +39
- name: Run PHPCS
run: composer phpcs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check how composer phpcs script is defined
cat composer.json | jq '.scripts.phpcs' 2>/dev/null || cat composer.json | grep -A 2 '"phpcs"'

Repository: raphaelsuzuki/pmpro-level-explorer

Length of output: 85


🏁 Script executed:

# Also check the phpcs.yml workflow file
cat .github/workflows/phpcs.yml

Repository: raphaelsuzuki/pmpro-level-explorer

Length of output: 1065


🏁 Script executed:

#!/bin/bash
# Get the scripts section from composer.json
cat composer.json | jq '.scripts'

Repository: raphaelsuzuki/pmpro-level-explorer

Length of output: 210


Workflows have inconsistent PHPCS output behavior.

ci.yml runs composer phpcs (which executes phpcs with no flags), while phpcs.yml runs ./vendor/bin/phpcs -n (which suppresses warnings). The -n flag changes which issues are reported, potentially causing the same code to pass one workflow but fail another. Update the phpcs script in composer.json to include the -n flag, or standardize both workflows to use the same command.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml around lines 38 - 39, The CI runs are inconsistent
because ci.yml invokes "composer phpcs" (composer script "phpcs") while
phpcs.yml uses "./vendor/bin/phpcs -n"; update the composer script named "phpcs"
in composer.json to include the -n flag (e.g., make the "phpcs" script run
"./vendor/bin/phpcs -n") or alternatively change ci.yml to call the exact same
command used in phpcs.yml so both workflows invoke "./vendor/bin/phpcs -n" and
produce identical PHPCS output.

Comment thread phpcs.xml.dist Outdated
Comment thread tests/bootstrap.php Outdated
Comment on lines +41 to +43
if ( ! defined( 'DB_PASSWORD' ) ) {
define( 'DB_PASSWORD', getenv( 'WP_DB_PASS' ) ?: '' );
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify which DB env vars are used in workflows/scripts/docs.
rg -n --hidden -g '!vendor/**' -g '!.git/**' -C2 'WP_DB_(PASS|PASSWORD|USER|NAME|HOST)|DB_PASSWORD' .

Repository: raphaelsuzuki/pmpro-level-explorer

Length of output: 872


Environment variable naming inconsistency for DB password.

Line 42 uses WP_DB_PASS, but the other database credentials follow the WP_DB_* naming pattern (WP_DB_NAME, WP_DB_USER, WP_DB_HOST). Additionally, standard WordPress testing setups and most CI tools use WP_DB_PASSWORD, not WP_DB_PASS. If only WP_DB_PASSWORD is set in the environment, authentication will silently fail with an empty password, breaking tests. Support both variable names.

🔧 Suggested fix
if ( ! defined( 'DB_PASSWORD' ) ) {
-	define( 'DB_PASSWORD', getenv( 'WP_DB_PASS' ) ?: '' );
+	define( 'DB_PASSWORD', getenv( 'WP_DB_PASS' ) ?: getenv( 'WP_DB_PASSWORD' ) ?: '' );
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/bootstrap.php` around lines 41 - 43, The DB_PASSWORD constant is
currently populated from getenv('WP_DB_PASS') which is inconsistent with the
other WP_DB_* vars and common CI naming; update the DB_PASSWORD initialization
to check for getenv('WP_DB_PASSWORD') first and fall back to
getenv('WP_DB_PASS') (and then to empty string) so both environment names are
supported (i.e., replace the getenv('WP_DB_PASS') call used when defining
DB_PASSWORD with a lookup that prefers 'WP_DB_PASSWORD' then 'WP_DB_PASS').

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/wp-tests-config.php`:
- Around line 14-16: The code defines DB_PASSWORD using only
getenv('WP_DB_PASS'); update the definition to check getenv('WP_DB_PASSWORD')
first and fall back to getenv('WP_DB_PASS') so DB_PASSWORD supports both env
names; modify the DB_PASSWORD define (the define('DB_PASSWORD', ...) expression)
to use WP_DB_PASSWORD if present, otherwise use WP_DB_PASS, preserving the
existing empty-string default.

@raphaelsuzuki
raphaelsuzuki merged commit d917115 into main Feb 22, 2026
10 of 14 checks passed
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.

1 participant