Skip to content

improve dependency resolution diagnostics when resolving non-versioned dependencies #4030

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 4 commits into from
Jan 18, 2022

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Jan 14, 2022

motivation: when resolving graphs with non-versioned depedendencies (such as branch dependencies), the dependencies get "flattened" onto the root node which looses the original association with the dependency's parent yielding incorrect diagnostics

changes:

  • more accuretly track the underlying dependency when computing root dependencies from non-versioned depedendencie
  • peek into the "real" cause when producing depedency based diagnostics for the root node
  • TBD: use top level package as root instead of synthesized root when appropriate
  • add a bunch of tests

rdar://87486528
rdar://64226666

@tomerd
Copy link
Contributor Author

tomerd commented Jan 14, 2022

@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 Jan 14, 2022
@tomerd
Copy link
Contributor Author

tomerd commented Jan 15, 2022

ci infra issues causing build timeout?

@tomerd
Copy link
Contributor Author

tomerd commented Jan 15, 2022

@swift-ci please smoke test

@tomerd tomerd added WIP Work in progress and removed ready Author believes the PR is ready to be merged & any feedback has been addressed labels Jan 15, 2022
@tomerd tomerd changed the title improve dependency resolution diagnostics when resolving non-versioned dependencies [wip] improve dependency resolution diagnostics when resolving non-versioned dependencies Jan 15, 2022
@tomerd
Copy link
Contributor Author

tomerd commented Jan 15, 2022

@swift-ci please smoke test

@tomerd tomerd changed the title [wip] improve dependency resolution diagnostics when resolving non-versioned dependencies improve dependency resolution diagnostics when resolving non-versioned dependencies Jan 15, 2022
@tomerd tomerd added ready Author believes the PR is ready to be merged & any feedback has been addressed and removed WIP Work in progress labels Jan 15, 2022
@tomerd tomerd self-assigned this Jan 15, 2022
@tomerd
Copy link
Contributor Author

tomerd commented Jan 15, 2022

@swift-ci please test package compatibility

// FIXME: This is duplicated and wrong.
private func isFailure(_ incompatibility: Incompatibility) -> Bool {
return incompatibility.terms.count == 1 && incompatibility.terms.first?.node.package.identity == .plain("<synthesized-root>")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unrelated cleanup

@tomerd
Copy link
Contributor Author

tomerd commented Jan 16, 2022

not able to reproduce the package compatibility failures reported, could be from a different cause

@tomerd
Copy link
Contributor Author

tomerd commented Jan 17, 2022

package compatibility failures: swiftlang/swift#40877

@tomerd
Copy link
Contributor Author

tomerd commented Jan 17, 2022

@swift-ci please test package compatibility

identity: .plain("<synthesized-root>"),
path: .root
))
// 👀 is this the right thing to do?
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like an improvement for now, especially for CLI. For IDEs such as Xcode, where there can be multiple roots and also package dependencies that don't come from packages, I think we'll want to add more information to PackageGraphRootInput that can be used in diagnostics. That should be easy for the IDE to provide and would let you know where the "root pointers" into the package graph are (either a set of root packages or some other external dependency on a package, such as from an iOS app Xcode target to a package). That could of course be done in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also discussed with @neonichu and we agreed this is an improvement

// Some of these might be overridden as we discover local and branch-based references.
var versionBasedDependencies: [DependencyResolutionNode: [VersionBasedConstraint]] = [:]
var versionBasedDependencies = OrderedDictionary<DependencyResolutionNode, [VersionBasedConstraint]>()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think switching to ordered collections is great where it makes sense — it will often help understandability if we can make the order of diagnostics stable from run to run, and also, when there's no better order, to show entities in the same order that users specify them (not always possible of course, but sometimes it is).

…d depedendencies

motivation:  when resolving graphs with non-versioned depedendencies (such as branch dependencies), the dependencies get "flattened" onto the root node which looses the original association with the dependency's parent yielding incorrect diagnostics

changes:
* more accuretly track the underlying dependency when computing root dependencies from non-versioned depedendencie
* peek into the "real" cause when producing depedency based diagnostics for the root node
* add a bunch of tests

rdar://87486528
@tomerd
Copy link
Contributor Author

tomerd commented Jan 18, 2022

@swift-ci please smoke test

}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

error handling cleanup ^^

@tomerd tomerd merged commit 6b18ebf into swiftlang:main Jan 18, 2022
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