Skip to content

Commit f7870dd

Browse files
authored
Merge pull request #3 from Oltrematica/002-jira-integration
feat(jira): complete Jira integration with multi-source support
2 parents 3a5898f + 3b3010c commit f7870dd

43 files changed

Lines changed: 8354 additions & 45 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Auto-generated from all feature plans. Last updated: 2025-11-28
44

55
## Active Technologies
6+
- Python 3.9+ (per constitution, leveraging type hints) + Standard library (urllib, json, csv, os, re); optional: requests (002-jira-integration)
7+
- CSV files for export (same as existing GitHub exports) (002-jira-integration)
68

79
- Python 3.9+ (as per constitution, leveraging type hints) + Standard library only (urllib, json, csv, os, re); optional: requests (001-modular-refactor)
810

@@ -34,6 +36,7 @@ python github_analyzer.py --days 7
3436
Python 3.9+ (as per constitution, leveraging type hints): Follow standard conventions
3537

3638
## Recent Changes
39+
- 002-jira-integration: Added Python 3.9+ (per constitution, leveraging type hints) + Standard library (urllib, json, csv, os, re); optional: requests
3740

3841
- 001-modular-refactor: Added Python 3.9+ (as per constitution, leveraging type hints) + Standard library only (urllib, json, csv, os, re); optional: requests
3942

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ pytest tests/ -v
112112
# Run with coverage
113113
pytest --cov=src/github_analyzer --cov-report=term-missing
114114

115-
# Check coverage meets threshold (95%)
116-
pytest --cov=src/github_analyzer --cov-fail-under=95
115+
# Check coverage meets threshold (90%)
116+
pytest --cov=src/github_analyzer --cov-fail-under=90
117117

118118
# Run linter
119119
ruff check src/github_analyzer/
@@ -267,7 +267,7 @@ class TestCommitAnalyzer:
267267

268268
### Test Requirements
269269

270-
- **Coverage**: Minimum 95% code coverage
270+
- **Coverage**: Minimum 90% code coverage
271271
- **Unit tests**: All new code must have tests
272272
- **Mocking**: Mock external dependencies (GitHub API, file system)
273273
- **Fixtures**: Use pytest fixtures for reusable test data
@@ -351,7 +351,7 @@ BREAKING CHANGE: The commits endpoint now returns a different structure.
351351
- [ ] Tests pass locally (`pytest tests/ -v`)
352352
- [ ] Linter passes (`ruff check src/github_analyzer/`)
353353
- [ ] Type checker passes (`mypy src/github_analyzer/`)
354-
- [ ] Coverage is ≥95%
354+
- [ ] Coverage is ≥90%
355355
- [ ] Documentation is updated (if applicable)
356356
- [ ] Commit messages follow conventions
357357

README.md

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
# GitHub Analyzer
1+
# DevAnalyzer (GitHub Analyzer)
22

