|
| 1 | +# GitHub Automation Rules Documentation |
| 2 | + |
| 3 | +This document describes all the automated workflows and rules configured for this repository. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +1. [Code Review Automation](#code-review-automation) |
| 8 | +2. [Issue Management](#issue-management) |
| 9 | +3. [Pull Request Management](#pull-request-management) |
| 10 | +4. [Security & Dependencies](#security--dependencies) |
| 11 | +5. [Quality Checks](#quality-checks) |
| 12 | +6. [Release Management](#release-management) |
| 13 | +7. [Performance Monitoring](#performance-monitoring) |
| 14 | + |
| 15 | +## Code Review Automation |
| 16 | + |
| 17 | +### Auto-Assign (`.github/workflows/auto-assign.yml`) |
| 18 | +- **Trigger**: Issues and PRs opened |
| 19 | +- **Actions**: Automatically assigns issues and PRs based on file paths changed |
| 20 | +- **Assignment Logic**: |
| 21 | + - `.github/` changes → repository owner |
| 22 | + - `web/` or `webui/` changes → frontend team |
| 23 | + - `.py` files → backend team |
| 24 | + - `docs/` changes → documentation team |
| 25 | + |
| 26 | +### Auto-Review Bot (`.github/workflows/auto-review.yml`) |
| 27 | +- **Trigger**: PR opened, synchronized, or reopened |
| 28 | +- **Actions**: |
| 29 | + - Checks if tests are included with code changes |
| 30 | + - Checks if documentation is updated |
| 31 | + - Auto-approves documentation-only PRs |
| 32 | + - Flags dependency updates |
| 33 | + - Adds appropriate labels |
| 34 | + |
| 35 | +### Review Reminder (`.github/workflows/review-reminder.yml`) |
| 36 | +- **Trigger**: Scheduled (weekdays at 9 AM) |
| 37 | +- **Actions**: |
| 38 | + - Reminds reviewers of pending PRs |
| 39 | + - Notifies when PRs have been waiting for >2 days |
| 40 | + - Alerts when changes have been made after review requests |
| 41 | + |
| 42 | +### CODEOWNERS (`.github/CODEOWNERS`) |
| 43 | +- **Purpose**: Automatic reviewer assignment based on file ownership |
| 44 | +- **Owners**: Defined per directory and file type |
| 45 | + |
| 46 | +## Issue Management |
| 47 | + |
| 48 | +### Auto-Issue Creator (`.github/workflows/auto-issue-creator.yml`) |
| 49 | +- **Triggers**: Workflow failures, PR comments with "gh create issue", scheduled scans |
| 50 | +- **Actions**: |
| 51 | + - Creates issues for workflow failures |
| 52 | + - Creates issues from PR comments |
| 53 | + - Scans repository for outstanding errors |
| 54 | + - Detects code quality issues |
| 55 | + |
| 56 | +### Auto-Issue Triage (`.github/workflows/auto-issue-triage.yml`) |
| 57 | +- **Trigger**: CI workflow completion |
| 58 | +- **Actions**: Creates issue when CI fails |
| 59 | + |
| 60 | +### Duplicate Issue Detection (`.github/workflows/duplicate-issue-detection.yml`) |
| 61 | +- **Trigger**: New issue opened |
| 62 | +- **Actions**: |
| 63 | + - Scans for similar existing issues (>70% title similarity or >80% body similarity) |
| 64 | + - Comments with potential duplicates |
| 65 | + - Adds 'potential-duplicate' label |
| 66 | + |
| 67 | +### First-Time Contributor Greeting (`.github/workflows/greet-first-time.yml`) |
| 68 | +- **Trigger**: Issue or PR opened |
| 69 | +- **Actions**: |
| 70 | + - Welcomes first-time contributors |
| 71 | + - Provides helpful information and guidelines |
| 72 | + - Adds 'first-time-contributor' label to PRs |
| 73 | + |
| 74 | +### Project Board Automation (`.github/workflows/project-board-automation.yml`) |
| 75 | +- **Trigger**: Issues/PRs opened, closed, labeled |
| 76 | +- **Actions**: |
| 77 | + - Auto-adds items to project boards |
| 78 | + - Updates status labels based on state |
| 79 | + - Manages priority labels |
| 80 | + |
| 81 | +### Stale Issues/PRs (`.github/workflows/stale.yml`) |
| 82 | +- **Trigger**: Scheduled (daily) |
| 83 | +- **Actions**: Marks inactive issues and PRs as stale |
| 84 | + |
| 85 | +### Auto-Close Inactive PRs (`.github/workflows/auto-close-inactive.yml`) |
| 86 | +- **Trigger**: Scheduled (weekly on Sunday) |
| 87 | +- **Actions**: |
| 88 | + - Marks PRs as stale after 30 days of inactivity |
| 89 | + - Closes PRs after 60 days of inactivity |
| 90 | + - Skips PRs with 'keep-open' label |
| 91 | + |
| 92 | +## Pull Request Management |
| 93 | + |
| 94 | +### PR Labeler (`.github/workflows/pr-labeler.yml`) |
| 95 | +- **Trigger**: PR opened, synchronized, or reopened |
| 96 | +- **Actions**: |
| 97 | + - Labels PRs based on changed files (uses `.github/labeler.yml`) |
| 98 | + - Adds size labels (XS, S, M, L, XL) based on lines changed |
| 99 | + - Adds 'work-in-progress' label for draft PRs or WIP in title |
| 100 | + - Adds 'breaking-change' label when detected |
| 101 | + |
| 102 | +### Labeler (`.github/workflows/label.yml`) |
| 103 | +- **Trigger**: PR opened |
| 104 | +- **Actions**: Applies labels based on file paths using `.github/labeler.yml` configuration |
| 105 | + |
| 106 | +### Branch Protection Enforcement (`.github/workflows/branch-protection.yml`) |
| 107 | +- **Trigger**: PR opened, synchronized, reopened, edited |
| 108 | +- **Actions**: |
| 109 | + - Checks PR title format (conventional commits) |
| 110 | + - Ensures PR has meaningful description |
| 111 | + - Encourages linking related issues |
| 112 | + - Adds reminder labels |
| 113 | + |
| 114 | +### Commit Message Linter (`.github/workflows/commit-lint.yml`) |
| 115 | +- **Trigger**: PR opened, synchronized, reopened |
| 116 | +- **Actions**: |
| 117 | + - Validates commit messages follow Conventional Commits spec |
| 118 | + - Comments with format guidance |
| 119 | + - Adds 'needs-better-commits' label if invalid |
| 120 | + |
| 121 | +### PR Template (`.github/pull_request_template.md`) |
| 122 | +- **Purpose**: Standard PR template with checklist |
| 123 | +- **Sections**: Description, type, changes, testing, documentation, checklist |
| 124 | + |
| 125 | +## Security & Dependencies |
| 126 | + |
| 127 | +### Dependabot (`.github/dependabot.yml`) |
| 128 | +- **Schedule**: Weekly on Mondays at 9 AM |
| 129 | +- **Ecosystems**: |
| 130 | + - Python (pip) |
| 131 | + - npm (root and /web) |
| 132 | + - GitHub Actions |
| 133 | + - Docker |
| 134 | +- **Actions**: Creates PRs for dependency updates |
| 135 | + |
| 136 | +### Auto-Merge Dependabot (`.github/workflows/auto-merge-dependabot.yml`) |
| 137 | +- **Trigger**: Dependabot PR opened/updated |
| 138 | +- **Actions**: |
| 139 | + - Auto-merges patch and minor updates after CI passes |
| 140 | + - Comments on major updates for manual review |
| 141 | + |
| 142 | +### Security Scanner (`.github/workflows/security-scanner.yml`) |
| 143 | +- **Trigger**: Scheduled (daily at 2 AM), PR to main/develop |
| 144 | +- **Actions**: |
| 145 | + - Runs safety and pip-audit for Python |
| 146 | + - Runs npm audit for JavaScript |
| 147 | + - Creates issues for discovered vulnerabilities |
| 148 | + - Uploads security reports as artifacts |
| 149 | + |
| 150 | +### Auto-Update Dependencies (`.github/workflows/auto-update-deps.yml`) |
| 151 | +- **Trigger**: Scheduled (weekly on Monday) |
| 152 | +- **Actions**: |
| 153 | + - Updates Python dependencies with pip-compile |
| 154 | + - Updates npm dependencies with npm-check-updates |
| 155 | + - Creates PRs for updates |
| 156 | + |
| 157 | +### CodeQL (`.github/workflows/codeql.yml`) |
| 158 | +- **Trigger**: Push, PR, scheduled |
| 159 | +- **Actions**: Advanced code scanning for security vulnerabilities |
| 160 | + |
| 161 | +## Quality Checks |
| 162 | + |
| 163 | +### Comprehensive CI (`.github/workflows/comprehensive-ci.yml`) |
| 164 | +- **Trigger**: Push to main/develop, PRs |
| 165 | +- **Jobs**: |
| 166 | + - Python tests with coverage |
| 167 | + - Frontend tests |
| 168 | + - API tests |
| 169 | + - Security scans |
| 170 | + - Markdown linting |
| 171 | + - Docker build tests |
| 172 | + |
| 173 | +### CI (`.github/workflows/ci.yml`) |
| 174 | +- **Trigger**: Push, PR |
| 175 | +- **Actions**: Runs basic lint and test suite |
| 176 | + |
| 177 | +### Documentation CI (`.github/workflows/documentation-ci.yml`) |
| 178 | +- **Trigger**: Changes to documentation |
| 179 | +- **Actions**: Validates documentation builds correctly |
| 180 | + |
| 181 | +## Release Management |
| 182 | + |
| 183 | +### Release Automation (`.github/workflows/release-automation.yml`) |
| 184 | +- **Trigger**: Version tags pushed (v*.*.*) |
| 185 | +- **Actions**: |
| 186 | + - Auto-generates changelog from commits |
| 187 | + - Categorizes changes (features, fixes, breaking, chores) |
| 188 | + - Creates GitHub release |
| 189 | + - Marks pre-releases (alpha, beta, rc) |
| 190 | + |
| 191 | +## Performance Monitoring |
| 192 | + |
| 193 | +### Performance Monitoring (`.github/workflows/performance-monitoring.yml`) |
| 194 | +- **Trigger**: PR opened/synchronized, push to main/develop |
| 195 | +- **Actions**: |
| 196 | + - Checks frontend bundle size |
| 197 | + - Profiles Python import times |
| 198 | + - Comments on PRs with performance metrics |
| 199 | + - Flags slow imports (>100ms) |
| 200 | + |
| 201 | +## Issue Templates |
| 202 | + |
| 203 | +### Bug Report (`.github/ISSUE_TEMPLATE/bug_report.md`) |
| 204 | +Standard bug report template with environment details |
| 205 | + |
| 206 | +### Feature Request (`.github/ISSUE_TEMPLATE/feature_request.md`) |
| 207 | +Standard feature request template |
| 208 | + |
| 209 | +### Security Vulnerability (`.github/ISSUE_TEMPLATE/security_vulnerability.md`) |
| 210 | +Security issue template with severity levels |
| 211 | + |
| 212 | +### Performance Issue (`.github/ISSUE_TEMPLATE/performance_issue.md`) |
| 213 | +Performance problem template with metrics |
| 214 | + |
| 215 | +### Custom Template (`.github/ISSUE_TEMPLATE/custom.md`) |
| 216 | +Blank template for other issues |
| 217 | + |
| 218 | +## Configuration Files |
| 219 | + |
| 220 | +### Labeler Configuration (`.github/labeler.yml`) |
| 221 | +Defines path-based label mappings for PRs: |
| 222 | +- `ingestion` - opendiscourse/ingestion/** |
| 223 | +- `documentation` - *.md, docs/** |
| 224 | +- `tests` - tests/** |
| 225 | +- `database` - *.sql, src/database/** |
| 226 | +- `scripts` - scripts/** |
| 227 | +- `dependencies` - requirements/**, pyproject.toml, setup.py |
| 228 | +- `github-actions` - .github/** |
| 229 | + |
| 230 | +## Best Practices |
| 231 | + |
| 232 | +### For Contributors |
| 233 | + |
| 234 | +1. **Write Good Commit Messages**: Follow Conventional Commits format |
| 235 | +2. **Link Issues**: Use "Closes #123" in PR descriptions |
| 236 | +3. **Add Tests**: Include tests with code changes |
| 237 | +4. **Update Docs**: Keep documentation current |
| 238 | +5. **Small PRs**: Break large changes into smaller PRs |
| 239 | +6. **Respond to Automation**: Address bot comments and suggestions |
| 240 | + |
| 241 | +### For Maintainers |
| 242 | + |
| 243 | +1. **Review Bot Comments**: Bot insights can help with review |
| 244 | +2. **Use Labels**: Labels help track and organize work |
| 245 | +3. **Keep Dependencies Updated**: Regularly review Dependabot PRs |
| 246 | +4. **Monitor Security**: Address security issues promptly |
| 247 | +5. **Maintain Templates**: Keep issue/PR templates up to date |
| 248 | + |
| 249 | +## Troubleshooting |
| 250 | + |
| 251 | +### Workflow Failures |
| 252 | + |
| 253 | +If a workflow fails: |
| 254 | +1. Check the Actions tab for error details |
| 255 | +2. Review the auto-created issue (if one was created) |
| 256 | +3. Fix the underlying problem |
| 257 | +4. Re-run the workflow if needed |
| 258 | + |
| 259 | +### False Positives |
| 260 | + |
| 261 | +If automation creates incorrect labels or comments: |
| 262 | +1. Manually remove/correct the label |
| 263 | +2. Consider adjusting the workflow configuration |
| 264 | +3. Report persistent issues to maintainers |
| 265 | + |
| 266 | +### Disabling Automation |
| 267 | + |
| 268 | +To temporarily disable automation on a PR: |
| 269 | +- Add the `skip-automation` label (if needed, create this label) |
| 270 | +- For keeping PRs open indefinitely, add `keep-open` label |
| 271 | + |
| 272 | +## Contributing to Automation |
| 273 | + |
| 274 | +To improve or add automation: |
| 275 | +1. Propose changes in an issue first |
| 276 | +2. Test workflows thoroughly |
| 277 | +3. Document any new automation |
| 278 | +4. Update this document with changes |
| 279 | +5. Consider backward compatibility |
| 280 | + |
| 281 | +## Resources |
| 282 | + |
| 283 | +- [GitHub Actions Documentation](https://docs.github.com/en/actions) |
| 284 | +- [Conventional Commits](https://www.conventionalcommits.org/) |
| 285 | +- [Dependabot Configuration](https://docs.github.com/en/code-security/dependabot) |
| 286 | +- [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) |
0 commit comments