-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support configuration cache #206
Support configuration cache #206
Conversation
I already found one case where it doesn't work correctly, so a fix should be added soon (hopefully next Monday). |
50faf28
to
3104d68
Compare
The fix has been pushed - bufTool configuration creation before task creation. |
Thanks for all the work in this contribution! Is the I think requiring users to declare that dependency is a non-starter - we should try as hard as we can not to require users to do any task dependency declarations like that. |
Thanks for quick reaction. After a few days of usage of this "modified" plugin version, I think I understand the traps and problems a bit more.
In the new version, the inputs/outputs are declared, so the buf is only executed if the inputs change. So for example
Now we come to the fact that buf tool itself is not very compatible with gradle way of organizing repositories. The standard gradle way is to have two directories in the module - |
Thanks for the detailed explanation. I guess phrased differently my question is: what is it about this change that makes the plugin now depend on |
Let me reply shortly this time. There is nothing that makes this plugin depend on |
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.
Sorry for the delay here. @drice-buf for visibility.
Ok, I think I see what you're saying - where previously there was some awkwardness, you've now arrived at a place where there is no complexity imparted upon the user of the plugin to support the configuration cache. That's great news, and I think it is a Pareto improvement so long as there are few edge cases you haven't considered. To be honest, the Gradle configuration cache is an area I know little about (perhaps this is obvious), so bear with me as I try to get up to speed on this PR.
...rces/GenerateTest/buf_generate_fails_with_a_nonexistent_specified_template_file/build.gradle
Outdated
Show resolved
Hide resolved
@@ -70,6 +70,7 @@ abstract class AbstractBufIntegrationTest : IntegrationTest { | |||
"-PprotobufVersion=3.23.4", | |||
"-PkotlinVersion=1.7.20", | |||
"-PandroidGradleVersion=7.3.0", | |||
"--configuration-cache", |
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.
Nice dogfooding.
...eTest/buf_generate_fails_with_both_default_and_specified_buf_gen_template_files/build.gradle
Show resolved
Hide resolved
// this is just an @Input, not @InputDirectory | ||
// this property is used only for relativization of paths, the task doesn't depend on the content | ||
@get:Input | ||
abstract val projectDir: Property<File> |
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.
Is there any way to restrict the visibility of all of these properties on the various task classes? I'd rather them not become part of the plugin's public API.
Also, while it's fresh, I think we should get proper KDoc on each property (even if we can make them internal). I'll never remember what they are a year from now...
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.
Added a few kdocs, although their usefulness is a bit low.
Not sure about the way to hide the inputs/outputs - kotlin internal doesn't work, Internal annotation in gradle has different meaning and semantics.
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 an @Internal
Gradle annotation - I wonder what that does.
Ah just read your last sentence more carefully. It doesn't hide the element? I thought I saw something like that before.
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.
What goes wrong with Kotlin internal
? I can add it to all of the abstract val
s locally and the tests run just fine.
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.
although their usefulness is a bit low.
I happen to think the nontrivial ones (and even some of the simpler ones) will be helpful and establish good practice. Thanks for adding them!
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.
The issue with kotlin internal
is that I cannot put that on parent classes (AbstractBufExecTask
, AbstractBufTask
) - I don't know exactly why. Putting it just on the concrete classes seems very inconsistent.
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.
That's exactly what I tried and it worked. What happens when you try?
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.
When I change AbstractBufTask.projectDir
to internal, the test fail on
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':publishBufImagePublicationPublicationToMavenRepository'.
> Could not create task ':bufBuild'.
> 'org.gradle.api.provider.Property build.buf.gradle.AbstractBufTask.getProjectDir()'
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.
How strange - they pass for me. What could be happening? I'm running OpenJDK Runtime Environment Corretto-11.0.18.10.1 (build 11.0.18+10-LTS)
.
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, found the issue. It is broken this way if I don't run gradle clean
after adding the internal modifier. That's quite strange, but anyway, it's not a blocker for changing it to internal. I'll prepare an extra commit that internalizes all new input/output properties.
a6893b0
to
17b6b1d
Compare
17b6b1d
to
c26a521
Compare
Looks good to me, but a single test is failing on Windows. |
Is there a way to see which test / how it failed? |
CI used to publish the results to the actions summary and it looks like that broke at some point during maintenance. I would try using Gradle test logging events? |
Ok, the failing test is |
@sebek64 I've done my best to merge in the main branch here but there's some semantic conflicts with Buf's v2 configurations. I'm pausing here but feel free to step in or I'll come back later. |
I have already a rebase in progress locally, but I wasn't able to finish it yet. I'll come back to it next week. |
Ok, feel free to ditch my commits if you want. |
…matically by gradle
e05b66b
to
c83739a
Compare
Rebased & adapted to changes. Also merged the commits added during previous reviews into correct commits. |
Looks like the failure in the Windows test is related to rate limiting:
@pkwarren @drice-buf any ideas on the best way to go about fixing this? |
To avoid rate limits w/ code generation, clients need to be authenticated with the BSR. Alternatively, we could switch to using local generation for the tests instead of relying on remote generation. Looking at how we might do the latter. |
It's probably overkill to exercise remote generation in tests - not a bad idea to see if we can do it locally. |
Opened #230 to switch the tests over to local generation. |
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.
Marvelous.
Support configuration cache.
This is the current standard for plugins. It makes the builds faster by supporting heavy parallelism in builds, and slow whenever a non-compliant plugin is part of the build.
I tried carefully to set all inputs / outputs of tasks. It is however quite hard to handle all imaginable cases.
The commits should be small and reviewable. If anything is not clear from the commits, I'm ready to explain.