Skip to content

CLI-180 Test Windows install script [NEW]#169

Merged
tomshafir-sonarsource merged 8 commits intomasterfrom
branch-CLI-180-test-windows-install-script
Apr 13, 2026
Merged

CLI-180 Test Windows install script [NEW]#169
tomshafir-sonarsource merged 8 commits intomasterfrom
branch-CLI-180-test-windows-install-script

Conversation

@tomshafir-sonarsource
Copy link
Copy Markdown
Contributor

No description provided.

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod bot commented Apr 10, 2026

CLI-180

@sonar-review-alpha
Copy link
Copy Markdown
Contributor

sonar-review-alpha bot commented Apr 10, 2026

Summary

Adds Windows support for CLI install script testing and CI/CD. The PR extends the test infrastructure and CI pipeline to validate that both install.sh (Linux) and install.ps1 (Windows) scripts work correctly end-to-end.

Key changes:

  • New E2E test suite (install-scripts.test.ts) that validates install scripts on both platforms
  • CI pipeline now runs tests on both Linux and Windows via matrix builds
  • Extracted platform-agnostic utilities into a new platform.ts module (IS_WINDOWS, buildHomeEnv(), hookScriptName(), hookScriptPath()) to eliminate duplicated platform logic
  • Test harness updated for Windows compatibility: file detection by extension, async cleanup with retries (fixes file-locking issues), proper PATH variable handling
  • Integration tests refactored to skip Unix-specific shell tests on Windows, use platform-aware naming conventions

What reviewers should know

Start here:

  1. Review tests/integration/harness/platform.ts — this is the core abstraction layer extracting platform-specific utilities. Pay special attention to buildHomeEnv() (sets both USERPROFILE and HOME on Windows for Git MSYS2 bash) and hookScriptPath() (handles PowerShell command wrapping).
  2. Check the new E2E test in tests/e2e/install-scripts.test.ts — verifies install.ps1 works on Windows with extended timeout (240s for PowerShell cold-start).

Key architectural decisions:

  • All Windows-specific path logic, extension handling, and environment setup is centralized in platform.ts to prevent scattered platform checks
  • buildHomeEnv() sets both HOME and USERPROFILE on Windows (not just USERPROFILE) because Git for Windows runs hooks in MSYS2 bash, which derives HOME from HOMEDRIVE+HOMEPATH when unset
  • File cleanup changed from sync rmSync() to async rm() with retries — Windows holds locks on files longer and the retries prevent spurious failures
  • Symlinks changed to file copies on Windows (requires admin/Developer Mode), but only in test setup

What to watch for:

  • The CI matrix build in build.yml — verify the conditional steps (libsecret, test:coverage vs test:all, e2e on branches, sonar analysis) run on the correct OS
  • Windows-specific test skips use .skipIf(IS_WINDOWS) for Unix-only shell tests (e.g., git-husky script execution)
  • File path normalization in test assertions — hookScriptPath() always normalizes to forward slashes for consistency
  • PATH variable case sensitivity — explicitly removes Path on Windows to avoid conflicts with PATH
  • E2E test cleanup in afterEach() calls removeFromUserPath() to clean up the user's PATH (real system mutation) — verify this runs even if the test fails

Testing considerations:

  • E2E tests require real network access (binaries.sonarsource.com) and network connectivity
  • PowerShell timeout is 240s vs 120s for shell tests (cold PowerShell startup overhead)
  • Integration tests on Windows may take longer due to file locking behavior on cleanup

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

sonar-review-alpha[bot]

This comment was marked as resolved.

Co-authored-by: tomshafir-sonarsource <tom.shafir@sonarsource.com>
sonar-review-alpha[bot]

This comment was marked as outdated.

Co-authored-by: tomshafir-sonarsource <tom.shafir@sonarsource.com>
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

🗣️ Give feedback

Copy link
Copy Markdown
Member

@kirill-knize-sonarsource kirill-knize-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM! Great work!

@tomshafir-sonarsource tomshafir-sonarsource merged commit 2dec763 into master Apr 13, 2026
24 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