|
| 1 | +# GitHub Actions Workflows |
| 2 | + |
| 3 | +This directory contains comprehensive GitHub Actions workflows for the Magento 2 Prometheus Exporter project. These workflows ensure code quality, automate releases, and maintain project health. |
| 4 | + |
| 5 | +## 🔄 Workflows Overview |
| 6 | + |
| 7 | +### 1. CI (Continuous Integration) - `ci.yml` |
| 8 | + |
| 9 | +**Trigger**: Push/PR to `master` or `develop` branches |
| 10 | + |
| 11 | +**Purpose**: Core testing and quality assurance pipeline |
| 12 | + |
| 13 | +**Jobs**: |
| 14 | +- **PHP CS Fixer**: Code style validation and automatic fixing |
| 15 | +- **PHPStan**: Static analysis for type safety and code quality |
| 16 | +- **Unit Tests**: Runs across PHP 7.4, 8.0, 8.1, 8.2 with coverage reporting |
| 17 | +- **Integration Tests**: Tests against Magento 2.4.5 and 2.4.6 |
| 18 | +- **Compatibility Check**: Validates Magento coding standards and PHP compatibility |
| 19 | +- **Security Check**: Scans for security vulnerabilities |
| 20 | +- **Composer Validation**: Ensures composer.json integrity |
| 21 | + |
| 22 | +### 2. Release - `release.yml` |
| 23 | + |
| 24 | +**Trigger**: Git tags (`v*.*.*`) or manual dispatch |
| 25 | + |
| 26 | +**Purpose**: Automated release management and distribution |
| 27 | + |
| 28 | +**Jobs**: |
| 29 | +- **Validate Release**: Checks version format and changelog consistency |
| 30 | +- **Run Tests**: Final test suite before release |
| 31 | +- **Create Release**: Generates GitHub release with archives |
| 32 | +- **Update Packagist**: Notifies Packagist of new version |
| 33 | +- **Post Release**: Updates development branch versions |
| 34 | + |
| 35 | +### 3. Code Quality - `code-quality.yml` |
| 36 | + |
| 37 | +**Trigger**: Push/PR to main branches, weekly schedule |
| 38 | + |
| 39 | +**Purpose**: Comprehensive code quality analysis |
| 40 | + |
| 41 | +**Jobs**: |
| 42 | +- **PHP CS Fixer**: Advanced code style enforcement |
| 43 | +- **PHPStan**: Deep static analysis |
| 44 | +- **Psalm**: Additional static analysis tool |
| 45 | +- **Magento Coding Standard**: Magento-specific code standards |
| 46 | +- **PHP Compatibility**: Multi-version PHP compatibility check |
| 47 | +- **PHPMD**: Mess detection for code smells |
| 48 | +- **PHPCPD**: Copy/paste detection |
| 49 | +- **Security Checker**: Vulnerability scanning |
| 50 | +- **Dependency Check**: Unused dependency detection |
| 51 | +- **Code Metrics**: Lines of code analysis |
| 52 | + |
| 53 | +### 4. Dependency Update - `dependency-update.yml` |
| 54 | + |
| 55 | +**Trigger**: Weekly schedule (Mondays 9 AM UTC) or manual |
| 56 | + |
| 57 | +**Purpose**: Automated dependency management and security monitoring |
| 58 | + |
| 59 | +**Jobs**: |
| 60 | +- **Update Dependencies**: Creates PRs for patch/minor updates |
| 61 | +- **Security Audit**: Scans for security vulnerabilities |
| 62 | +- **Composer Audit**: Official Composer security advisories |
| 63 | +- **Outdated Check**: Reports on outdated packages |
| 64 | +- **Cleanup**: Removes old dependency update PRs |
| 65 | + |
| 66 | +### 5. Documentation - `docs.yml` |
| 67 | + |
| 68 | +**Trigger**: Changes to docs, README, or source code |
| 69 | + |
| 70 | +**Purpose**: Documentation validation and generation |
| 71 | + |
| 72 | +**Jobs**: |
| 73 | +- **Validate Docs**: Markdown linting and link checking |
| 74 | +- **Generate API Docs**: Creates PHPDoc documentation |
| 75 | +- **Check Changelog**: Ensures changelog updates in PRs |
| 76 | +- **Validate Changelog**: Checks changelog format |
| 77 | +- **Spell Check**: Spell checking with custom dictionary |
| 78 | +- **Update Docs**: Auto-generates metrics and config documentation |
| 79 | +- **Deploy Docs**: Publishes to GitHub Pages |
| 80 | + |
| 81 | +### 6. Performance Monitoring - `performance.yml` |
| 82 | + |
| 83 | +**Trigger**: Push/PR to main branches, weekly schedule |
| 84 | + |
| 85 | +**Purpose**: Performance testing and monitoring |
| 86 | + |
| 87 | +**Jobs**: |
| 88 | +- **Performance Baseline**: Measures core performance metrics |
| 89 | +- **Performance Comparison**: Compares PR performance vs base branch |
| 90 | +- **Load Testing**: High-load scenario testing with k6 |
| 91 | + |
| 92 | +## 🛠️ Configuration |
| 93 | + |
| 94 | +### Required Secrets |
| 95 | + |
| 96 | +Add these secrets in your GitHub repository settings: |
| 97 | + |
| 98 | +- `GITHUB_TOKEN`: Automatically provided by GitHub |
| 99 | +- `PACKAGIST_TOKEN`: For automated Packagist updates (optional) |
| 100 | + |
| 101 | +### Required Permissions |
| 102 | + |
| 103 | +Ensure the following permissions are enabled for GitHub Actions: |
| 104 | + |
| 105 | +- **Contents**: Read/Write (for creating releases and updating docs) |
| 106 | +- **Issues**: Write (for creating security issue reports) |
| 107 | +- **Pull Requests**: Write (for dependency update PRs) |
| 108 | +- **Pages**: Write (for documentation deployment) |
| 109 | + |
| 110 | +## 📊 Workflow Features |
| 111 | + |
| 112 | +### Automated Features |
| 113 | + |
| 114 | +- ✅ **Code Style**: Automatic code formatting on develop branch |
| 115 | +- 🔄 **Dependency Updates**: Weekly automated dependency PRs |
| 116 | +- 📚 **Documentation**: Auto-generated API docs and metrics lists |
| 117 | +- 🏷️ **Releases**: Fully automated release process with archives |
| 118 | +- 🔍 **Security**: Continuous vulnerability monitoring |
| 119 | +- 📈 **Performance**: Regular performance regression testing |
| 120 | + |
| 121 | +### Quality Gates |
| 122 | + |
| 123 | +- **Unit Tests**: Must pass across all PHP versions |
| 124 | +- **Integration Tests**: Must pass against supported Magento versions |
| 125 | +- **Security**: No critical vulnerabilities allowed |
| 126 | +- **Code Style**: Must follow PSR-12 and Magento standards |
| 127 | +- **Static Analysis**: PHPStan level 5 compliance required |
| 128 | + |
| 129 | +### Reporting |
| 130 | + |
| 131 | +All workflows generate detailed reports in the GitHub Actions summary, including: |
| 132 | + |
| 133 | +- Test coverage metrics |
| 134 | +- Performance benchmarks |
| 135 | +- Security scan results |
| 136 | +- Code quality scores |
| 137 | +- Dependency status |
| 138 | + |
| 139 | +## 🚀 Getting Started |
| 140 | + |
| 141 | +1. **Fork/Clone** this repository |
| 142 | +2. **Enable Actions** in your repository settings |
| 143 | +3. **Add Secrets** (if needed for Packagist integration) |
| 144 | +4. **Push Changes** to trigger the workflows |
| 145 | + |
| 146 | +## 📋 Workflow Status |
| 147 | + |
| 148 | +You can monitor workflow status through: |
| 149 | + |
| 150 | +- **GitHub Actions Tab**: Real-time workflow execution |
| 151 | +- **README Badges**: Add status badges to your README |
| 152 | +- **Branch Protection**: Configure required status checks |
| 153 | + |
| 154 | +### Example Badges |
| 155 | + |
| 156 | +Add these to your README.md: |
| 157 | + |
| 158 | +```markdown |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | +``` |
| 163 | + |
| 164 | +## 🔧 Customization |
| 165 | + |
| 166 | +### Modifying Workflows |
| 167 | + |
| 168 | +- **PHP Versions**: Update matrix in `ci.yml` and `release.yml` |
| 169 | +- **Magento Versions**: Update matrix in integration test jobs |
| 170 | +- **Schedule**: Modify cron expressions for scheduled workflows |
| 171 | +- **Quality Gates**: Adjust PHPStan levels, coverage thresholds |
| 172 | + |
| 173 | +### Adding Custom Checks |
| 174 | + |
| 175 | +1. Create new jobs in existing workflows |
| 176 | +2. Add custom scripts in `.github/scripts/` |
| 177 | +3. Use marketplace actions for additional functionality |
| 178 | + |
| 179 | +## 🆘 Troubleshooting |
| 180 | + |
| 181 | +### Common Issues |
| 182 | + |
| 183 | +- **Composer Auth**: May need Magento marketplace credentials |
| 184 | +- **Memory Limits**: Increase PHP memory for large projects |
| 185 | +- **Timeouts**: Adjust timeout values for slow operations |
| 186 | +- **Permissions**: Ensure proper GitHub token permissions |
| 187 | + |
| 188 | +### Debug Mode |
| 189 | + |
| 190 | +Enable debug logging by setting repository variable: |
| 191 | +- `ACTIONS_STEP_DEBUG`: `true` |
| 192 | +- `ACTIONS_RUNNER_DEBUG`: `true` |
| 193 | + |
| 194 | +## 🤝 Contributing |
| 195 | + |
| 196 | +When contributing to workflows: |
| 197 | + |
| 198 | +1. Test changes in a fork first |
| 199 | +2. Update documentation for new features |
| 200 | +3. Follow existing naming conventions |
| 201 | +4. Add appropriate error handling |
| 202 | + |
| 203 | +## 📚 Additional Resources |
| 204 | + |
| 205 | +- [GitHub Actions Documentation](https://docs.github.com/en/actions) |
| 206 | +- [Magento DevDocs](https://devdocs.magento.com/) |
| 207 | +- [Prometheus Documentation](https://prometheus.io/docs/) |
| 208 | +- [PHP Testing Best Practices](https://phpunit.de/documentation.html) |
| 209 | + |
| 210 | +--- |
| 211 | + |
| 212 | +*These workflows are designed to be production-ready and can be customized based on your specific requirements.* |
0 commit comments