sphinx-action icon indicating copy to clipboard operation
sphinx-action copied to clipboard

Problem reading logfile causes fatal error

Open rpgoldman opened this issue 2 years ago • 5 comments

When I run this in a github action I get this error:

====================================
Building docs in docs/
====================================
[sphinx-action] Running: ['sphinx-build', '-b', 'html', '.', '_build', '--keep-going', '--no-color', '-w', '/tmp/sphinx-log']
    action.build_all_docs(github_env, [os.environ.get("INPUT_DOCS-FOLDER")])
  File "/sphinx_action/action.py", line 152, in build_all_docs
    return_code, annotations = build_docs(github_env.build_command, docs_dir)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/sphinx_action/action.py", line 134, in build_docs
    with open(log_file, "r") as f:
         ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/sphinx-log'

Looks like the script assumes that there will be a logfile in /tmp and when that is not true, then we get an error. I can't actually tell if this is a side-effect of build_all_docs failing, or if it succeeded, but the log can't be parsed.

Perhaps the right fix is to check to make sure the log_file is written before reading it. If it's not written, then inspect the return_code and emit a result based on that, together with mention of failure writing the logfile?

rpgoldman avatar Apr 22 '23 17:04 rpgoldman

  • 1 for this appearing recently

SoundsSerious avatar May 23 '23 06:05 SoundsSerious

Looks like this was a previous issue https://github.com/ammaraskar/sphinx-action/issues/5

SoundsSerious avatar May 23 '23 07:05 SoundsSerious

I faced the same issue

even specified my own build command

    - name: Build HTML with Sphinx
      uses: ammaraskar/sphinx-action@master
      with:
        docs-folder: "doc/"
        build-command: "sphinx-build -b html . build"

But it still appends the options [sphinx-action] Running: ['sphinx-build', '-b', 'html', '.', 'build', '--keep-going', '--no-color', '-w', '/tmp/sphinx-log']

m-birke avatar Jun 05 '23 16:06 m-birke

Did you fix this problem? Thx

stephanbcbauer avatar Jun 21 '23 11:06 stephanbcbauer

For anyone interested, here is the solution I went with. This replaces the broken sphinx-action with installing python and using the GitHub runner to build and upload the documentation artifacts. It's a few extra lines, but seems very stable and reliable.

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python
      uses: actions/setup-python@v3
      with:
        python-version: '3.x'

    - name: Install Sphinx & Dependencies
      run: pip install sphinx sphinx_markdown_builder sphinx_rtd_theme
    - name: Build Documentation
      run: cd "$GITHUB_WORKSPACE/doc" && make html

    - uses: actions/upload-artifact@v3
      with:
        name: Documentation
        path: "$GITHUB_WORKSPACE/doc/_build/html/"

jonoomph avatar Feb 11 '24 22:02 jonoomph