Skip to content

Cleanup PackageModel Module #2980

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

Merged
merged 21 commits into from
Oct 21, 2020

Conversation

mattt
Copy link
Contributor

@mattt mattt commented Oct 12, 2020

Following up on #2970, this PR seeks to make code in the PackageModel module more understandable by extracting some standalone types into separate files and moving declarations around to be closer to related APIs.

Notably, this PR moves the ResolvedPackage, ResolvedProduct, and ResolvedTarget types into the PackageGraph module. In the process of reading through the codebase, these types seemed to be more relevant to the concerns of PackageGraph than to PackageModel where they're currently declared. However, that could just be my lack of understanding how these types fit into the broader picture for SPM.

The other change I wanted to call out was 64f6b5d, which attempts to make Manifest.swift more manageable by extracting the ____Description types into individual files. Here, I created a subdirectory to group them together; without a common prefix, they'd be intermingled with other types. However, this convention isn't currently used in the codebase. Please let me know if you have a different, more preferable solution. (Alternatively, this grouping could be seen as a code smell, indicating that these types belong somewhere else... interested to hear any thoughts you have)

@MaxDesiatov

This comment has been minimized.

@mattt mattt force-pushed the packagemodel-module-cleanup branch from 37a89bb to 28420cf Compare October 13, 2020 15:38
@mattt
Copy link
Contributor Author

mattt commented Oct 13, 2020

@swift-ci please smoke test

Copy link
Contributor

@neonichu neonichu left a comment

Choose a reason for hiding this comment

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

Thanks, Mattt! This refactoring is great, just had one comment.

@neonichu
Copy link
Contributor

@swift-ci please smoke test linux

@mattt
Copy link
Contributor Author

mattt commented Oct 14, 2020

It looks like Linux smoke test is failing for unrelated reasons. Is this a known issue?

Failing Log Lines
/home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:13:1: error: expressions are not allowed at the top level
11:54:38 tests += LSPLoggingTests.__allTests()
11:54:38 ^
11:54:38 /home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:14:1: error: expressions are not allowed at the top level
11:54:38 tests += LanguageServerProtocolJSONRPCTests.__allTests()
11:54:38 ^
11:54:38 /home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:15:1: error: expressions are not allowed at the top level
11:54:38 tests += LanguageServerProtocolTests.__allTests()
11:54:38 ^
11:54:38 /home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:16:1: error: expressions are not allowed at the top level
11:54:38 tests += SKCoreTests.__allTests()
11:54:38 ^
11:54:38 /home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:17:1: error: expressions are not allowed at the top level
11:54:38 tests += SKSupportTests.__allTests()
11:54:38 ^
11:54:38 /home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:18:1: error: expressions are not allowed at the top level
11:54:38 tests += SKSwiftPMWorkspaceTests.__allTests()
11:54:38 ^
11:54:38 /home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:19:1: error: expressions are not allowed at the top level
11:54:38 tests += SourceKitDTests.__allTests()
11:54:38 ^
11:54:38 /home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:20:1: error: expressions are not allowed at the top level
11:54:38 tests += SourceKitLSPTests.__allTests()
11:54:38 ^
11:54:38 /home/buildnode/jenkins/workspace/swift-package-manager-Linux-smoke-test/branch-main/sourcekit-lsp/Tests/LinuxMain.swift:22:1: error: expressions are not allowed at the top level
11:54:38 XCTMain(tests)
11:54:38 ^

@neonichu
Copy link
Contributor

Not known to me, let's just try another re-run.

@neonichu
Copy link
Contributor

@swift-ci please smoke test linux

@mattt
Copy link
Contributor Author

mattt commented Oct 15, 2020

@swift-ci Please clean smoke test Linux platform

@mattt
Copy link
Contributor Author

mattt commented Oct 15, 2020

@benlangmuir We're getting seemingly unrelated build failures with sourcekit-lsp on Linux smoke tests. [1]. I don't have much to go on, but do you think it has anything to do with swiftlang/swift-integration-tests#70?

@benlangmuir
Copy link
Contributor

No, that integration test issue looks unrelated to me. I can't see any way that sourcekit-lsp would cause this failure - we haven't changed anything about LinuxMain.swift. Instead it looks like swiftpm is incorrectly building LinuxMain.swift as a regular swift file instead of as a main file like it used to.

@benlangmuir
Copy link
Contributor

Looking at the history of https://ci.swift.org/job/swift-package-manager-Linux-smoke-test/ it seems like this failure is caused by this PR, since it's not happening on any other PR tests before or after.

@mattt
Copy link
Contributor Author

mattt commented Oct 15, 2020

@benlangmuir Thanks for clarifying that — I appreciate your help with this. I'm still struggling to understand what about this PR might be affecting how SwiftPM builds LinuxMain, but that helps eliminate a few possibilities.

@mattt
Copy link
Contributor Author

mattt commented Oct 19, 2020

@swift-ci Please smoke test Linux

@mattt mattt force-pushed the packagemodel-module-cleanup branch from 28420cf to b58782f Compare October 19, 2020 19:09
@mattt
Copy link
Contributor Author

mattt commented Oct 19, 2020

@swift-ci please smoke test

@abertelrud
Copy link
Contributor

Thanks for this, @mattt. Using subdirectories for this makes sense to me; I think that initially they weren't used because the codebase was very small, and as it grew, things weren't moved into subdirectories when perhaps they should have.

I haven't seen exactly what's going on here with LinuxMain, but will continue looking to see if I can spot the problem. One thing that comes to mind is if a fileprivate declaration somewhere ended up in a different file from one of its uses, which is now binding to another occurrence of the name rather than failing outright. I don't have any suggestions for specific cases, but that might be something to watch for. @benlangmuir's suggestion about checking the compiler flags for compiling LinuxMain is also good.

@mattt
Copy link
Contributor Author

mattt commented Oct 20, 2020

@abertelrud Thanks for taking a look and offering some advice on resolving the failed build. I think you're onto something with that fileprivate change. Will make a change there and re-run smoke test to see if that resolves the issue.

@mattt mattt force-pushed the packagemodel-module-cleanup branch from 29ead68 to 1231679 Compare October 20, 2020 13:31
@mattt
Copy link
Contributor Author

mattt commented Oct 20, 2020

@swift-ci please smoke test

@mattt
Copy link
Contributor Author

mattt commented Oct 20, 2020

@neonichu @abertelrud FYI: Build is passing now. Thanks for your help and patience reviewing this!

@abertelrud
Copy link
Contributor

abertelrud commented Oct 20, 2020

Woohoo! Thanks for your work on this! The code base will be a lot more approachable after the restructuring.

@abertelrud
Copy link
Contributor

@mattt, it looks as if everything is ready for this one. Do you want me to go ahead and merge it, or do you have other things you want to add?

@mattt
Copy link
Contributor Author

mattt commented Oct 20, 2020

@abertelrud Please go ahead and merge this. Thanks!

@abertelrud abertelrud assigned abertelrud and unassigned neonichu Oct 20, 2020
@abertelrud abertelrud merged commit 2ecc5e8 into swiftlang:main Oct 21, 2020
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.

5 participants