33
[![Tests](https://github.com/Oltrematica/github_analyzer/actions/workflows/tests.yml/badge.svg)](https://github.com/Oltrematica/github_analyzer/actions/workflows/tests.yml)
44
[![codecov](https://codecov.io/gh/Oltrematica/github_analyzer/branch/main/graph/badge.svg)](https://codecov.io/gh/Oltrematica/github_analyzer)
55
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77

8-
A powerful Python command-line tool for analyzing GitHub repositories and extracting comprehensive metrics about commits, pull requests, issues, and contributor activity. Generate detailed CSV reports for productivity analysis and code quality assessment.
8+
A powerful Python command-line tool for analyzing GitHub repositories and Jira projects, extracting comprehensive metrics about commits, pull requests, issues, and contributor activity. Generate detailed CSV reports for productivity analysis and code quality assessment.
99

1010
![GitHub Analyzer Banner](screens/screen1.png)
1111

1212
## Features
1313

14+
### GitHub Analysis
1415
- **Commit Analysis** - Track commits with detailed statistics including additions, deletions, merge detection, and revert identification
1516
- **Pull Request Metrics** - Monitor PR workflow, merge times, review coverage, and approval rates
1617
- **Issue Tracking** - Analyze issue resolution times, categorization (bugs vs enhancements), and closure rates
1718
- **Contributor Insights** - Identify top contributors with activity metrics and productivity scoring
1819
- **Multi-Repository Support** - Analyze multiple repositories in a single run with aggregated statistics
1920
- **Quality Metrics** - Assess code quality through revert ratios, review coverage, and commit message analysis
2021
- **Productivity Scoring** - Calculate composite productivity scores for contributors across repositories
22+
23+
### Jira Integration (NEW)
24+
- **Jira Issue Extraction** - Extract issues and comments from Jira Cloud and Server/Data Center
25+
- **Multi-Project Support** - Analyze multiple Jira projects with interactive project selection
26+
- **Time-Based Filtering** - Filter issues by update date using JQL queries
27+
- **Comment Tracking** - Export all issue comments with author and timestamp
28+
- **ADF Support** - Automatically converts Atlassian Document Format to plain text
29+
30+
### Core Features
31+
- **Multi-Source CLI** - Use `--sources` flag to select GitHub, Jira, or both
32+
- **Auto-Detection** - Automatically detects available sources from environment credentials
2133
- **Zero Dependencies** - Works with Python standard library only (optional `requests` for better performance)
22-
- **Secure Token Handling** - Token loaded from environment variable, never exposed in logs or error messages
34+
- **Secure Token Handling** - Tokens loaded from environment variables, never exposed in logs or error messages
2335

2436
## Requirements
2537

@@ -123,14 +135,40 @@ The tool shows real-time progress with detailed information for each repository:
123135

124136
### Environment Variables
125137

138+
**GitHub Configuration:**
139+
126140
| Variable | Required | Default | Description |
127141
|----------|----------|---------|-------------|
128-
| `GITHUB_TOKEN` | **Yes** | - | GitHub Personal Access Token |
142+
| `GITHUB_TOKEN` | **Yes*** | - | GitHub Personal Access Token |
129143
| `GITHUB_ANALYZER_DAYS` | No | 30 | Number of days to analyze |
130144
| `GITHUB_ANALYZER_OUTPUT_DIR` | No | `github_export` | Output directory for CSV files |
131145
| `GITHUB_ANALYZER_REPOS_FILE` | No | `repos.txt` | Repository list file |
132146
| `GITHUB_ANALYZER_VERBOSE` | No | `true` | Enable detailed logging |
133147

148+
**Jira Configuration:**
149+
150+
| Variable | Required | Default | Description |
151+
|----------|----------|---------|-------------|
152+
| `JIRA_URL` | **Yes*** | - | Jira instance URL (e.g., `https://company.atlassian.net`) |
153+
| `JIRA_EMAIL` | **Yes*** | - | Jira account email |
154+
| `JIRA_API_TOKEN` | **Yes*** | - | Jira API token |
155+
156+
*Required only if using that source. Auto-detection skips sources without credentials.
157+
158+
### How to Generate a Jira API Token
159+
160+
**For Jira Cloud (Atlassian Cloud):**
161+
1. Go to https://id.atlassian.com/manage-profile/security/api-tokens
162+
2. Click **"Create API token"**
163+
3. Give it a descriptive name (e.g., "dev-analyzer")
164+
4. Click **"Create"** and copy the token immediately (shown only once!)
165+
166+
**For Jira Server / Data Center:**
167+
1. Go to **Profile****Personal Access Tokens**
168+
2. Click **"Create token"**
169+
3. Select appropriate permissions and create
170+
4. Copy the generated token
171+
134172
**Note:** CLI arguments override environment variables.
135173

136174
### repos.txt Format
@@ -149,9 +187,28 @@ astral-sh/ruff
149187
# Duplicates are automatically removed
150188
```
151189

190+
### jira_projects.txt Format
191+
192+
```txt
193+
# Add Jira project keys to analyze (one per line)
194+
# Project keys are case-sensitive (usually uppercase)
195+
196+
PROJ
197+
DEV
198+
OPS
199+
200+
# Lines starting with # are comments
201+
# Empty lines are ignored
202+
# Duplicates are automatically removed
203+
```
204+
205+
If this file is missing, the tool will prompt you interactively to select from available projects.
206+
152207
## Output Files
153208

154-
The analyzer generates 7 CSV files in the output directory:
209+
The analyzer generates CSV files in the output directory. GitHub outputs are always generated when analyzing GitHub, and Jira outputs when analyzing Jira:
210+
211+
**GitHub outputs (7 files):**
155212

156213
![Analysis Summary](screens/screen3.png)
157214

@@ -165,6 +222,13 @@ The analyzer generates 7 CSV files in the output directory:
165222
| `productivity_analysis.csv` | Per-contributor productivity metrics and scores |
166223
| `contributors_summary.csv` | Contributor overview with commit and PR statistics |
167224

225+
**Jira outputs (2 files):**
226+
227+
| File | Description |
228+
|------|-------------|
229+
| `jira_issues_export.csv` | Jira issues with key, summary, status, type, priority, assignee, reporter, dates |
230+
| `jira_comments_export.csv` | Jira issue comments with issue key, author, date, body |
231+
168232
### CSV Field Details
169233

170234
#### commits_export.csv
@@ -341,6 +405,39 @@ export GITHUB_TOKEN=ghp_your_token_here
341405
- Verify repository names in `repos.txt` are correct
342406
- Ensure the token has read access to the repositories
343407

408+
### "JIRA_URL environment variable not set"
409+
```bash
410+
export JIRA_URL="https://yourcompany.atlassian.net"
411+
export JIRA_EMAIL="your.email@company.com"
412+
export JIRA_API_TOKEN="your-api-token"
413+
```
414+
415+
### "Jira authentication failed"
416+
- Verify your email matches your Jira account exactly
417+
- Check that the API token is valid and not expired
418+
- For Jira Cloud, ensure you're using the correct email (not username)
419+
- For Jira Server/Data Center, verify the token has appropriate permissions
420+
421+
### "Jira project not found: PROJ"
422+
- Project keys are case-sensitive (usually uppercase)
423+
- Verify you have access to the project with your account
424+
- Check the project key in Jira (visible in issue keys like PROJ-123)
425+
426+
### "Jira rate limit exceeded"
427+
- The tool automatically retries with exponential backoff
428+
- If persistent, wait a few minutes and retry
429+
- Reduce the number of projects in `jira_projects.txt`
430+
- Use a shorter analysis period with `--days`
431+
432+
### Jira skipped (no credentials)
433+
- This is expected if you only have GitHub configured
434+
- To use Jira, set all three required environment variables: `JIRA_URL`, `JIRA_EMAIL`, `JIRA_API_TOKEN`
435+
436+
### Empty Jira CSV files
437+
- Check if projects have issues updated in the specified period
438+
- Verify project keys in `jira_projects.txt` are correct
439+
- Ensure your account has permission to view the projects
440+
344441
## Security
345442

346443
- **Token Security**: The GitHub token is loaded from the `GITHUB_TOKEN` environment variable and is never stored, logged, or exposed in error messages
@@ -373,7 +470,7 @@ pytest tests/ -v
373470
ruff check src/github_analyzer/
374471
```
375472

376-
We aim for **95% test coverage**. Open an issue for discussion before starting major changes.
473+
We aim for **90% test coverage**. Open an issue for discussion before starting major changes.
377474

378475
## License
379476

dev_analyzer.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
"""DevAnalyzer - Multi-platform development data extraction tool.
3+
4+
This is the primary entry point for analyzing GitHub repositories and Jira projects.
5+
Supports multiple data sources with auto-detection of available credentials.
6+
7+
Usage:
8+
python dev_analyzer.py --sources auto --days 7
9+
python dev_analyzer.py --sources github --days 14
10+
python dev_analyzer.py --sources jira --days 30
11+
python dev_analyzer.py --sources github,jira --output ./reports
12+
13+
Environment Variables:
14+
GitHub:
15+
GITHUB_TOKEN: GitHub Personal Access Token (required for GitHub)
16+
17+
Jira:
18+
JIRA_URL: Jira instance URL (e.g., https://company.atlassian.net)
19+
JIRA_EMAIL: User email for authentication
20+
JIRA_API_TOKEN: Jira API token
21+
22+
For more information, run with --help.
23+
"""
24+
25+
from __future__ import annotations
26+
27+
import sys
28+
29+
from src.github_analyzer.cli.main import main
30+
31+
if __name__ == "__main__":
32+
sys.exit(main())

github_analyzer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"""GitHub Repository Analyzer - Backward Compatible Entry Point.
33
44
This script provides backward compatibility with the original
5-
github_analyzer.py interface while using the new modular architecture.
5+
github_analyzer.py interface. The recommended entry point is now
6+
dev_analyzer.py which supports multiple data sources.
67
78
For the new modular API, use:
89
from src.github_analyzer.cli import main
@@ -14,6 +15,9 @@
1415
Set GITHUB_TOKEN environment variable, then run:
1516
$ python github_analyzer.py
1617
18+
For multi-source analysis, use dev_analyzer.py instead:
19+
$ python dev_analyzer.py --sources github,jira --days 7
20+
1721
Output:
1822
- commits_export.csv: All commits from all repositories
1923
- pull_requests_export.csv: All PRs from all repositories

jira_projects.txt.example

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Jira Projects Configuration
2+
#
3+
# List Jira project keys to analyze, one per line.
4+
# Lines starting with '#' are comments and will be ignored.
5+
# Empty lines are also ignored.
6+
#
7+
# Example project keys:
8+
# PROJ
9+
# DEV
10+
# OPS
11+
#
12+
# To use this file:
13+
# 1. Copy to jira_projects.txt: cp jira_projects.txt.example jira_projects.txt
14+
# 2. Replace example keys with your actual Jira project keys
15+
# 3. Set the required environment variables:
16+
# - JIRA_URL: Your Jira instance URL (e.g., https://company.atlassian.net)
17+
# - JIRA_EMAIL: Your Jira account email
18+
# - JIRA_API_TOKEN: Your Jira API token
19+
#
20+
# Alternatively, run the analyzer without this file to interactively
21+
# select projects from those available in your Jira instance:
22+
# python dev_analyzer.py --sources jira
23+
#
24+
# The project keys below are examples - replace them with your own:
25+
# PROJ
26+
# DEV

0 commit comments

Comments
 (0)