Skip to content

refactor managed dependencies #3698

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 1 commit into from
Sep 29, 2021

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Aug 31, 2021

motivation: ManagedDependencies are based on location instead of on identity, refactor them to be based on identity as part of the transition to identity based logic

changes:

  • transition ManagedDependencies underlying hashmap to be based on identity
  • update the ManagedDependencies edit state to include the "basedOn" property which is only relevant to that state
  • update calls ites to use package identity instead of location when reading/writing managed depedencies
  • refactor related call-sites to handle edited state more safely and correctly
  • add code comments to explain some of the more subtle business logic
  • adjust tests where needed

rdar://82954076

@tomerd
Copy link
Contributor Author

tomerd commented Aug 31, 2021

needs #3696 first

@tomerd tomerd force-pushed the refactor/managed-depedencies branch from 615bd43 to f1c22db Compare September 1, 2021 00:45
@tomerd
Copy link
Contributor Author

tomerd commented Sep 1, 2021

@swift-ci please smoke test

@tomerd tomerd force-pushed the refactor/managed-depedencies branch from f1c22db to 99d23a6 Compare September 1, 2021 00:49
@tomerd tomerd added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Sep 1, 2021
@tomerd
Copy link
Contributor Author

tomerd commented Sep 1, 2021

@swift-ci please smoke test

@tomerd tomerd force-pushed the refactor/managed-depedencies branch from 99d23a6 to 53e43db Compare September 1, 2021 01:31
@tomerd
Copy link
Contributor Author

tomerd commented Sep 1, 2021

@swift-ci please smoke test

} else {
currentDependency = nil
}
let currentDependency = self.state.dependencies[packageRef.identity]
Copy link
Contributor Author

@tomerd tomerd Sep 1, 2021

Choose a reason for hiding this comment

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

👀 plz help make sure the logic here hasn't regressed

@tomerd tomerd force-pushed the refactor/managed-depedencies branch 5 times, most recently from 3386076 to adb61b3 Compare September 1, 2021 04:32
@tomerd
Copy link
Contributor Author

tomerd commented Sep 1, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Sep 2, 2021

@swift-ci please test package compatibility

@tomerd
Copy link
Contributor Author

tomerd commented Sep 2, 2021

@abertelrud @neonichu @shahmishal I looked at the package compatibility test and Kitura 5.1 is now failing due to an improved validation that we introduced in #3687 (which is already merged, so not this PR)

'Kitura-net' /private/tmp/Kitura/.build/checkouts/Kitura-net: error: 'kitura-net' dependency on 'https://github.com/Kitura/LoggerAPI.git' conflicts with dependency on 'https://github.com/IBM-Swift/LoggerAPI.git' which has the same identity 'loggerapi'
'KituraContracts' /private/tmp/Kitura/.build/checkouts/KituraContracts: error: 'kituracontracts' dependency on 'https://github.com/Kitura/LoggerAPI.git' conflicts with dependency on 'https://github.com/IBM-Swift/LoggerAPI.git' which has the same identity 'loggerapi'

the question is what the best strategy here, since the new validation find an issue with the existing code which used to "work" but was never valid and can lead to undefined behavior. should we remove the version of kitura from the compatibility suite until its fixed there, or do you have a better way?

@tomerd
Copy link
Contributor Author

tomerd commented Sep 8, 2021

@swift-ci please test package compatibility

@abertelrud
Copy link
Contributor

@abertelrud @neonichu @shahmishal I looked at the package compatibility test and Kitura 5.1 is now failing due to an improved validation that we introduced in #3687 (which is already merged, so not this PR)

'Kitura-net' /private/tmp/Kitura/.build/checkouts/Kitura-net: error: 'kitura-net' dependency on 'https://github.com/Kitura/LoggerAPI.git' conflicts with dependency on 'https://github.com/IBM-Swift/LoggerAPI.git' which has the same identity 'loggerapi'
'KituraContracts' /private/tmp/Kitura/.build/checkouts/KituraContracts: error: 'kituracontracts' dependency on 'https://github.com/Kitura/LoggerAPI.git' conflicts with dependency on 'https://github.com/IBM-Swift/LoggerAPI.git' which has the same identity 'loggerapi'

the question is what the best strategy here, since the new validation find an issue with the existing code which used to "work" but was never valid and can lead to undefined behavior. should we remove the version of kitura from the compatibility suite until its fixed there, or do you have a better way?

