Skip to content

fix: scope full sync to GH_ORG and await Probot readiness - #1095

Merged
decyjphr merged 3 commits into
yadhav/fix-recent-issuesfrom
decyjphr-organization-sync-targeting
Sep 29, 2026
Merged

decyjphr merged 3 commits into
yadhav/fix-recent-issuesfrom
decyjphr-organization-sync-targeting

Conversation

@decyjphr

@decyjphr decyjphr commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Operators need to restrict full sync to a specific account instead of reconciling every account where the App is installed. This adapts #1053 to yadhav/fix-recent-issues, including its now-merged all-installations behavior from #1094.

Approach

  • Export GH_ORG and select the matching repository-owning account case-insensitively. Fail clearly when no installation matches, including an empty installation list, rather than falling back to another account.
  • When GH_ORG is unset, preserve the target branch's sequential sync of all repository-owning installations. Retain per-installation authentication/context, failure isolation, and aggregated { results, errors }.
  • Log each selected account. Preserve enterprise enrichment and the existing info() slug lookup; enterprise installations are not repository sync targets.
  • Return the scheduled sync promise and log/rethrow targeting or enumeration failures so node-cron reports failed execution. CLI errors retain nonzero exit status, including dry runs.
  • Await Probot readiness before using its logger. Actual-runtime testing exposed a startup failure because Probot initializes asynchronously.
  • Retain both targeting and fanout regression suites and smoke phases 21, 22, and 24. Update documentation to describe the combined behavior.

Validation

Node 22.12.0 / npm 10.9.0:

  • After resolving the target-branch merge, npm run test:unit -- --runInBand --reporters=default: 889 passed, 12 skipped.
  • Combined coverage includes unset/empty GH_ORG fanout, case-insensitive single-account targeting, enterprise exclusion, failure aggregation/isolation, targeted NOP configuration failure without fallback, CLI exit status, and cron failure reporting.
  • Conflict-resolved CLI/test files pass targeted ESLint; syntax and whitespace checks pass.
  • Six real-Probot CLI regressions, with synthetic credentials and networking blocked, originally failed before the readiness correction and passed afterward; they remain included in the combined suite.

Earlier live smoke, before this merge resolution: setup -> Phase 24 -> teardown passed 6 assertions with actual CLI completion and exit status verified. Independent cleanup confirmed unchanged original configuration, property definitions, admin policy, unrelated refs, and repository/team/role inventories. Owned processes exited and the port closed. No live smoke was rerun for the merge resolution.

Live coverage limitation: That smoke used a session-only verified-installation enumeration filter and hard authentication/API guards. It proves a contained single-test-org CLI/NOP run, not unfiltered live multi-account selection. Second-account selection and no-match behavior are covered offline. The first smoke attempt was rejected because Probot reloaded .env over explicitly blank execution flags; the retry verified effective flags after loading and restored the private environment copy exactly. No containment adapters or credentials are committed.

Earlier baseline validation found integration failures at the pre-existing Probot ESM import boundary (7 suites, 0 executed tests) and repository lint debt of 173 errors and 7 warnings. Those broad checks were not rerun for this merge resolution.

Provenance and integration

Originally based on 188c604929201774699fd1d8dabd445358cee9e8:

The overlap with #1044's adaptation is now reconciled: all repository-owning installations when unset, only the matching account when GH_ORG is set. Combined local regression coverage passes; the earlier single-branch smoke is not presented as live validation of the merged implementation.

decyjphr and others added 3 commits September 28, 2026 23:25
Adapt PR #1053 source 0201457 onto yadhav/fix-recent-issues at 188c604. Preserve the first-installation default and enterprise context, and return scheduled sync promises so targeting failures are reported.

Cover case-insensitive selection, fail-closed targeting, NOP and CLI failures, scheduler reporting, and explicit-org smoke dry runs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Wait for the installed Probot runtime to initialize before using its logger or loading the application. Preserve existing full-sync reporting and exit behavior.

Add no-network real-runtime CLI regressions for apply and dry-run success, missing targets, and collected sync failures; update existing CLI mock fixtures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve all repository-owning installations when GH_ORG is unset and limit sync to the matching account when configured. Retain failure aggregation, Probot readiness, scheduler error reporting, and all regression and smoke coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation matches the stated targeting and fanout behavior with comprehensive regression coverage; only a minor documentation correction remains.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Scopes full syncs using GH_ORG while preserving multi-installation fanout and ensuring Probot is ready before CLI use.

Changes:

  • Adds case-insensitive installation targeting and clear failures.
  • Preserves sequential fanout, enterprise enrichment, and cron error reporting.
  • Expands CLI, unit, smoke, and documentation coverage.
File Description
.env.example Documents GH_ORG behavior.
README.md Documents scoped full sync and smoke testing.
docs/​github-action.md Updates GitHub Actions guidance.
full-sync.js Awaits Probot readiness.
index.js Implements targeting and cron rejection propagation.
lib/​env.js Exports GH_ORG.
smoke-test.js Adds targeted CLI smoke phase.
test/​unit/​full-sync.test.js Tests real Probot CLI startup.
test/​unit/​lib/​env.test.js Tests environment defaults and overrides.
test/​unit/​lib/​settings-batching.test.js Updates Probot readiness mock.
test/​unit/​smoke-organization-targeting.test.js Tests smoke-phase safeguards.
test/​unit/​sync-installation.test.js Covers targeting, fanout, and failures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md
```
CREATE_DEFAULT_BRANCH=true
```
1. Scope CLI and cron full syncs to one account using `GH_ORG`. For e.g.
@decyjphr
decyjphr merged commit b0684df into yadhav/fix-recent-issues Sep 29, 2026
3 checks passed
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.

2 participants