I have a skaffold + jib + jib-maven-plugin setup that I use for development.
I run skaffold dev and it builds the project, container image and deploys to my local k8s cluster. Whenever I touch the source code it rebuilds and redeploys containers. The rebuilds trigger maven goals to compile & run unit tests.
This works fine, but is a bit slow since maven recompiles all sources everytime sth changes so I thought I'd give gradle setup a shot and test its incremental compilation capabilities for my project.
It works great, but there's one thing I am bit confused about, that is that jib gradle plugin seems not to be running the test tasks for my sources at all.
$> gradle jibDockerBuild --dry-run
:my-module:generateMainEffectiveLombokConfig1 SKIPPED
:my-module:compileJava SKIPPED
:my-module:processResources SKIPPED
:my-module:classes SKIPPED
:my-module:jibDockerBuild SKIPPED
If I run gradle build the tests tasks are triggered:
$> gradle build --dry-run
:my-module:generateMainEffectiveLombokConfig1 SKIPPED
:my-module:compileJava SKIPPED
:my-module:processResources SKIPPED
:my-module:classes SKIPPED
:my-module:jar SKIPPED
:my-module:assemble SKIPPED
:my-module:generateTestEffectiveLombokConfig1 SKIPPED
:my-module:compileTestJava SKIPPED
:my-module:processTestResources SKIPPED
:my-module:testClasses SKIPPED
:my-module:test SKIPPED
:my-module:check SKIPPED
:my-module:build SKIPPED
I trawled through jib and skaffold documentation and github issues, but I couldn't find anything related to running unit tests as part of the container image creation using jib.
I would think that running unit tests should be mandatory part of building an image and that either gradle jibDockerBuild would run it implicitly just like gradle build does or that skaffold via its integration with jib would somehow trigger those by perhaps running gradle test before jibDockerBuild, but it seems not to be the case.
So the question is how do I make sure my unit tests run when using skaffold with jib and gradle and what's the reason why it doesn't happen automatically....