squidfunk / mkdocs-material

Documentation that simply works
https://squidfunk.github.io/mkdocs-material/
MIT License
20.89k stars 3.54k forks source link

no longer possible to deploy via CI (GitLab #3173

Closed ArdennesEtape closed 3 years ago

ArdennesEtape commented 3 years ago

Contribution guidelines

I've found a bug and checked that ...

Description

Unable to build the static site via Gitlab-CI

Everything goes well when running the site locally via docker

docker build -t squidfunk/mkdocs-material .
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material

tested with and without custom_dir setting in mkdocs.yml

Expected behaviour

generate the static site

Actual behaviour

error when running the GitLab CI and also fails when running locally gitlab-runner exec docker pages

Steps to reproduce

  1. Either deploy to Gitlab or try to run local via gitlab-runner exec docker pages This is the content of .gitab-ci.yml:

        image: python:latest
    pages:
      stage: deploy
      only:
        - main
      script:
        - pip install git+https://__TOKEN__@github.com/squidfunk/mkdocs-material-insiders.git
        - pip install mkdocs-minify-plugin
        - pip install mkdocs-git-revision-date-plugin
        - mkdocs build --site-dir public
      artifacts:
        paths:
          - public

Error:

#....

$ mkdocs build --site-dir public
INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /builds/project-0/public
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/mkdocs/__main__.py", line 187, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/usr/local/lib/python3.10/site-packages/mkdocs/commands/build.py", line 287, in build
    nav = config['plugins'].run_event('nav', nav, config=config, files=files)
  File "/usr/local/lib/python3.10/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/material/plugins/tags/plugin.py", line 76, in on_nav
    nav.items[start] = nav.items.pop(end)
IndexError: pop index out of range
ERROR: Job failed: exit code 1

FATAL: exit code 1     

Package versions

using python:latest docker container

Configuration

site_name: __NAME__
site_description: __DESCRIPTION__
site_author: __AUTHOR__
site_dir: public

copyright: Copyright &copy; 2016 - 20nn ___NAME__

repo_name: ae-doc
repo_url: __REPO_URL__
edit_uri: __REPO_URL__

theme:
  name: material
  custom_dir: overrides

  logo: ../../../assets/images/logo.svg

  font:
    text: Lato
    code: Roboto Mono

  static_templates:
    - 404.html

  # Don't include MkDocs' JavaScript
  include_search_page: false
  search_index_only: true

  features:
    - navigation.indexes
    - navigation.tracking
    - navigation.tabs
    - search.suggest
    - search.highlight
    - search.share
    - navigation.top
    - content.code.annotate
    - toc.integrate
    # - navigation.instant
    # - navigation.sections

  palette: 
    - scheme: ae
      primary: ae
      accent: ae
      toggle:
        icon: material/toggle-switch-off-outline
        name: Switch to dark mode
    - scheme: slate
      primary: red
      accent: red
      toggle:
        icon: material/toggle-switch
        name: Switch to light mode

plugins:
  - search:
      separator: "[\\s\\-,:!=\\[\\]()\"/]+|\\.(?!\\d)|&[lg]t;|(?!\\b)(?=[A-Z][a-z])"
  - git-revision-date
  - minify:
      minify_html: true
  - tags:
     tags_file: tags.md

extra:
  generator: false

markdown_extensions:
  - admonition
  - footnotes
  - meta
  - attr_list
  - pymdownx.highlight:
      use_pygments: true
  - pymdownx.inlinehilite
  - pymdownx.details
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid-experimental
          format: !!python/name:pymdownx.superfences.fence_code_format
  # - pymdownx.snippets
  - pymdownx.tabbed:
      alternate_style: true
  - pymdownx.snippets
  - pymdownx.keys
  - pymdownx.critic
  - pymdownx.caret
  - pymdownx.keys
  - pymdownx.mark
  - pymdownx.tilde
  - def_list
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg
  - pymdownx.arithmatex:
      generic: true
  # - tables

extra_javascript:
  - https://polyfill.io/v3/polyfill.min.js?features=es6
  - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

System information

N/A >> docker

ArdennesEtape commented 3 years ago

Not having the issues with previous release, ie 7.3.5-insiders.3.1.4

This works:

image: python:latest
pages:
  stage: deploy
  only:
    - main
  script:
    # - pip install mkdocs-material
    - pip install git+https://__TOKEN__@github.com/squidfunk/mkdocs-material-insiders.git@7.3.5-insiders.3.1.4
    - pip install mkdocs-minify-plugin
    - pip install mkdocs-git-revision-date-plugin
    - mkdocs build --site-dir public
  artifacts:
    paths:
      - public

Errors occur with all releases after 7.3.5-insiders.3.1.4

squidfunk commented 3 years ago

Thanks for reporting. Possibly related to #3167.

squidfunk commented 3 years ago

Okay, I think I've got a fix in 1a7f20889. I could simplify the code and I've tested it with and without tags file, and with and without specifying the navigation. I hope that this covers all cases now.

Could you try the latest master and see if the GitLab deploy works again?

ArdennesEtape commented 3 years ago

hi @squidfunk
Awesome... Just tested and everything went well.
Thanks !