-
Notifications
You must be signed in to change notification settings - Fork 29
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
✨ Get staging profile task #62
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really informative PR description, thanks!
I went through the code and in general I like it. Chaining tasks makes sense, but there is one side effect related to logging. I put some remarks inline.
I also requested e2e tests on your PR.
src/main/kotlin/io/github/gradlenexus/publishplugin/GetStagingProfile.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/io/github/gradlenexus/publishplugin/GetStagingProfile.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/io/github/gradlenexus/publishplugin/GetStagingProfile.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/io/github/gradlenexus/publishplugin/GetStagingProfile.kt
Outdated
Show resolved
Hide resolved
src/compatTest/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPluginTests.kt
Outdated
Show resolved
Hide resolved
src/compatTest/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPluginTests.kt
Outdated
Show resolved
Hide resolved
src/compatTest/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPluginTests.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPlugin.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPlugin.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/io/github/gradlenexus/publishplugin/GetStagingProfile.kt
Outdated
Show resolved
Hide resolved
src/compatTest/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPluginTests.kt
Outdated
Show resolved
Hide resolved
src/compatTest/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPluginTests.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/io/github/gradlenexus/publishplugin/GetStagingProfile.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/io/github/gradlenexus/publishplugin/GetStagingProfile.kt
Outdated
Show resolved
Hide resolved
src/compatTest/kotlin/io/github/gradlenexus/publishplugin/NexusPublishPluginTests.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we use the new task to retrieve the staging profile id for the initialize task?
/** | ||
* Diagnostic task for retrieving the [NexusRepository.stagingProfileId] for the [packageGroup] from the provided [NexusRepository] and logging it | ||
*/ | ||
@Incubating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@szpak Not sure if we should use this annotation. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I like to use @Incubating
for the new tasks/features to gather feedback and possibly have a clear way to fix spotted issues even in a non-backward compatible way in the following release. However, you don't like the "beta" status of that feature or just a Gradle annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fine with me but we should have some common understanding when to do this. IIUC you'd like to do this for all new features. Is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be safe, but maybe it would be to defensive, as we - in general - do not expose API to others (at least, it is not the main goal of that extension). How does it look like in JUnit? Are you satisfied with the strategy adopted there?
@marcphilipp I asked the PR's author about that a comment earlier - see my reasoning. It simplifies the general construction and we eventually still use the common logic from the client. |
/** | ||
* Diagnostic task for retrieving the [NexusRepository.stagingProfileId] for the [packageGroup] from the provided [NexusRepository] and logging it | ||
*/ | ||
@Incubating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fine with me but we should have some common understanding when to do this. IIUC you'd like to do this for all new features. Is that correct?
src/compatTest/kotlin/io/github/gradlenexus/publishplugin/MethodScopeWiremockResolver.kt
Outdated
Show resolved
Hide resolved
5938dd5
to
e7c9e69
Compare
* helper method for get getting a [ExtensionContext.Store] specific to a test method | ||
*/ | ||
private fun getStore(context: ExtensionContext): ExtensionContext.Store { | ||
return context.getStore(ExtensionContext.Namespace.create(javaClass, context.requiredTestMethod)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to add the test method to the namespace since the extension context is already scoped to the method level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I couldn't remember the rules around this so I went looking in the user guide and derived it from this example: https://junit.org/junit5/docs/current/user-guide/#extensions-lifecycle-callbacks-before-after-execution - but fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! That example should indeed be simplified.
…allows the creation of new WireMockServers scoped to a specific test method
a8bf194
to
df6cd66
Compare
Thanks @ryandens for your PR (and patience ;-) ). It will be a part of 1.1.0. |
Awesome, thanks for accepting my contribution and working through the feedback with me! Hoping this makes it easier for other folks to adopt this plugin 😄 |
Closes #60
Documentation Updates
I think we should add an update to the "Tasks" section of the migration guide to say something like
↓
This reflects the main difference between the previous plugin project and this one: tasks are on a per
NexusRepsitory
basis, including theRetrieveStagingProfile
task.Summary of changes
First adds a new
AbstractNexusStagingRepositoryTask
subclass calledRetrieveStagingProfile
. we register a newRetrieveStagingProfile
task for eachNexusRepository
registered in the plugin's extension. This enables users to run./gradlew retrieve<NEXUS_REPOSITORY_NAME>StagingProfile
and see the staging profile ID for the repository in stdout.This was initially as far as I was planning on going with this, but something @szpak mentioned in issue #60 caught my attentionAfter reading this, it struck me that we wouldn't want there to be inconsistencies between howGetStagingProfile
gets the staging profile and howInitializeNexusStagingRepository
gets the staging profile. So, I went about a small refactor of the plugin to remove the responsibility of figuring out the staging profile id fromInitializeNexusStagingRepository
and instead make it a required input. Then, I configuredInitializeNexusStagingRepository
to depend on theGetStagingProfile
which now has all the logic for getting the staging profile ID, outputting it to stdout, storing the ID in a file in the build directory, and managing the optimization of not doing the API lookup if the staging profile id is provided via configuration.This not only has benefits for code re-use, but it also helps those who don't configure the stagingProfileId ever. Since we output the staging profile ID to an artifact, it can be cached and reused on subsequent builds which decreases the configuration burden on the user while still giving them access to this performance optimization.I know changingInitializeNexusStagingRepository
was not technically in the scope of what was discussed in #60 so if you would like me to remove it from the scope of this change I'd be happy to. But, it seemed to me like refactoringInitializeNexusStagingRepository
was the responsible thing to do as I was introducing some logic duplication around how this plugin gets the staging profile id.Update on 2/27/21: After discussion, it was deemed that this refactor was problematic due to the conflicting nature of the different use cases of the
InitializeNexusStagingRepository
task and the diagnostic task to retrieve the staging profilePossible other tasks
Another thought that occurred to me was adding a task called
getStagingProfiles
orgetAllStagingProfiles
which is simply an alias for executingget<NEXUS_REPOSITORY_NAME>StagingProfile
on each configuredNexusRepository
. I ultimately decided it was not worthwhile/might cause confusion but I'm willing to reconsider.Testing gaps?
After writing up this pull request description, I realized my implementation for storing the staging repository ID was flawed, as I at first would overwrite the file storing the staging profile ID every time a new
GetStagingProfile
was run, which could lead to confusing results with multipleNexusRepository
destinations. The existing tests didn't catch it because there were no tests that published to two different repositories at the same time. I had to make some tweaks to the helper methods to accomplish this test, but I'm super open to feedback on how this was tested. Perhaps it would be better as a unit test than a compatTest?