Release 1.5.8 — more robust GitHub integration, workflow detection, and PR/check handling
Summary (what's the main story)
This release (1.5.8) significantly improves the GitHub integration surface: better repository detection, more resilient PR creation and check-waiting logic, richer handling of workflows triggered by PRs/releases, improved release note handling, and milestone management utilities. The net effect is fewer false negatives when checking for CI/checks, clearer failure/recovery diagnostics when PRs or releases fail to create or have failing checks, and better non-interactive behavior for automations.
Highlights — what changed and why it matters
-
Repository detection via environment context
- New behavior: getRepoDetails will use environment variables KODRDRIV_CONTEXT_REPOSITORY_OWNER and KODRDRIV_CONTEXT_REPOSITORY_NAME if present before falling back to parsing the git origin URL.
- Why it matters: makes the library work reliably in parallel/agented execution environments where repo info is provided externally (avoids brittle git remote parsing failures).
-
Injectible prompt function for non-interactive environments
- You can now call setPromptFunction(...) to provide a custom prompt handler; the module defaults to a non-interactive prompt that logs a warning and returns true.
- Why it matters: automated callers (CI/agents) can inject their own confirmation logic or a stub to control flows that would otherwise prompt the user.
-
More resilient PR creation
- createPullRequest truncates titles intelligently to conform to GitHub's 256-char limit.
- Improved handling of 422 errors: on failure, the code will attempt to find an existing PR and return it (with useful logged recovery instructions) rather than immediately failing.
- Why it matters: avoids duplicate PRs created in parallel runs and provides actionable errors/instructions when creation fails.
-
Improved check-run deduplication and completion detection
- waitForPullRequestChecks now:
- Deduplicates check runs by name, retaining the most recent run using timestamp/id heuristics (isNewerCheckRun/getCheckRunTimestamp).
- Treats a check run with a non-empty conclusion as terminal via isTerminalCheckRun (so incorrectly reported "in_progress" status with a conclusion is still treated as done).
- Tracks and logs cancelled checks separately (informational) and only treats genuine failure conclusions as failing.
- Why it matters: reduces flakiness where stale or overlapping check runs could block merges indefinitely; more accurate detection of when checks have truly completed.
- waitForPullRequestChecks now:
-
Better handling when no checks or workflows are present
- If no check runs are found repeatedly, the code now:
- Checks whether Actions workflows are configured (hasWorkflowsConfigured).
- If workflows exist, checks whether any runs are associated with the PR (hasWorkflowRunsForPR) and explains the possible mismatch (e.g., workflows triggered on push but not pull_request).
- Prompts (or uses injected prompt behavior) to allow proceeding in non-interactive scenarios.
- Why it matters: avoids infinite waits and gives clearer guidance when a repository has no checks or misconfigured triggers.
- If no check runs are found repeatedly, the code now:
-
Release-related improvements
- createRelease unescapes common escaped characters (e.g., "
") in title/body so release notes render properly in GitHub when those strings were JSON-serialized earlier. - New helpers to find and wait for workflows triggered by a release (getWorkflowRunsTriggeredByRelease, waitForReleaseWorkflows, getWorkflowsTriggeredByRelease).
- Why it matters: makes automated releases more robust and helps operators know whether release-triggered workflows actually ran and succeeded.
- createRelease unescapes common escaped characters (e.g., "
-
Milestone and issue utilities
- New/expanded functions: findMilestoneByTitle, createMilestone, closeMilestone, getOpenIssuesForMilestone, moveIssueToMilestone, moveOpenIssuesToNewMilestone, ensureMilestoneForVersion, closeMilestoneForVersion, getClosedIssuesForMilestone, getIssueDetails, getMilestoneIssuesForRelease, getRecentClosedIssuesForCommit.
- Notable behavior: getRecentClosedIssuesForCommit strips "-dev.*" suffixes from a provided currentVersion when attempting to locate the matching milestone (so "1.5.8-dev.0" will match milestone "release/1.5.8").
- Why it matters: automates milestone creation/migration and helps generate release notes / commit context from issues reliably.
-
Logging and diagnostic improvements
- Many functions now log more detailed debug/info messages (workflow names, match decisions, counts), and recovery instructions are printed line-by-line for readability.
- Why it matters: makes troubleshooting easier when automations run in CI or in developer machines.
Files changed (scope)
- src/github.ts — large feature and behavior additions and refactors (~65 lines of behavioral changes, many new helper functions).
- tests/github.test.ts — updated/expanded tests to exercise the new behaviors.
- package.json — small version/metadata update.
Total delta: 3 commits, 3 files, ~109 insertions and 7 deletions.
Impact on users and developers
-
For users / integrators:
- Expect more reliable behavior when automating PR creation, waiting for checks, and performing releases.
- If you rely on interactive prompts, behavior is unchanged, but you can now inject custom prompt behavior for non-interactive runs.
- Release notes and titles will render correctly even if they came through JSON-escaped strings.
-
For developers / maintainers:
- New helper functions and code paths (deduplication, timestamp-based selection) are added — review tests to see intended behaviors.
- If you provide repo details via environment in orchestration layers, the module will now use KODRDRIV_CONTEXT_REPOSITORY_OWNER and KODRDRIV_CONTEXT_REPOSITORY_NAME if set.
- The logging is more verbose at debug/info levels; this will help during troubleshooting but may increase log volume if debug is enabled.
Breaking changes and important considerations
-
Breaking changes: none that change the public function signatures in a way that requires callers to update parameter lists. The get_breaking_changes scan for this release surfaced internal refactors around how check runs are inspected and normalized:
- Internally, check run logic moved from raw checkRuns => normalizedCheckRuns and introduced helper functions:
- isTerminalCheckRun(checkRun)
- getCheckRunTimestamp(checkRun)
- isNewerCheckRun(candidate, current)
- Implication: behavior for determining whether a check run is "complete" or which run is "newer" has been tightened. This can change the observable behavior of waitForPullRequestChecks (e.g., deduplicating runs by name and preferring the most recent by timestamp/id). This is intentional and should reduce cases where stale check runs block progress. No API change for callers.
- Internally, check run logic moved from raw checkRuns => normalizedCheckRuns and introduced helper functions:
-
Other noteworthy considerations:
- The module now returns true by default for prompts in non-interactive mode (existing default behavior retained, but now injectable). If you depend on the old console-only warning behavior, you can inject a different prompt function.
- getRepoDetails throwing behavior remains: if git origin parsing fails (and the context env vars are not present), the function will still throw. However, the new environment variable support gives an alternative for environments where git metadata is unavailable or unsuitable.
- Because check deduplication is by name and timestamp, repositories or workflows that intentionally reuse names with out-of-order timestamps may have different effective resolution — this is a correctness improvement in most CI setups but worth validating in unusual setups.
Examples / practical notes
-
To avoid interactive prompts in automation, inject a prompt that returns false to block proceeding without checks, or true to allow automatic continuation:
- setPromptFunction(async (msg) => true);
-
If you run into "no checks" situations, enable debug logging to see the new diagnostic messages explaining whether:
- no workflows are configured,
- workflows exist but don't trigger on pull_request,
- workflows run on branch but not associated with PR checks.
-
When generating release notes programmatically, you can pass strings containing escaped newlines; createRelease will unescape them so GitHub renders line breaks.
Tests
Tests were updated/added (tests/github.test.ts) to cover new behavior around check deduplication, workflow detection, and PR/release flows. Review test changes if you need to modify or extend behavior.
If you maintain integrations or automation that rely on subtle details of check-run ordering or repository detection, please validate those flows after upgrading to 1.5.8.