jdoiro3 / mkdocs-multirepo-plugin

Build documentation in multiple repos into one site.
MIT License
128 stars 47 forks source link

Unable to build multirepo docs for Gitlab Pages #133

Open alexeych0 opened 10 months ago

alexeych0 commented 10 months ago

I'm using multirepo plugin with nav_repos config:

mkdocs.yml:

- multirepo:
    cleanup: false
    nav_repos:
        -
            name: developers-docs
            import_url: https://my.gitlab.com/project-online/developers-doc?edit_uri=edit/master
            imports:
                - 'docs/contracts/api.md'

Everything works fine, when I run mkdocs serve / mkdocs build locally. However, when building the docs from Gitlab CI job, I'm facing the issue that remote repositories are cloned only when the documentation already has been built. As a result, the output directory site doesn't have the imported repos, causing 404 errors.

Here's the example:

$ mkdocs build
INFO    -  DeprecationWarning: warning_filter doesn't do anything since MkDocs 1.2 and will be removed soon. All messages on the `mkdocs` logger get counted automatically.
  File "/usr/local/lib/python3.11/site-packages/mkdocs_multirepo_plugin/util.py", line 10, in <module>
    from mkdocs.utils import warning_filter
  File "/usr/local/lib/python3.11/site-packages/mkdocs/utils/__init__.py", line 453, in __getattr__
    warnings.warn(
INFO    -  [macros] - Macros arguments: {'module_name': 'main', 'modules': [], 'render_by_default': True, 'include_dir': '', 'include_yaml': [], 'j2_block_start_string': '', 'j2_block_end_string': '', 'j2_variable_start_string': '', 'j2_variable_end_string': '', 'on_undefined': 'keep', 'on_error_fail': False, 'verbose': False}
INFO    -  [macros] - Extra variables (config file): ['tags', 'generator', 'version', 'vars']
INFO    -  [macros] - Extra filters (module): ['pretty']
INFO    -  Multirepo plugin importing docs...
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /builds/project-online/general-doc/site
INFO    -  Documentation built in 3.87 seconds
🔳 developers-doc
✅ developers-doc (0.013 secs)

Notice line 10. Normally, developers-doc import is started and completed right after the log "Multirepo plugin importing docs...". But somehow running this command from Gitlab Runner alters this behavior and its execution postponed until it's already too late.

Do you have any ideas what's happening here?

cardoe commented 2 months ago

I believe I'm hitting this as well and it's related to the usage of asyncio. Only have a couple of guesses here but another plugin could be calling asyncio.run() but the code definitely doesn't wait for the clone to finish for me as well.

alexeych0 commented 2 months ago

Eventually, wasn't able to locate the problem. But, the issue is resolved for us after we migrated Gitlab runners to k8s. Maybe it was something with the runner config or with the vm it was previously executed on

cardoe commented 1 month ago

I would agree that it was a runner config after playing with this plugin a bit. It's not the async like I implied at first.