I'm currently trying to optimise CI builds for a server-side application on Gitlab CI.
In a first stage, we're trying to compile the Swift project with swift build --build-tests
The resulting .build
folder is cached for the next stage, where we run swift test
What I would expect
In the swift test
stage, we don't need to recompile anything.
What happens instead
Some of the code is recompiled for some reason, but apparently not everything.
I've created a sample project on Gitlab to showcase the issue. The behaviour can be observed by looking at the pipeline execution. (note: gitlab CI actually calls the "cache" between different stages "artifacts".)
I have in the past observed similar behaviour in docker containers where some code was being rebuilt even though the swift build
step had been cached.
I don't understand why this happens. I could understand that things need to recompiled when the host machine changes, but given that everything is executed in a docker environment, the architecture etc. should be the same? Can anybody shed some light on this?