|
| 1 | +--- |
| 2 | +arguments: <since-date> |
| 3 | +--- |
| 4 | + |
| 5 | +# Weekly PR Report Generator |
| 6 | + |
| 7 | +Generate a comprehensive weekly PR report for openshift/hypershift and openshift-eng/ai-helpers repositories. |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +``` |
| 12 | +/weekly-pr-report [since-date] |
| 13 | +``` |
| 14 | + |
| 15 | +**Parameters:** |
| 16 | + |
| 17 | +- `since-date` (optional): Starting date in YYYY-MM-DD format. Defaults to 7 days ago. |
| 18 | + |
| 19 | +## What This Command Does |
| 20 | + |
| 21 | +1. **Fetch repository contributors** from openshift/hypershift (all 194 contributors) |
| 22 | +2. **Fetch merged PRs** from both repositories since the specified date using GitHub GraphQL API |
| 23 | +3. **Filter openshift/ai-helpers PRs** to only include those authored by HyperShift contributors |
| 24 | +4. **Query Jira** for each ticket to find Epic and Parent links to OCPSTRAT issues |
| 25 | +5. **Gather detailed PR metadata**: |
| 26 | + - Author, reviewers, and approvers |
| 27 | + - Draft status and timeline (when moved from draft to ready) |
| 28 | + - Time from creation to ready |
| 29 | + - Time from ready to merge |
| 30 | +6. **Generate comprehensive report** including: |
| 31 | + - PR topic and summary |
| 32 | + - Jira ticket hierarchy (ticket → Epic → OCPSTRAT) |
| 33 | + - Review and approval activity |
| 34 | + - Timing metrics |
| 35 | + - OCPSTRAT groupings |
| 36 | + - Auto-generated impact statements |
| 37 | + |
| 38 | +## Output |
| 39 | + |
| 40 | +The command creates: |
| 41 | + |
| 42 | +- `/tmp/weekly_pr_report_fast.md` - Comprehensive markdown report |
| 43 | +- `/tmp/hypershift_pr_details_fast.json` - Raw PR data in JSON format |
| 44 | + |
| 45 | +## Example Usage |
| 46 | + |
| 47 | +```bash |
| 48 | +# Report for last week (default) |
| 49 | +/weekly-pr-report |
| 50 | + |
| 51 | +# Report since specific date |
| 52 | +/weekly-pr-report 2025-11-06 |
| 53 | +``` |
| 54 | + |
| 55 | +## Expected Output Format |
| 56 | + |
| 57 | +The generated markdown report (`/tmp/weekly_pr_report_fast.md`) should follow this structure: |
| 58 | + |
| 59 | +```markdown |
| 60 | +# Weekly PR Report: YYYY-MM-DD to YYYY-MM-DD |
| 61 | + |
| 62 | +## Summary |
| 63 | + |
| 64 | +- **Total PRs merged**: X |
| 65 | +- **Total contributors**: Y |
| 66 | +- **Repositories**: openshift/hypershift (X PRs), openshift-eng/ai-helpers (Y PRs) |
| 67 | + |
| 68 | +## PRs by OCPSTRAT Initiative |
| 69 | + |
| 70 | +### OCPSTRAT-XXXX: [OCPSTRAT Summary] |
| 71 | + |
| 72 | +**Related Epics:** |
| 73 | +- EPIC-XXX: [Epic Summary] |
| 74 | + |
| 75 | +#### PR: [PR Title] (#XXXX) |
| 76 | +- **Repository**: openshift/hypershift |
| 77 | +- **Author**: @username |
| 78 | +- **Jira**: TICKET-XXX → EPIC-XXX → OCPSTRAT-XXXX |
| 79 | +- **Merged**: YYYY-MM-DD |
| 80 | +- **Reviewers**: @user1, @user2 |
| 81 | +- **Approvers**: @user3 |
| 82 | +- **Draft Timeline**: |
| 83 | + - Created as draft: YYYY-MM-DD HH:MM |
| 84 | + - Ready for review: YYYY-MM-DD HH:MM |
| 85 | + - Time in draft: X days |
| 86 | +- **Review Timeline**: |
| 87 | + - Time to merge after ready: X days |
| 88 | +- **Topic**: [Auto-generated topic classification] |
| 89 | +- **Summary**: [Brief description of what the PR does] |
| 90 | +- **Impact**: [Generated impact statement using Jira context and OCPSTRAT hierarchy] |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +### Uncategorized PRs (No OCPSTRAT Link) |
| 95 | + |
| 96 | +#### PR: [PR Title] (#XXXX) |
| 97 | +[Same format as above, but without OCPSTRAT hierarchy] |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Metrics |
| 102 | + |
| 103 | +### Time to Merge Distribution |
| 104 | +- **Average time from creation to ready**: X.Y days |
| 105 | +- **Average time from ready to merge**: X.Y days |
| 106 | +- **Fastest PR**: #XXXX (X.Y days) |
| 107 | +- **Slowest PR**: #XXXX (X.Y days) |
| 108 | + |
| 109 | +### Top Contributors |
| 110 | +1. @username - X PRs |
| 111 | +2. @username - Y PRs |
| 112 | + |
| 113 | +### Cross-Repository Contributions |
| 114 | +- Contributors working on both repos: X |
| 115 | +``` |
| 116 | + |
| 117 | +**Key Requirements for Generated Report:** |
| 118 | + |
| 119 | +1. **PRs must be grouped by OCPSTRAT** parent initiative when available |
| 120 | +2. **Complete hierarchy** must be shown: Ticket → Epic → OCPSTRAT |
| 121 | +3. **Draft timeline** must include creation time, ready time, and duration in draft |
| 122 | +4. **Impact statements** should leverage: |
| 123 | + - Ticket summary and description |
| 124 | + - Epic summary for context |
| 125 | + - OCPSTRAT summary for strategic alignment |
| 126 | +5. **Topics** should be auto-classified (e.g., "Bug Fix", "Feature Enhancement", "Test Improvement", "Documentation") |
| 127 | +6. **Metrics section** must include timing analysis and contributor statistics |
| 128 | + |
| 129 | +## Implementation |
| 130 | + |
| 131 | +This command uses an optimized Python script for fast PR fetching, then enriches the data with Jira hierarchy information. |
| 132 | + |
| 133 | +### Step 1: Run the Python script to fetch PRs |
| 134 | + |
| 135 | +Parse the date argument and run the script: |
| 136 | + |
| 137 | +```bash |
| 138 | +SINCE_DATE="$ARGUMENTS" |
| 139 | +if [ -z "$SINCE_DATE" ]; then |
| 140 | + SINCE_DATE=$(date -d '7 days ago' +%Y-%m-%d) |
| 141 | +fi |
| 142 | + |
| 143 | +echo "Generating PR report since: $SINCE_DATE" |
| 144 | +python3 contrib/repo_metrics/weekly_pr_report.py "$SINCE_DATE" |
| 145 | +``` |
| 146 | + |
| 147 | +### Step 2: Query Jira for ticket hierarchy (in parallel) |
| 148 | + |
| 149 | +Extract all unique Jira ticket IDs from the generated PR data and query Jira for each ticket to build hierarchy and enhance impact statements. |
| 150 | + |
| 151 | +First, extract the unique tickets: |
| 152 | + |
| 153 | +```bash |
| 154 | +TICKETS=$(jq -r '.[].jiraTickets[]' /tmp/hypershift_pr_details_fast.json | sort -u) |
| 155 | +echo "Found tickets: $TICKETS" |
| 156 | +``` |
| 157 | + |
| 158 | +Now, for EACH ticket in the list, use `mcp__atlassian-mcp__jira_get_issue` to fetch: |
| 159 | + |
| 160 | +**Fields to request:** `summary,description,parent,customfield_12311140,customfield_12313140,issuelinks,labels,priority,status` |
| 161 | + |
| 162 | +**Key custom fields:** |
| 163 | +- `customfield_12311140` = Epic Link field |
| 164 | +- `customfield_12313140` = OCPSTRAT Parent (simple string like "OCPSTRAT-2426") |
| 165 | + |
| 166 | +**Build the hierarchy for each ticket:** |
| 167 | + |
| 168 | +1. Query the ticket itself to get summary, description, Epic Link |
| 169 | +2. If Epic Link exists (customfield_12311140), query that Epic ticket to get its summary and OCPSTRAT parent |
| 170 | +3. Build a JSON structure like: |
| 171 | +```json |
| 172 | +{ |
| 173 | + "TICKET-123": { |
| 174 | + "summary": "Ticket summary text", |
| 175 | + "description": "Full ticket description", |
| 176 | + "epic": "EPIC-456", |
| 177 | + "epicSummary": "Epic summary text", |
| 178 | + "ocpstrat": "OCPSTRAT-789", |
| 179 | + "ocpstratSummary": "OCPSTRAT summary text" |
| 180 | + } |
| 181 | +} |
| 182 | +``` |
| 183 | + |
| 184 | +4. Save ALL ticket hierarchies to `/tmp/jira_hierarchy.json` |
| 185 | + |
| 186 | +**IMPORTANT:** Query all Epics and tickets in PARALLEL using multiple concurrent `mcp__atlassian-mcp__jira_get_issue` calls for maximum performance. |
| 187 | + |
| 188 | +### Step 3: Regenerate report with Jira enrichment |
| 189 | + |
| 190 | +Once Jira hierarchy is saved, re-run the Python script to regenerate the report with enriched impact statements: |
| 191 | + |
| 192 | +```bash |
| 193 | +python3 contrib/repo_metrics/weekly_pr_report.py "$SINCE_DATE" |
| 194 | +``` |
| 195 | + |
| 196 | +The script will now use the Jira data to: |
| 197 | +- Show complete ticket → Epic → OCPSTRAT hierarchy |
| 198 | +- Generate better impact statements using ticket summaries and OCPSTRAT context |
| 199 | +- Group PRs by their OCPSTRAT parent initiatives |
| 200 | + |
| 201 | +## Script Features |
| 202 | + |
| 203 | +The Python script uses: |
| 204 | +- **GitHub Contributors API** to fetch all 194 HyperShift contributors |
| 205 | +- **GitHub GraphQL API** with search queries for efficient PR fetching (`merged:>=$DATE`) |
| 206 | +- **Parallel async API calls** with aiohttp for maximum performance |
| 207 | +- **Jira hierarchy caching** (loads from previous run if available) |
| 208 | + |
| 209 | +## Notes |
| 210 | + |
| 211 | +- Requires `aiohttp` Python package: `pip install aiohttp` |
| 212 | +- Falls back to synchronous mode if aiohttp is not available (slower but functional) |
| 213 | +- Jira hierarchy is loaded from cache (`/tmp/jira_hierarchy.json`) if available |
| 214 | +- For full Jira integration, ensure Jira MCP tools are configured |
0 commit comments