Seems similar to a marking a unit test as failing for external reason, except at a whole-package level. Could we let them know about the problem, disable Kitura, and then reenable it when they have a version that fixes the problem?

@tomerd
Copy link
Contributor Author

tomerd commented Sep 8, 2021

Seems similar to a marking a unit test as failing for external reason, except at a whole-package level. Could we let them know about the problem, disable Kitura, and then reenable it when they have a version that fixes the problem?

I relaxed the error to warning for now which means the test suite passes. once we escalate to an error again (next major release) we will see if they fixed it already or we need to ask them to do so

@tomerd tomerd self-assigned this Sep 9, 2021
@tomerd tomerd removed the ready Author believes the PR is ready to be merged & any feedback has been addressed label Sep 10, 2021
@tomerd
Copy link
Contributor Author

tomerd commented Sep 25, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Sep 25, 2021

@swift-ci please test package compatibility

@tomerd
Copy link
Contributor Author

tomerd commented Sep 25, 2021

@mattt this should be in a bit of a better shape now. can you test to see if it works for you?

@tomerd tomerd added ready Author believes the PR is ready to be merged & any feedback has been addressed and removed DO NOT MERGE labels Sep 26, 2021
@mattt
Copy link
Contributor

mattt commented Sep 27, 2021

@swift-ci please smoke test

@tomerd tomerd force-pushed the refactor/managed-depedencies branch from 4adf6f8 to de10175 Compare September 27, 2021 18:27
@tomerd
Copy link
Contributor Author

tomerd commented Sep 27, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Sep 27, 2021

@mattt did you add commits here that I mistakingly override?

@tomerd
Copy link
Contributor Author

tomerd commented Sep 27, 2021

@swift-ci please test package compatibility

@mattt
Copy link
Contributor

mattt commented Sep 27, 2021

@mattt did you add commits here that I mistakingly override?

I applied the typo fix suggestion from my original PR review earlier this morning (lbashedOn -> lbasedOn), which appears to have been lost with the force push. But that's no big deal. The commit ref is 4adf6f8 if you'd like to cherry pick that.

$ curl https://github.com/apple/swift-package-manager/commit/4adf6f87568bbd8cc5c80bfa29bd75ea1a1adc0c.patch | git am

@tomerd
Copy link
Contributor Author

tomerd commented Sep 27, 2021

@abertelrud @neonichu ptal so we can merge this

return ManagedDependency(
packageRef: packageRef,
state: .local,
// FIXME: This is just a fake entry, we should fix it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that for a later PR, or a FIXME for a future update of this one?

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 FIXME was there before, so not a new thing

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 do think we should fix this, but it was not in scope for this PR

/// If the path is non-nil, the dependency is managed by a user and is
/// located at the path. In other words, this dependency is being used
/// for top of the tree style development.
case edited(basedOn: ManagedDependency?, unmanagedPath: AbsolutePath?)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it an error state for the basedOn to be nil here? Just asking for my understanding...

Copy link
Contributor Author

@tomerd tomerd Sep 28, 2021

Choose a reason for hiding this comment

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

big picture, the whole "edited" feature needs to go away.

specifically, the basedOn can be nil in some situation unfortunately - tired to make it required but the logic still requires it

Copy link
Contributor

Choose a reason for hiding this comment

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

Yah, I think once we have explicit overrides, we can get rid of edit mode and therefore the entirety of managed dependencies.

motivation: ManagedDependencies are based on location instead of on identity, refactor them to be based on identity as part of the transition to identity based logic

changes:
* transition ManagedDependencies underlying hashmap to be based on identity
* update the ManagedDependencies edit state to include the "basedOn" property which is only relevant to that state
* update calls ites to use package identity instead of location when reading/writing managed depedencies
* refactor related call-sites to handle edited state more safely and correctly
* add code comments to explain some of the more subtle business logic
* adjust tests where needed
@tomerd tomerd force-pushed the refactor/managed-depedencies branch from de10175 to 3e343ce Compare September 29, 2021 01:05
@tomerd
Copy link
Contributor Author

tomerd commented Sep 29, 2021

@swift-ci please smoke test

@tomerd
Copy link
Contributor Author

tomerd commented Sep 29, 2021

@swift-ci please test package compatibility

@tomerd tomerd merged commit 3d48f94 into swiftlang:main Sep 29, 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.

4 participants