Skip to content

feat: Windows support#71

Merged
ainame merged 14 commits intomainfrom
windows-support
Sep 24, 2025
Merged

feat: Windows support#71
ainame merged 14 commits intomainfrom
windows-support

Conversation

@ainame
Copy link
Owner

@ainame ainame commented Sep 23, 2025

Tested this branch on Windows 11 with ARM.

  • Support Windows in ToyHttpServer
  • Fix test cases relying on string representation of file paths with / which is \ in Windows instead
  • Fix file path operations using split(separator: "/")
  • Updated GitWrapper to throw errors when a git command fails (so that it'll be easier to notice bugs)
  • Downgrade swift-markdown to 0.6.0 due to compilation errors on Windows
  • Downgrade Swift toolchains version to 6.1.3 due to compilation errors on macOS 😂
  • Updated ci.yml to support os matrix (ubuntu, macOS, windows)

Copilot AI review requested due to automatic review settings September 23, 2025 21:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds Windows support to the project by addressing platform-specific differences in file path handling and socket APIs. The changes ensure cross-platform compatibility while maintaining existing functionality on Unix-like systems.

Key changes:

  • Updated path handling to use FilePath API instead of string-based path operations for cross-platform compatibility
  • Added Windows socket implementation with WinSDK imports and platform-specific type aliases
  • Fixed GitHub Actions workflow to explicitly reference repository for release operations

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/TuzuruLibTests/IntegrityManagerTests.swift Updated file path comparisons to use FilePath for cross-platform compatibility
Tests/TuzuruLibTests/GitCommitterTests.swift Removed test case that relied on Unix-specific file behavior
Tests/TuzuruLibTests/GenerateManifestTests.swift Updated path assertions to use FilePath API instead of string comparisons
Tests/TuzuruLibTests/BlogConfigurationLoaderTests.swift Modified configuration path tests to use FilePath equality checks
Sources/TuzuruLib/Utils/GitWrapper.swift Enhanced error handling with proper exit code checking and custom error type
Sources/TuzuruLib/SourceLoader/SourceLoader.swift Replaced string-based path splitting with FilePath components
Sources/TuzuruLib/Generator/PathGenerator.swift Refactored path operations to use FilePath components for better cross-platform support
Sources/TuzuruLib/Generator/BlogGenerator.swift Updated directory parsing to use FilePath components
Sources/TuzuruLib/Amender/FileAmender.swift Modernized FileHandle usage with proper error handling
Sources/ToyHttpServer/SocketAPI.swift Added comprehensive Windows socket support with WinSDK integration
.github/workflows/release-please.yml Fixed GitHub CLI commands to explicitly reference repository

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

let fileHandle = try FileHandle(forWritingTo: URL(fileURLWithPath: fullFilePath.string))
defer { try? fileHandle.close() }
try fileHandle.seekToEnd()
try fileHandle.write(contentsOf: "\n".data(using: .utf8)!)
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The do block doesn't have a catch clause, which means any errors thrown by the FileHandle operations will propagate up. This could result in unclear error messages for the caller. Consider adding a catch block to provide more context about file writing failures.

Suggested change
try fileHandle.write(contentsOf: "\n".data(using: .utf8)!)
try fileHandle.write(contentsOf: "\n".data(using: .utf8)!)
} catch {
throw TuzuruError.fileWriteFailed(fullFilePath.string, error)

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings September 23, 2025 21:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +68 to +73
do {
let fileHandle = try FileHandle(forWritingTo: URL(fileURLWithPath: fullFilePath.string))
defer { try? fileHandle.close() }
try fileHandle.seekToEnd()
try fileHandle.write(contentsOf: "\n".data(using: .utf8)!)
}
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The do block is missing a corresponding catch block. Either add proper error handling or remove the do block since all operations are already throwing and will propagate up.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings September 23, 2025 22:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings September 23, 2025 22:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings September 23, 2025 22:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings September 23, 2025 22:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ainame ainame marked this pull request as ready for review September 23, 2025 23:09
@ainame ainame enabled auto-merge (squash) September 24, 2025 00:22
@ainame ainame mentioned this pull request Sep 24, 2025
15 tasks
@ainame ainame merged commit 14ad8da into main Sep 24, 2025
6 of 8 checks passed
@ainame ainame deleted the windows-support branch September 24, 2025 00:30
@ainame ainame mentioned this pull request Sep 24, 2025
@ainame ainame mentioned this pull request Jan 15, 2026
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