|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build, Test, and Lint Commands |
| 6 | + |
| 7 | +### Testing |
| 8 | +```bash |
| 9 | +# Run all tests with coverage (default, excludes integration tests) |
| 10 | +tox |
| 11 | + |
| 12 | +# Run tests for specific Python version |
| 13 | +tox -e py312 |
| 14 | +tox -e py313 |
| 15 | + |
| 16 | +# Run with HTML coverage report (add this arg locally) |
| 17 | +tox -- --cov-report html:htmlcov-py313 |
| 18 | + |
| 19 | +# Run tests directly with pytest |
| 20 | +coverage run -m pytest --ignore=tests/integration_tests |
| 21 | +coverage report |
| 22 | +coverage html # Generate HTML coverage report |
| 23 | +``` |
| 24 | + |
| 25 | +### Linting and Formatting |
| 26 | +```bash |
| 27 | +# Check linting (flake8) |
| 28 | +tox -e lint |
| 29 | + |
| 30 | +# Check code formatting (black) |
| 31 | +tox -e black |
| 32 | + |
| 33 | +# Check import sorting (isort) |
| 34 | +tox -e isort |
| 35 | + |
| 36 | +# Auto-format code |
| 37 | +tox -e black-format |
| 38 | +tox -e isort-format |
| 39 | +``` |
| 40 | + |
| 41 | +### Running the Service |
| 42 | +```bash |
| 43 | +# Install in development mode |
| 44 | +pip install -e . |
| 45 | + |
| 46 | +# Run the main sync service |
| 47 | +sync2jira |
| 48 | + |
| 49 | +# Run with initialization (sync all existing issues) |
| 50 | +INITIALIZE=1 sync2jira |
| 51 | + |
| 52 | +# Run the sync-page web UI |
| 53 | +cd sync-page |
| 54 | +python event-handler.py |
| 55 | +``` |
| 56 | + |
| 57 | +## Architecture |
| 58 | + |
| 59 | +Sync2Jira is a fedmsg-based service that synchronizes GitHub issues and pull requests to JIRA in real-time. |
| 60 | + |
| 61 | +### Data Flow |
| 62 | +GitHub Event → Fedora Message Bus → sync2jira → Upstream Handler → Intermediary Object → Downstream Handler → JIRA |
| 63 | + |
| 64 | +### Core Components |
| 65 | + |
| 66 | +**sync2jira/main.py**: Entry point and event loop |
| 67 | +- Loads configuration from `fedmsg.d/sync2jira.py` |
| 68 | +- Sets up message handlers for GitHub events |
| 69 | +- Routes messages to appropriate handlers (issues vs PRs) |
| 70 | +- Handles initialization mode for bulk syncing |
| 71 | + |
| 72 | +**sync2jira/intermediary.py**: Platform-agnostic data models |
| 73 | +- `Issue` and `PR` classes represent upstream items in a normalized way |
| 74 | +- `matcher()` function determines if an item should be synced based on filters |
| 75 | +- Converts between GitHub format and internal representation |
| 76 | + |
| 77 | +**sync2jira/upstream_*.py**: GitHub event processors |
| 78 | +- `upstream_issue.py`: Processes GitHub issue events, converts to intermediary objects |
| 79 | +- `upstream_pr.py`: Processes GitHub PR events |
| 80 | +- Handles API calls to fetch full issue/PR data when needed |
| 81 | +- Manages rate limiting |
| 82 | + |
| 83 | +**sync2jira/downstream_*.py**: JIRA interaction layer |
| 84 | +- `downstream_issue.py`: Creates/updates JIRA issues from intermediary objects |
| 85 | +- `downstream_pr.py`: Creates/updates JIRA issues for PRs |
| 86 | +- Handles JIRA-specific logic: custom fields, transitions, components |
| 87 | +- Manages issue linking and remote links back to GitHub |
| 88 | + |
| 89 | +**sync-page/**: Flask web UI for manual sync |
| 90 | +- `event-handler.py`: Flask app that allows triggering syncs for individual repositories |
| 91 | +- Useful for testing or one-off syncs without waiting for fedmsg events |
| 92 | + |
| 93 | +## Configuration |
| 94 | + |
| 95 | +See README.md "Configuration" section and the example in `fedmsg.d/sync2jira.py`. |
| 96 | + |
| 97 | +## Development Guidelines |
| 98 | + |
| 99 | +See CONTRIBUTING.md for: |
| 100 | +- Testing requirements and coverage expectations |
| 101 | +- PR etiquette (history management, comment resolution) |
| 102 | +- Code standards (black, isort, flake8) |
0 commit comments