Skip to content

integrate registry dependencies into dependency resolution #3873

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 5 commits into from
Nov 18, 2021

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Nov 17, 2021

motivation: support registries

changes:

  • create RegistryPackageContainer to handle dependencies from registry, integrated with the previously introduces registry client
  • update workspace to create RegistryPackageContainer when dealing with registry dependencies
  • update registry client (RegitryManager) to perform download request (buffered) when downloading the package archive
  • update registry client manifest listing and handling so it supportes multi-manifest setups. simplified the client to return the manifest content instead of attempting to load it which is done in RegistryPackageContainer which has additional context
  • update registry client to use Codable
  • add testing infrastructure to MockWorkspace to mock registry dependencies
  • add basic tests for registry scenarios

XCTAssertMatch(workspace.delegate.events, ["did load manifest for remoteSourceControl package: http://localhost/org/bar"])
}

func testBasicResolutionFromRegistry() throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🥳

@tomerd
Copy link
Contributor Author

tomerd commented Nov 17, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Nov 17, 2021

@yim-lee note changes to RegistryClient (previously RegistryManager). one important change is the client no longer assume the server buffers the content of the package in the response, and instead supports steaming. this is something we should check in the compatibility tests suite if we have not already

}

// <http://packages.example.com/mona/LinkedList/1.1.1/Package.swift?swift-version=4>; rel="alternate"; filename="[email protected]"; swift-tools-version="4.0",
func parseLinkLine(_ value: String) throws -> ManifestLink? {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is kinda terrible, open to better ideas

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move all this into an HTTPHeader extension

@tomerd
Copy link
Contributor Author

tomerd commented Nov 17, 2021

@swift-ci please smoke test

@tomerd tomerd added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Nov 17, 2021
@tomerd tomerd force-pushed the feature/registry-02 branch from 6aecf95 to fba8248 Compare November 18, 2021 00:27
@tomerd
Copy link
Contributor Author

tomerd commented Nov 18, 2021

@swift-ci please smoke test

guard let url = URL(string: self.url),
url.scheme == "https"
else {
guard let url = URL(string: self.url), url.scheme == "https" else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Safer to do case-insensitive compare

@@ -65,14 +65,14 @@ public struct PackageIdentity: CustomStringConvertible {
}

// TODO: formalize package registry identifier
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR: is this done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would need to take another look. will address in follow up PR of needs more attention, it works fine for the test cases I ran

}

// <http://packages.example.com/mona/LinkedList/1.1.1/Package.swift?swift-version=4>; rel="alternate"; filename="[email protected]"; swift-tools-version="4.0",
func parseLinkLine(_ value: String) throws -> ManifestLink? {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move all this into an HTTPHeader extension

public var id: String
public var version: String
public var resources: [Resource]
public var metadata: AdditionalMetadata
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was assuming we would need this, see #3873 (comment)

// MARK: - Serialization

extension RegistryClient {
public enum Serialization {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure expanding a few lines of JSON processing code into JSON models is necessary. I don't think we care about most of the contents. e.g., we only care if a release has problem and don't care what the actual problem is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up with needing these for the test infrastructure which mimics the server, so instead of doing it only there I reused on both ends

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

motivation: support registries

changes:
* create RegistryPackageContainer to handle dependencies from registry, integrated with the previously introduces registry client
* update workspace to create RegistryPackageContainer when dealing with registry dependencies
* update registry client (RegitryManager) to perform download request (buffered) when downloading the package archive
* update registry client manifest listing and handling so it supportes multi-manifest setups. simplified the client to return the manifest content instead of attempting to load it which is done in RegistryPackageContainer which has additional context
* update registry client to use Codable
* add testing infrastructure to MockWorkspace to mock registry dependencies
* add basic tests for regsitry scenarios
@tomerd tomerd force-pushed the feature/registry-02 branch from fba8248 to ce1bf91 Compare November 18, 2021 06:33
@tomerd
Copy link
Contributor Author

tomerd commented Nov 18, 2021

@swift-ci please smoke test

@tomerd tomerd merged commit c313dea into swiftlang:main Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants