Google Cloud Functions not pulling in git submodules

Viewed 418

I'm using a Cloud Source Repo for my Cloud Function which is connected to an external GitHub repo. The github repo has a submodule.

When my cloud function runs (Python), I get import errors when trying to import files from said submodule.

It the same errors I get if I do: git clone <repo> And then try to run my python script instead of: git clone --recurse-submodules <repo>

AFAICT, it seems like Cloud Functions isn't pulling in my submodules. I've tried making the submodule point directly to a mirror repo in Cloud Source Repository - but to no effect.

Any idea how to get submodules working correctly with Cloud Functions?

1 Answers

Git submodules don't appear to work with Cloud Functions as of 3/2020 (even when the submodule is a public repo, it isn't pulled in) and has problems elsewhere in GCP (e.g. Cloud Build).

git-subrepo is an effective alternative which directly embeds the sub-repo into your main repo - so git clone pulls all the code (including the sub-repo) without need to pass --recurse-submodules.

git submodules appear to be pretty well-hated on the net for their complexity. Sub-repos by comparison aren't perfect either, but are simple and work.

https://github.com/ingydotnet/git-subrepo

Related