Skip to content

ci(project): nightly drift-sync to catch missed auto-adds - #2316

Merged
zackees merged 1 commit into
masterfrom
feat/project-drift-sync
Apr 18, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/project-drift-sync

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Adds a daily cron + workflow_dispatch reconciler. Safety net behind the event-driven auto-add workflows. Smoke-tested locally (added 1 drifted item). Uses the same GitHub App as project_automation.yml.

Summary by CodeRabbit

  • New Features
    • Introduced automated GitHub Project synchronization that runs nightly to ensure project items stay aligned with repository issues and pull requests. The system automatically detects and adds any new or missing items from configured repositories. On-demand manual synchronization can also be triggered to include closed or merged items for backfill scenarios.

Adds a scheduled safety net behind the event-driven add-to-project
workflows. Every day at 03:00 UTC, reconciles the FastLED Tracker
project (#1) against the live state of the six feeder repos and adds
any open issue/PR that isn't already linked. Also exposed via
workflow_dispatch with an `include_closed` flag for rare full-backfill
needs (off by default — there are ~1500 historical closed items).

Why: event-driven workflows miss items if a run flakes, if the App key
is revoked mid-day, if events aren't delivered (rare but documented),
or if automation was off entirely for a window. Without a reconciler,
those items drift forever. This script finds them on the next cron.

Design notes:
- addProjectV2ItemById is idempotent — re-adds cost nothing.
- Script first fetches every item currently in the project (paginated
  GraphQL), then per-repo diffs against gh issue/pr list output, then
  adds missing items one-by-one. Rate-limit friendly: one mutation per
  missing item, which is typically 0-5 per day.
- Uses the same GitHub App installation token as project_automation.yml,
  so no additional secrets.
- Smoke-tested locally: 293 project items, 277 open items across 6
  repos, 1 missing → added cleanly.

On "bot resurrection": if the App key gets rotated wrong, or a workflow
disables, or anything else drops coverage, the next scheduled run
backfills whatever was missed while things were broken.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 3314312 into master Apr 18, 2026
@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8c65897b-3587-49c7-9251-566b5d26cdbf

📥 Commits

Reviewing files that changed from the base of the PR and between 6bd2adf and 845c6ff.

📒 Files selected for processing (2)
  • .github/workflows/project_drift_sync.yml
  • ci/github_project_drift_sync.py

📝 Walkthrough

Walkthrough

A new GitHub Actions workflow and Python script add nightly drift synchronization for GitHub Projects. The workflow triggers automatically at 03:00 UTC or manually, executing a script that resolves a project's node ID, fetches current linked items, iterates through configured feeder repositories, and adds any missing items to the project.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/project_drift_sync.yml
New workflow scheduling nightly execution at 03:00 UTC and supporting manual dispatch. Conditionally runs sync job with required repository variables, checks out code with sparse checkout, sets up Python 3.11, generates GitHub App token, and invokes drift sync script with environment variables and configuration.
Drift Sync Script
ci/github_project_drift_sync.py
New Python script reconciling GitHub Project items against live repository state. Resolves project node ID, fetches currently-linked items, iterates through feeder repositories, and adds missing items via GraphQL. Includes helper functions for gh CLI execution, GraphQL queries, and best-effort error handling.

Sequence Diagram

sequenceDiagram
    actor Schedule as GitHub<br/>(Schedule/Manual)
    participant Workflow as GitHub Actions<br/>Workflow
    participant Script as Drift Sync<br/>Script
    participant GH as GitHub API<br/>(gh CLI)
    participant Repos as Feeder<br/>Repositories

    Schedule->>Workflow: Trigger (nightly or manual)
    Workflow->>Workflow: Checkout & setup Python 3.11
    Workflow->>GH: Create GitHub App token
    Workflow->>Script: Execute with env vars
    
    Script->>GH: Resolve project node ID
    GH-->>Script: Project node ID
    
    Script->>GH: Fetch current project items
    GH-->>Script: Item list (repo, number)
    
    Script->>Repos: List issues/PRs for each repo
    Repos-->>Script: Item node IDs & numbers
    
    Script->>Script: Identify missing items
    
    alt For each missing item
        Script->>GH: addProjectV2ItemById (GraphQL)
        GH-->>Script: Success or failure
    end
    
    Script->>Workflow: Exit code (0 or 1)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A project keeps drifting, items slip from sight,
But now a rabbit script runs through the night,
Syncing with feeder repos, neat and precise,
Finding lost issues—oh, wouldn't that be nice!
Hop by hop, the gaps close tight. 🐇✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/project-drift-sync

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees deleted the feat/project-drift-sync branch May 30, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant