Skip to content

Refactor: two-way sync, extract services, add tests#527

Closed
nembree360 wants to merge 1 commit intoreload:v1.xfrom
360incentives:refactor/two-way-sync-and-tests
Closed

Refactor: two-way sync, extract services, add tests#527
nembree360 wants to merge 1 commit intoreload:v1.xfrom
360incentives:refactor/two-way-sync-and-tests

Conversation

@nembree360
Copy link

@nembree360 nembree360 commented Mar 9, 2026

Summary

  • Extract Config DTO — centralizes all getenv() calls with validation and readonly properties
  • Two-way sync — when GitHub alerts are resolved (FIXED/DISMISSED/AUTO_DISMISSED), the corresponding Jira tickets are now automatically closed via workflow transition
  • Extract servicesGitHubGraphQLClient, AlertSyncService, JiraTransitionService, AlertIdentifier, RetryableApiCall break the monolithic SyncCommand into focused, testable classes
  • Add PHPUnit — 41 tests (unit + integration) covering Config, unique ID generation, GraphQL client, pagination, Jira transitions, and the full closure flow
  • Cursor-based pagination — no longer capped at 100 alerts/PRs
  • Retry with exponential backoff — GraphQL and Jira API calls retry up to 3 times on transient failures
  • Remove unused symfony/yaml dependency

New environment variable

Variable Required Default Purpose
JIRA_CLOSE_TRANSITION No Done Jira workflow transition name for closing resolved alerts

New files

File Purpose
src/Config.php Readonly config DTO
src/SecurityIssueInterface.php Shared interface
src/GitHubGraphQLClient.php GitHub GraphQL with pagination
src/AlertSyncService.php Core sync logic (open, PRs, close)
src/AlertIdentifier.php Shared unique ID builder
src/JiraTransitionService.php Jira search + transition
src/RetryableApiCall.php Exponential backoff retry
phpunit.xml PHPUnit configuration
tests/ 41 tests across 9 test files

Test plan

  • composer exec phpunit — 41 tests pass
  • phpstan analyse . — level 8, no errors
  • phpcs -s bin/ src/ — no violations
  • Dry-run against a real repo: docker compose run --rm ghsec-jira --verbose --dry-run
  • Live test against a staging Jira project with known resolved alerts
  • Verify CI passes (PHPStan + PHPCS + PHPUnit)

🤖 Generated with Claude Code

@nembree360 nembree360 requested a review from a team as a code owner March 9, 2026 20:57
@nembree360 nembree360 changed the title Refactor/two way sync and tests Refactor: two-way sync, extract services, add tests Mar 9, 2026
- Extract Config DTO to centralize all getenv() calls with validation
- Add SecurityIssueInterface for shared contract
- Extract GitHubGraphQLClient with cursor-based pagination
- Extract AlertSyncService from monolithic SyncCommand (~50 line orchestrator)
- Add two-way sync: close Jira tickets when GitHub alerts are resolved
  (FIXED, DISMISSED, AUTO_DISMISSED) via new JiraTransitionService
- Add AlertIdentifier for shared unique ID generation
- Add RetryableApiCall with exponential backoff for API resilience
- Add PHPUnit with 41 tests (unit + integration), all passing
- New env var: JIRA_CLOSE_TRANSITION (default: "Done")
- Remove unused symfony/yaml dependency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nembree360 nembree360 force-pushed the refactor/two-way-sync-and-tests branch from 8cfe8d9 to 64a8fef Compare March 9, 2026 21:08
achton
achton previously requested changes Mar 9, 2026
Copy link
Member

@achton achton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a massive refactoring with ~4k changed LOC and many disparate features and changes.

Can you provide some context to why are you suggesting these changes?

@achton achton dismissed their stale review March 9, 2026 21:43

Dismissing: review contained at least one unverified finding (actions/checkout@v6 does exist). Will re-review with verified findings.

@nembree360 nembree360 closed this Mar 10, 2026
@nembree360 nembree360 deleted the refactor/two-way-sync-and-tests branch March 10, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants