Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run sphinx-build as a module, ensures pipx compatibility #99

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,27 @@ jobs:
- name: Install pip
run: apt update && apt install -y python3-pip python3-pytest

- name: Install apt dependencies
run: apt update && apt install -y doxygen graphviz

- name: Smoke test of pipx install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we drop this into a separate test to keep it clear that it's a separable test. It will run in parallel and get a separate report then too.

run: |
apt install -y pipx python3-sphinx
PATH="$HOME/.local/bin:$PATH"
pipx install .
rosdoc2 build -d tmp/docs_build -c /tmp/cross_references -o /tmp/docs_output -p test/packages/full_package
if [ ! -f /tmp/docs_output/full_package/index.html ]; then
echo "Failed to find any output from rosdoc2"
exit 2
else
echo "rosdoc2 ran successfully under pipx"
fi

- name: Install pip dependencies
run: |
python3 -m pip install -U pycodestyle flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes
python3 -m pip install .[test]
python3 -m pip freeze

- name: Install apt dependencies
run: sudo apt update && sudo apt install -y doxygen graphviz

- name: Run tests
run: python3 -m pytest --verbose test
14 changes: 5 additions & 9 deletions rosdoc2/verbs/build/builders/sphinx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import subprocess

import setuptools
from sphinx.cmd.build import main as sphinx_main

from ..builder import Builder
from ..collect_inventory_files import collect_inventory_files
Expand Down Expand Up @@ -550,17 +551,12 @@ def build(self, *, doc_build_folder, output_staging_directory):
# Invoke Sphinx-build.
sphinx_output_dir = os.path.abspath(
os.path.join(wrapped_sphinx_directory, 'sphinx_output'))
cmd = [
'sphinx-build',
wrapped_sphinx_directory,
sphinx_output_dir,
]
logger.info(
f"Running Sphinx-build: '{' '.join(cmd)}' in '{wrapped_sphinx_directory}'"
f"Running sphinx_build with: [{wrapped_sphinx_directory}, '{sphinx_output_dir}]'"
)
completed_process = subprocess.run(cmd, cwd=wrapped_sphinx_directory)
msg = f"Sphinx-build exited with return code '{completed_process.returncode}'"
if completed_process.returncode == 0:
returncode = sphinx_main([wrapped_sphinx_directory, sphinx_output_dir])
msg = f"sphinx_build exited with return code '{returncode}'"
if returncode == 0:
logger.info(msg)
else:
raise RuntimeError(msg)
Expand Down