Skip to content

Commit 1b0944c

Browse files
Ops Health Dashboard Devclaude
andcommitted
feat(M0): Complete setup & infrastructure with TDD
Milestone 0 implementation following strict TDD and NO singleton pattern. Features: - Complete directory structure (src/, tests/, .github/, bin/) - Composer configuration with all dependencies - PHPCS configured for WordPress Coding Standards - PHPUnit configured with coverage support (target: PHP 8.3) - GitHub Actions CI workflow (PHPCS + PHPUnit matrix PHP 7.4-8.5) Core Classes (TDD): - Container: Lightweight DI with share() method (NO singleton pattern) - Plugin: Main orchestrator with constructor injection (NO static methods) - Activator: Activation/deactivation handler (NO final modifier) Pattern Enforcement: ✅ NO singleton pattern - uses shared instances via Container ✅ NO static methods/properties - pure dependency injection ✅ NO final classes/methods - ensures testability ✅ All tests GREEN with TDD workflow (RED → GREEN → REFACTOR) Files Changed: - Added plugin header file (ops-health-dashboard.php) - Added bootstrap configuration (config/bootstrap.php) - Added core classes (src/Core/*) - Added comprehensive unit tests (tests/Unit/Core/*) - Added CI/CD configuration (.github/workflows/ci.yml) - Updated .gitignore for vendor/ and coverage/ Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 706eafa commit 1b0944c

18 files changed

Lines changed: 1351 additions & 1 deletion

.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# EditorConfig for WordPress Plugin Development
2+
# https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
indent_style = tab
12+
indent_size = 4
13+
14+
[*.{json,yml,yaml}]
15+
indent_style = space
16+
indent_size = 2
17+
18+
[*.md]
19+
trim_trailing_whitespace = false
20+
21+
[composer.json]
22+
indent_style = space
23+
indent_size = 2
24+
25+
[package.json]
26+
indent_style = space
27+
indent_size = 2

.github/workflows/ci.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main, dev ]
8+
9+
jobs:
10+
phpcs:
11+
name: PHPCS (WordPress Coding Standards)
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.3'
22+
tools: composer
23+
coverage: none
24+
25+
- name: Get Composer cache directory
26+
id: composer-cache
27+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
28+
29+
- name: Cache Composer dependencies
30+
uses: actions/cache@v4
31+
with:
32+
path: ${{ steps.composer-cache.outputs.dir }}
33+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
34+
restore-keys: ${{ runner.os }}-composer-
35+
36+
- name: Install dependencies
37+
run: composer install --prefer-dist --no-progress --no-suggest
38+
39+
- name: Run PHPCS
40+
run: composer run-script phpcs
41+
42+
phpunit:
43+
name: PHPUnit (PHP ${{ matrix.php }})
44+
runs-on: ubuntu-latest
45+
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
50+
51+
services:
52+
mysql:
53+
image: mysql:5.7
54+
env:
55+
MYSQL_ROOT_PASSWORD: root
56+
MYSQL_DATABASE: wordpress_test
57+
ports:
58+
- 3306:3306
59+
options: >-
60+
--health-cmd="mysqladmin ping"
61+
--health-interval=10s
62+
--health-timeout=5s
63+
--health-retries=3
64+
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
69+
- name: Setup PHP
70+
uses: shivammathur/setup-php@v2
71+
with:
72+
php-version: ${{ matrix.php }}
73+
extensions: mysqli, zip
74+
coverage: ${{ matrix.php == '8.3' && 'xdebug' || 'none' }}
75+
tools: composer
76+
77+
- name: Get Composer cache directory
78+
id: composer-cache
79+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
80+
81+
- name: Cache Composer dependencies
82+
uses: actions/cache@v4
83+
with:
84+
path: ${{ steps.composer-cache.outputs.dir }}
85+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
86+
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-
87+
88+
- name: Install dependencies
89+
run: composer install --prefer-dist --no-progress --no-suggest
90+
91+
- name: Install WordPress test suite
92+
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest
93+
94+
- name: Run tests (without coverage)
95+
if: matrix.php != '8.3'
96+
run: composer run-script test
97+
98+
- name: Run tests (with coverage on PHP 8.3)
99+
if: matrix.php == '8.3'
100+
run: composer run-script test:coverage
101+
102+
- name: Upload coverage to Codecov
103+
if: matrix.php == '8.3'
104+
uses: codecov/codecov-action@v4
105+
with:
106+
files: ./coverage/clover.xml
107+
flags: unittests
108+
name: php-8.3
109+
fail_ci_if_error: false

.gitignore

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,21 @@ wp-config.php
4545
#
4646
# Note: If you wish to whitelist themes,
4747
# uncomment the next line
48-
#/wp-content/themes
48+
#/wp-content/themes
49+
# Plugin specific
50+
/vendor/
51+
/node_modules/
52+
composer.phar
53+
composer.lock
54+
55+
# Testing
56+
/coverage/
57+
/.phpunit.cache/
58+
/phpunit.xml
59+
60+
# IDE
61+
.idea/
62+
.vscode/
63+
*.swp
64+
*.swo
65+
*~

.phpcs.xml.dist

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Ops Health Dashboard">
3+
<description>WordPress Coding Standards for Ops Health Dashboard</description>
4+
5+
<!-- Check all PHP files in directory tree by default. -->
6+
<arg name="extensions" value="php"/>
7+
<file>.</file>
8+
9+
<!-- Show progress and sniff codes in all reports -->
10+
<arg value="ps"/>
11+
12+
<!-- Show colors in output -->
13+
<arg name="colors"/>
14+
15+
<!-- Exclude paths -->
16+
<exclude-pattern>*/vendor/*</exclude-pattern>
17+
<exclude-pattern>*/node_modules/*</exclude-pattern>
18+
<exclude-pattern>*/tests/*</exclude-pattern>
19+
<exclude-pattern>*/bin/*</exclude-pattern>
20+
21+
<!-- Use WordPress Coding Standards -->
22+
<rule ref="WordPress">
23+
<!-- Allow short array syntax -->
24+
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
25+
26+
<!-- Allow short ternary operators -->
27+
<exclude name="WordPress.PHP.DisallowShortTernary"/>
28+
</rule>
29+
30+
<!-- Use WordPress-Extra for additional checks -->
31+
<rule ref="WordPress-Extra">
32+
<!-- Exclude translation text domain check for now -->
33+
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/>
34+
</rule>
35+
36+
<!-- Use WordPress-Docs for documentation standards -->
37+
<rule ref="WordPress-Docs"/>
38+
39+
<!-- Enforce short array syntax [] instead of array() -->
40+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
41+
42+
<!-- Check for PHP cross-version compatibility -->
43+
<config name="testVersion" value="7.4-"/>
44+
<rule ref="PHPCompatibilityWP"/>
45+
46+
<!-- Verify text domain -->
47+
<rule ref="WordPress.WP.I18n">
48+
<properties>
49+
<property name="text_domain" type="array">
50+
<element value="ops-health-dashboard"/>
51+
</property>
52+
</properties>
53+
</rule>
54+
55+
<!-- Naming conventions -->
56+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
57+
<properties>
58+
<property name="prefixes" type="array">
59+
<element value="ops_health"/>
60+
<element value="OpsHealthDashboard"/>
61+
</property>
62+
</properties>
63+
</rule>
64+
65+
<!-- Allow PSR-4 autoloading standard -->
66+
<rule ref="WordPress.Files.FileName">
67+
<properties>
68+
<property name="strict_class_file_names" value="false"/>
69+
</properties>
70+
</rule>
71+
72+
<!-- Line length -->
73+
<rule ref="Generic.Files.LineLength">
74+
<properties>
75+
<property name="lineLimit" value="120"/>
76+
<property name="absoluteLineLimit" value="150"/>
77+
</properties>
78+
</rule>
79+
</ruleset>

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Initial plugin scaffolding
12+
- Core dependency injection container (NO singleton pattern)
13+
- Main plugin orchestrator with constructor injection
14+
- Activation/deactivation handler
15+
- Complete test suite with TDD approach
16+
- GitHub Actions CI workflow (PHPCS + PHPUnit matrix)
17+
- WordPress Coding Standards configuration
18+
- PHPUnit configuration with coverage support
19+
20+
### Development Notes
21+
- **M0 Completed**: Setup & Infrastruttura ✅
22+
- All core classes follow NO singleton, NO static, NO final pattern
23+
- TDD workflow enforced: RED → GREEN → REFACTOR
24+
- Coverage target: PHP 8.3
25+
26+
## [1.0.0] - TBD
27+
28+
Initial release.
29+
30+
[Unreleased]: https://github.com/ops-team/ops-health-dashboard/compare/v1.0.0...HEAD
31+
[1.0.0]: https://github.com/ops-team/ops-health-dashboard/releases/tag/v1.0.0

DEVELOPMENT_PLAN.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Development Plan - Ops Health Dashboard
2+
3+
**Current Milestone**: M0 - Setup & Infrastruttura
4+
**Started**: 2026-02-08
5+
**Status**: 🚧 In Progress
6+
7+
---
8+
9+
## Milestone 0: Setup & Infrastruttura ✅ 8/8
10+
11+
**Obiettivo**: Scaffolding completo con CI verde
12+
13+
### Tasks
14+
15+
- [x] **M0.1** - Struttura directory completa
16+
- [x] **M0.2** - Setup composer.json con dipendenze
17+
- [x] **M0.3** - Configurazione PHPCS (WPCS)
18+
- [x] **M0.4** - Setup PHPUnit (config + bootstrap)
19+
- [x] **M0.5** - GitHub Actions workflows
20+
- [x] **M0.6** - File bootstrap (main plugin + config)
21+
- [x] **M0.7** - Core classes (Container, Plugin, Activator) - TDD
22+
- [x] **M0.8** - Script bin/install-wp-tests.sh
23+
24+
**Pattern Enforcement**:
25+
- ✅ Container usa `share()` per shared instances, NON `singleton()`
26+
- ✅ Plugin riceve Container via constructor, NO `get_instance()`
27+
- ✅ Bootstrap function crea e configura, NO static factories
28+
- ✅ Nessuna classe final, nessun metodo final
29+
30+
**Deliverable**: CI verde con PHPCS + PHPUnit matrix + coverage 8.3
31+
32+
---
33+
34+
## Progress Log
35+
36+
### 2026-02-08
37+
38+
**Completed M0**: Setup & Infrastruttura ✅
39+
- Created complete directory structure
40+
- Setup composer.json with all dependencies (PHPUnit, WPCS, Brain\Monkey, etc.)
41+
- Configured PHPCS for WordPress Coding Standards
42+
- Setup PHPUnit configuration with coverage support
43+
- Created GitHub Actions CI workflow (PHPCS + PHPUnit matrix PHP 7.4-8.5)
44+
- Implemented core classes with TDD:
45+
- `Container` class - DI container with NO singleton pattern
46+
- `Plugin` class - Main orchestrator with constructor injection
47+
- `Activator` class - Activation/deactivation handler
48+
- Created main plugin file and bootstrap function
49+
- All tests: ✅ GREEN
50+
- Pattern enforcement: ✅ NO singleton, NO static, NO final
51+
52+
---
53+
54+
## Next Milestones (Preview)
55+
56+
- **M1**: Core Checks + Storage + Cron
57+
- **M2**: Error Log Summary Safe
58+
- **M3**: Redis Check
59+
- **M4**: Alerting System
60+
- **M5**: E2E Testing
61+
- **M6**: WordPress.org Readiness

0 commit comments

Comments
 (0)