How to ensure that cache warm-up job(s) run before regular ones if jobs run in parallel?

If building dependencies takes too long for Travis job timeout, suggests making a “starter” job that builds just them, while others use its cached results.

However, Travis jobs run concurrently. How do I ensure that other jobs run after the “warm-up” job?

There don’t seem to be any features to mark job interdependencies or anything. The example is using some feature that seems to be specific to bundler for that.

Moreover, a project I have in mind may require multiple cache warm-ups 'cuz the net time for building all dependencies is currently about 50 minutes – so the build is going to be not 2- but 3-stage – which is something the example doesn’t cover.

Limiting concurrent jobs to one is not an option because there are many jobs, so the build will be complete faster if I instead write logic that terminates the build if it takes too long and continues from cache after I restart the build in Travis UI.

We employ the mechanism of build stages. We then have one stage “dependencies” and one called “build”, see for example here.

Note however, that the build jobs only start when all dependency jobs have finished…

(Of course you can chain this for more than two stages, you “just” have to decompose your build into multiple steps that each take less than 50 minutes).

1 Like