Skip to content

Disable Configuration Cache in generated pre-commit Gradle call - #995

Open
pkubowicz wants to merge 1 commit into
JLLeitschuh:mainfrom
pkubowicz:hook-no-conf-cache
Open

Disable Configuration Cache in generated pre-commit Gradle call#995
pkubowicz wants to merge 1 commit into
JLLeitschuh:mainfrom
pkubowicz:hook-no-conf-cache

Conversation

@pkubowicz

Copy link
Copy Markdown

internalKtlintGitFilter is part of the cache key, and it changes with every commit, so getting a cache hit is extremely unlikely.

If you execute the commit hook (in the form before my changes) with Configuration Cache enabled, you will see:

Calculating task graph as configuration cache cannot be reused because the set of Gradle properties has changed: the value of 'internalKtlintGitFilter' was changed.

@JLLeitschuh

Copy link
Copy Markdown
Owner

I'm guessing this is going to fail CI because the PR doesn't update the test testing the the pre-commit script that is generated. Just and FYI.

Thanks for the contribution!

@JLLeitschuh

Copy link
Copy Markdown
Owner

Also, this needs a change log entry please!

@pkubowicz

Copy link
Copy Markdown
Author

I added a change log entry.

I also executed GitHookTasksTest and it passed. From what I see inside the test, it does not check the contents character by character, but rather asserts that certain key words (like the task name) appear. Also, the string --quiet only appears in production code, never in test sources.

@pkubowicz

Copy link
Copy Markdown
Author

Something for the future: instead of relying on -P (which does not work well with configuration cache), git filter can be modeled as a CLI option: https://docs.gradle.org/current/userguide/custom_tasks.html#sec:declaring_and_using_command_line_options

So instead of running:

./gradlew --quiet ktlintCheck -PinternalKtlintGitFilter="my-file"

the call will look like this:

./gradlew --quiet ktlintCheck --git-filter="my-file"

with the default for option not passed being **/*.kts,**/*.kt. This would require moving fun BaseKtLintCheckTask.applyGitFilter() away from GitHook.kt (this does not look like the responsibility of the hook code anyway) and closer to Task.action.

@p00j4

p00j4 commented Feb 9, 2026

Copy link
Copy Markdown

Hi @pkubowicz ,
Thank you for fixing this issue.

Like you indicated, I experienced similar. And yes, now I understand why i'm not getting benefitted from the configuration cache. And so my execution time is hitting 1.2 mins, which is high every push/commit.

Was there any further decision on making it work with the alternate you suggested? --git-filter="my-file" and will it be any faster?

@pkubowicz

Copy link
Copy Markdown
Author

Should I do anything about this PR? I can solve conflicts, but if no one want to merge this, I'll be just wasting my time.

@JLLeitschuh

Copy link
Copy Markdown
Owner

@wakingrufus can you review this quickly when you get a chance. You understand this code better than I do

@JLLeitschuh

Copy link
Copy Markdown
Owner

Should I do anything about this PR? I can solve conflicts, but if no one want to merge this, I'll be just wasting my time.

Thanks for the ping reminding us about this one. Sorry for not getting back to you about this sooner

@wakingrufus

Copy link
Copy Markdown
Collaborator

@wakingrufus can you review this quickly when you get a chance. You understand this code better than I do

I'll take a look. Give me a little time to dig into this one

@vpelikh

vpelikh commented Jun 18, 2026

Copy link
Copy Markdown

Hey @wakingrufus - pinging this PR as an interested bystander. Would you mind giving it a review when you get a chance? We'd love to see this move forward. Thanks!

@JLLeitschuh

Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

@pkubowicz
pkubowicz force-pushed the hook-no-conf-cache branch from 1dabd28 to 0c8fc4d Compare June 18, 2026 19:38
@JLLeitschuh

Copy link
Copy Markdown
Owner

Okay... So copilot doesn't work on pull request from external contributors... Soooo... Conflicts will need to be resolved. Sorry

internalKtlintGitFilter is part of the cache key,
and it changes with every commit, so getting a cache hit
is extremely unlikely.
@pkubowicz
pkubowicz force-pushed the hook-no-conf-cache branch from 0c8fc4d to 8e8d039 Compare June 22, 2026 17:57
@pkubowicz

Copy link
Copy Markdown
Author

I already resolved conflicts and pushed.

@JLLeitschuh

Copy link
Copy Markdown
Owner

Running the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants