Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linux support #9

Merged
merged 9 commits into from
Jan 12, 2024
Merged

Add Linux support #9

merged 9 commits into from
Jan 12, 2024

Conversation

dfed
Copy link
Owner

@dfed dfed commented Jan 10, 2024

We're failing to build on Linux today. This PR gets us working on Linux by making ZippyJSON a platform-conditioned dependency, as well as fixing a host of other issues. I added Linux checks to CI as well.

When we merge, I'll need to add the linux check as required on all PRs.

@dfed dfed self-assigned this Jan 10, 2024
@dfed dfed force-pushed the dfed--linux-support branch 2 times, most recently from f0c90b3 to 4e19b63 Compare January 10, 2024 19:28
@dfed dfed force-pushed the dfed--linux-support branch from a06486e to 9d4225d Compare January 10, 2024 19:49
uses: actions/checkout@v3
uses: actions/checkout@v4
Copy link
Owner Author

Choose a reason for hiding this comment

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

This isn't a directly related change but I figured I'd bump while I was here.

Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 18 lines in your changes are missing coverage. Please review.

Comparison is base (484ee1e) 97.63% compared to head (2215c4e) 97.47%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main       #9      +/-   ##
==========================================
- Coverage   97.63%   97.47%   -0.17%     
==========================================
  Files          37       37              
  Lines        7324     7333       +9     
==========================================
- Hits         7151     7148       -3     
- Misses        173      185      +12     
Files Coverage Δ
...afeDICore/Generators/DependencyTreeGenerator.swift 96.63% <100.00%> (ø)
Tests/SafeDICoreTests/TypeDescriptionTests.swift 100.00% <100.00%> (ø)
Tests/SafeDIToolTests/SafeDIToolTests.swift 100.00% <100.00%> (ø)
Sources/SafeDICore/Models/TypeDescription.swift 92.85% <14.28%> (-0.03%) ⬇️
Sources/SafeDITool/SafeDITool.swift 41.11% <0.00%> (-2.94%) ⬇️

@dfed dfed force-pushed the dfed--linux-support branch 2 times, most recently from 29dd651 to 9fa58d4 Compare January 10, 2024 21:14
@@ -54,7 +54,7 @@ public final class DependencyTreeGenerator {
for try await generatedRoot in taskGroup {
generatedRoots.append(generatedRoot)
}
return generatedRoots.sorted().joined(separator: "\n\n").trimmingCharacters(in: .whitespacesAndNewlines)
Copy link
Owner Author

Choose a reason for hiding this comment

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

trimmingCharacters exists on NSString, which doesn't exist in Swift on Linux. Turns out we didn't need this call anyways though.

enum DependencyTreeGeneratorError: Error, CustomStringConvertible {
private enum DependencyTreeGeneratorError: Error, CustomStringConvertible {
Copy link
Owner Author

Choose a reason for hiding this comment

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

not a necessary change but noticed that I'd forgotten to make this private while I was here.

@@ -121,7 +121,7 @@ public enum TypeDescription: Codable, Hashable, Comparable, Sendable {
case let .closure(arguments, isAsync, doesThrow, returnType):
return "(\(arguments.map { $0.asSource }.joined(separator: ", ")))\([isAsync ? " async" : "", doesThrow ? " throws" : ""].filter { !$0.isEmpty }.joined()) -> \(returnType.asSource)"
case let .unknown(text):
return text.trimmingCharacters(in: .whitespacesAndNewlines)
Copy link
Owner Author

Choose a reason for hiding this comment

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

since trimmingCharacters doesn't exist on Linux, we now initialize this type with a trimmedDescription which does effectively the same thing (and we've got a test to prove it!)

"SafeDICore",
"ZippyJSON",
Copy link
Owner Author

Choose a reason for hiding this comment

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

ZippyJSON does not support Linux (or technically watchOS, visionOS, and a few other platforms)

@@ -476,9 +476,8 @@ extension TypeSyntax {
returnType: typeIdentifier.returnClause.type.typeDescription)

} else {
assertionFailure("TypeSyntax of unknown type. Defaulting to `description`.")
Copy link
Owner Author

Choose a reason for hiding this comment

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

We haven't gotten any value out of this assertionFailure in multiple years of development on this type across multiple projects. Time to remove.

} catch {
didThrow = true
XCTAssertEqual((error as CustomStringConvertible).description, errorDescription, line: line)
XCTAssertEqual("\(error)", errorDescription, line: line)
Copy link
Owner Author

Choose a reason for hiding this comment

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

This change was required to get tests working on Linux. (error as CustomStringConvertible).description was not finding our var description: String code on Linux for unknown reasons.

@dfed dfed force-pushed the dfed--linux-support branch from a28ae2f to 972e650 Compare January 10, 2024 22:46
@dfed dfed marked this pull request as ready for review January 10, 2024 23:09
@dfed
Copy link
Owner Author

dfed commented Jan 12, 2024

Merging this since we aren't really changing functionality, and we have good test coverage on the changed code. As always, happy to take feedback post merge.

@dfed dfed merged commit 4c83c05 into main Jan 12, 2024
6 checks passed
@dfed dfed deleted the dfed--linux-support branch January 12, 2024 23:26
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.

1 participant