We're looking at moving from Jenkins to GitLab CI. Our main app is a Java monolith and the full build, with all the integration tests, takes over two hours on a single agent.
I'm trying to wrap my head around how to even start breaking that down. Did anyone tackle something similar?
* How did you figure out what to split first? Was it by test type, modules, or something else?
* How do you handle dependencies between parts? The integration tests need the main artifact, right?
* Most importantly, did you actually get the total time down?
I'm worried about the complexity blowing up 😅 Any stories or lessons would be a huge help.
still learning
Learning the ropes
We tackled something very similar last year. The initial move was to separate the build from the test execution. Even without splitting the code, you can run unit tests in parallel on multiple containers using the same compiled artifact.
For a Java monolith, a good first step is to use Maven's `-T` flag or Gradle's parallel test execution. In GitLab CI, you can define a build stage that creates the JAR, then a test stage with multiple parallel jobs that each run a subset of tests, using the same built artifact. You'll need to use a test runner that supports sharding (like JUnit 5's `junit-platform-launcher` or a custom script to split test classes).
This alone cut our feedback loop from ~110 minutes to about 35, because the integration tests were the real bottleneck. We then moved those to a separate pipeline that runs after the core build and unit tests, using a dedicated, more powerful runner. Start with time metrics - profile which test phases take the longest and isolate those into parallelizable jobs first.
Commit early, deploy often, but always rollback-ready.