Skip to content

fix: tolerate Windows NSIS line endings#509

Merged
Astro-Han merged 3 commits into
devfrom
codex/fix-windows-nsis-line-endings
May 9, 2026
Merged

fix: tolerate Windows NSIS line endings#509
Astro-Han merged 3 commits into
devfrom
codex/fix-windows-nsis-line-endings

Conversation

@Astro-Han

@Astro-Han Astro-Han commented May 9, 2026

Copy link
Copy Markdown
Owner

Summary

Allow the Windows NSIS shortcut customization test to match both LF and CRLF line endings.

Why

The post-merge windows-advisory workflow started failing after #503 because Git for Windows checked out packages/desktop-electron/resources/installer.nsh with CRLF line endings, while the test asserted a literal LF-only substring. The installer script content was correct; the test was too line-ending-specific for the Windows runner.

Related Issue

No dedicated issue. This fixes the repeated post-merge windows-advisory failure introduced by #503.

Human Review Status

Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.

Review Focus

Confirm the regex preserves the original structural assertion while accepting Windows CRLF checkout behavior.

Risk Notes

Low. This is a test-only change and does not change installer runtime behavior.

How To Verify

Focused desktop test: 9 passed, 0 failed via bun --cwd packages/desktop-electron test electron-builder-nsis-shortcut.test.ts
Line-ending proof: ok for both LF and CRLF via a Bun regex smoke check
Diff check: git diff --check passed with no whitespace errors
Final diff: 1 file changed, 1 insertion, 1 deletion

Screenshots or Recordings

Not applicable. No visible UI change.

Checklist

  • Human review status is stated above as pending, approved, or not required
  • I linked the related issue, or stated why there is no issue
  • This PR has type, primary area, and priority labels, or I requested maintainer labeling
  • I described the review focus and any meaningful risks
  • I listed the relevant verification steps and the key result for each
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope
  • I manually checked visible UI or copy changes when needed, with screenshots or recordings
  • I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes
  • I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant
  • I reviewed the final diff for unrelated changes and suspicious dependency changes
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English

Summary by CodeRabbit

Release Notes

  • Tests
    • Enhanced Windows installer test robustness to handle varying line ending formats across different systems.

Review Change Stack

@Astro-Han Astro-Han added bug Something isn't working ci Continuous integration / GitHub Actions windows Windows-specific P2 Medium priority labels May 9, 2026
@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Astro-Han has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 35 minutes and 10 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ec4366a7-d001-4ce1-acde-952b7e94036d

📥 Commits

Reviewing files that changed from the base of the PR and between 9469ce1 and 45311c6.

📒 Files selected for processing (1)
  • packages/desktop-electron/electron-builder-nsis-shortcut.test.ts
📝 Walkthrough

Walkthrough

A single test assertion in the Windows NSIS installer shortcut customization test is updated to use newline-tolerant regex matching (\r?\n) instead of a hardcoded string with Unix line endings. This makes the test pass regardless of the line ending style in the generated installer.nsh file.

Changes

NSIS Shortcut Test Robustness

Layer / File(s) Summary
Line Ending Resilience
packages/desktop-electron/electron-builder-nsis-shortcut.test.ts
The assertion for !ifndef BUILD_UNINSTALLER and Var AddDesktopShortcutCheckbox declaration changes from toContain() with hardcoded \n to toMatch() with regex \r?\n, tolerating both Windows (\r\n) and Unix (\n) line endings.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • Astro-Han/pawwork#503: Added or modified the NSIS desktop-shortcut test and installer content that this change now makes line-ending resilient.

Poem

🐰 Line endings dance between systems two,
Now regex plays both old and new,
\r?\n bends either way,
No more brittle tests will fray!
A tiny fix, yet smooth to stay. 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: tolerate Windows NSIS line endings' directly and concisely describes the main change: modifying the test to handle both LF and CRLF line endings on Windows.
Description check ✅ Passed The pull request description comprehensively follows the template with all required sections completed: Summary, Why, Related Issue, Human Review Status, Review Focus, Risk Notes, How To Verify, Screenshots/Recordings, and a fully checked Checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-windows-nsis-line-endings

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates a test in electron-builder-nsis-shortcut.test.ts to use a regular expression for matching script content, which improves compatibility with different line endings. The review feedback suggests further enhancing the regex by using \s+ to make the test more resilient to variations in indentation and whitespace.

Comment thread packages/desktop-electron/electron-builder-nsis-shortcut.test.ts Outdated
@Astro-Han Astro-Han merged commit ec5c6e2 into dev May 9, 2026
20 checks passed
@Astro-Han Astro-Han deleted the codex/fix-windows-nsis-line-endings branch May 9, 2026 14:26
Astro-Han added a commit that referenced this pull request May 9, 2026
Root cause:
- The post-merge `windows-advisory` workflow was still red after PR #509, but the remaining failure was no longer the NSIS desktop installer test.
- The failing job was `unit-windows-opencode-session`, and the failure happened inside `packages/opencode/test/session/export.test.ts` before the export assertion ran.
- Windows reported `EBUSY: resource busy or locked` while the test attempted to delete a git-backed temp project directory with `fs.rm(...)` in order to simulate a missing original session instruction directory.
- The same `EBUSY` signature appeared in consecutive dev advisory runs, so it was actionable CI instability rather than a one-off signal to ignore.

What changed:
- Added a small test-local helper, `removeSessionProjectDirectory`, that keeps the existing deletion behavior but adds retry budget for transient Windows file-handle release delays.
- Replaced the two direct `fs.rm(sessionProject.path, ...)` calls in the export tests that intentionally remove the original session project directory.
- Kept the export/runtime implementation and the existing assertions unchanged.

Scope boundary:
- Test-only change in `packages/opencode/test/session/export.test.ts`.
- No product export behavior, installer code, workflow configuration, dependencies, or generated files changed.
- This is separate from the PR #509 NSIS line-ending fix; #509 fixed `unit-windows-desktop`, while this PR addresses the remaining opencode session export advisory failure.

Verification:
- `git diff --check` completed with no whitespace errors.
- `bun --cwd packages/opencode test test/session/export.test.ts` passed locally with 32 pass / 0 fail.
- PR #511 status rollup completed successfully: `ci`, `desktop-smoke`, `codeql`, `e2e-artifacts`, `commit-lint`, PR title lint, dependency review, CodeRabbit, and unit result checks were all green.

Follow-up:
- The direct original failure surface is the `windows-advisory` workflow on dev. That workflow is not part of the normal PR path, so the final confirmation is the next dev advisory run after this squash merge, or a manual dispatch of `windows-advisory`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci Continuous integration / GitHub Actions P2 Medium priority windows Windows-specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant