-
Notifications
You must be signed in to change notification settings - Fork 56
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 #244
Conversation
* This is temporary until config cache serialization is fixed when writing tests | ||
* More in https://github.com/gradle/gradle/issues/25898 | ||
*/ | ||
tasks.withType(Test).configureEach { |
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.
This is temporary until gradle/gradle#25898 is addressed
@@ -48,6 +48,9 @@ abstract class GitVersioningIntegrationSpec extends IntegrationSpec { | |||
build/ | |||
gradle.properties'''.stripIndent() | |||
|
|||
// Enable configuration cache :) | |||
new File(projectDir, 'gradle.properties') << '''org.gradle.configuration-cache=true'''.stripIndent() |
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.
This enables config cache for all integration tests
cc294a2
to
08b937a
Compare
08b937a
to
c2edfac
Compare
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.work.DisableCachingByDefault | ||
|
||
@DisableCachingByDefault(because = "Publishing related tasks should not be cacheable") |
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.
💯
src/main/groovy/nebula/plugin/release/git/base/ReleaseTask.groovy
Outdated
Show resolved
Hide resolved
Co-authored-by: OdysseusLives <[email protected]>
ByteArrayOutputStream error = new ByteArrayOutputStream() | ||
List<String> commandLineArgs = ["git", "--git-dir=${rootDir.absolutePath}/.git".toString(), "--work-tree=${rootDir.absolutePath}".toString()] | ||
commandLineArgs.addAll(args) | ||
execOperations.exec { |
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! 🎉
abstract ExecOperations getExecOperations() | ||
|
||
@CompileDynamic | ||
String executeGitCommand(Object ... args) { |
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.
Love how this takes args
* These read only git commands use ValueSource approach for configuration cache | ||
* @see {@link https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes} | ||
*/ | ||
abstract class GitReadCommand implements ValueSource<String, GitCommandParameters> { |
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.
💯 on documenting all these classes for usability and posterity
|
||
/** | ||
* These git commands involve creating or pushing tags | ||
* Because these happen at task execution level, we are fine with not using ValueSource |
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.
Great call-out! Thank you
This should support config cache by following https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes when executing Git
All the integration tests apply the following now:
which will enforce configuration cache during tests across all the specs