How to load public submodules in a private repo?

doug.schmidt's Avatar

doug.schmidt

19 May, 2020 08:32 PM

I have current appveyor build of a private repo which has just added a submodule reference to a public repo.

When the build kicks off and the private repo is cloned, the submodule is not cloned and the build fails.

I added an install command to initialize the submodule

install:  
    - git submodule update --init --recursive
<pre><code>
When the `install` phase runs, my build fails with `fatal: not a git repository (or any of the parent directories): .git`

It appears that appveyor is not fetching the parent repo as a git repo, but instead pulls the ZIP of parent repo from GitHub and extracts the ZIP into the project working folder, without the hidden `.git` subfolder that would allow the submodule command to work.

I am currently working around this by explicitly cloning the submodule into the desired parent path, but that is a problematic hack.

I found [this doc page](https://www.appveyor.com/docs/how-to/private-git-sub-modules/) which describes how to access a *private* submodule reference, but in my scenario, the submodule is a public repo, accessible to all, so no SSH key setup should be required. However, that page also implies the install command as above, which just won&#39;t work without the magic `.git` folder of the parent.

How can submodules be resolved in an appveyor build?

Is my PR build failure because the first PR which includes the submodule has not actually been merged into the parent? (I don&#39;t like merging a failing build, but maybe submodules require a bootstrap?)</code>
</pre>
  1. Support Staff 1 Posted by Feodor Fitsner on 19 May, 2020 08:38 PM

    Feodor Fitsner's Avatar

    Hi Doug,

    Make sure you don't have "shallow clone" enabled.

  2. 2 Posted by doug.schmidt on 19 May, 2020 09:00 PM

    doug.schmidt's Avatar

    Yep, I do have shall clone enabled!

    And I just realized why (having shallow clone meant not having to add an SSH key to access the parent repo, which is private)

    So I will follow the guidance on https://www.appveyor.com/docs/how-to/private-git-sub-modules/ for adding an SSH key via a secure variable, and then disabled shallow clone.

    Thanks

  3. Support Staff 3 Posted by Feodor Fitsner on 20 May, 2020 04:09 PM

    Feodor Fitsner's Avatar

    Or, alternatively, you can authorize AppVeyor to GitHub as "AppVeyor" GitHub App - this way the repo will be cloned via HTTPS, not SSH.

  4. 4 Posted by doug.schmidt on 20 May, 2020 05:12 PM

    doug.schmidt's Avatar

    Thanks Feodor. We are planning to migrate to the AppVeyor GitHub App for authorization tomorrow.

  5. 5 Posted by doug.schmidt on 22 May, 2020 05:30 PM

    doug.schmidt's Avatar

    We made the following changes:
    - switched our authorization mode from the older OAuth to the newer AppVeyor GitHub app - changed the submodule reference from an SSH URL to an HTTPS URL. - disabled shallow clone

    Now the - git submodule update --init --recurserve command in the install: section is working perfectly.

    Thanks for your guidance on this.

  6. Support Staff 6 Posted by Feodor Fitsner on 23 May, 2020 03:43 AM

    Feodor Fitsner's Avatar

    Cool, thanks for the update!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac