Ignore certain submodules on clone (Updating/initializing)
Description
Currently for submodules there are two basic ways gitlab runner supports submodules as per documentation (https://docs.gitlab.com/ee/ci/git_submodules.html#using-git-submodules-in-your-ci-jobs, https://docs.gitlab.com/ee/ci/runners/README.html#git-submodule-strategy):
- simply ignore them and don't check them out (
GIT_SUBMODULE_STRATEGY: none
) - check out submodules (
GIT_SUBMODULE_STRATEGY: normal
andGIT_SUBMODULE_STRATEGY: recursive
)
I feel like there's other use cases not properly adressed by this all-or-nothing approach.
Submodules can be used for code sharing. Checking them out is a pretty lean and fast operation since after all it's just text files. The recursive
strategy fits this very well and you just get all the code since it's fast enough even for 20 submodules.
But another use case is binary sharing. You might at the same time have binaries included as submodules that aren't required by all build-jobs. Always checking them out as well because you need to other code sharing submodules can cause quite the overhead.
I know there are other ways to achieve this or work around the problem e.g. through manual scripting, achieving a speed up through some caching magic or not bothering with binaries in git at all. However I still see the use case of sharing binaries via submodules. For example if you have regulations forcing you to not only version code but also specific build environments submodules are a really effecient and effective solution.
Proposal
I would like to have an additional submodule option:
select which submodules should be ignored. I could see this be done through a new variable behaving similar to .gitignore
.
GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_IGNORE: /toolchain/*
It would then recurse all submodules except the ones matching toolchain
. Maybe this could also be extended to git cloning behavior in general. (I only found shallow cloning and caching which somehwat goes in the direction.)
Links to related issues and merge requests / references
I haven't found issues regarding submodules that fit this proposal.