Skip to content

Sphinx conroldoc

Sphinx conroldoc #358

name: Build
on:
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
push:
branches: [ master, nightly ]
pull_request:
branches: [ master, nightly ]
jobs:
test-code:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt --prefer-binary; fi
python -m pip install .
- name: Test with pytest
env:
PY_VER: ${{ matrix.python-version }}
run: |
pytest
build-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install docs toolchain
#pre-build-command: "apt-get update && apt-get install -y git && python -m pip install 'sphinx==3.5.4' 'docutils==0.16' sphinx_mdinclude 'sphinx-rtd-theme==1.0.0' 'sphinxcontrib-applehelp==1.0.4' 'sphinxcontrib-devhelp==1.0.2' 'sphinxcontrib-qthelp==1.0.3' 'sphinxcontrib-serializinghtml==1.1.5' 'sphinxcontrib-htmlhelp==2.0.0' && python -m pip install -r requirements.txt && python -m pip install git+https://github.com/upb-lea/control-block-diagram && python -m pip install ."
#docs-folder: "docs/"
run: |
python -m pip install -U pip setuptools wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt || true; fi
pip install "sphinx==7.3.7" "docutils==0.20.1" "myst-parser==2.0.0" "sphinx-rtd-theme==3.0.2"
# REQUIRED so autodoc can import gem_controllers.*
pip install git+https://github.com/upb-lea/gem-control@main
# Optional: if gem-control imports this at import time in your pages
# pip install git+https://github.com/upb-lea/control-block-diagram
# Install your package so autodoc can import your modules too
pip install .
- name: Ensure docs/_static exists
run: mkdir -p docs/_static
- name: Build docs
working-directory: docs
run: |
sphinx-build -b html -n -T -v -E . _build/html --keep-going -w /tmp/sphinx-log
echo "---- Sphinx log ----"
cat /tmp/sphinx-log || true
- name: Upload docs as Pages artifact
if: success()
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html
- name: Print Sphinx log on failure
if: failure()
run: |
echo "::group::/tmp/sphinx-log"
tail -n +1 /tmp/sphinx-log || true
echo "::endgroup::"
# Publish built docs to gh-pages branch.
# ===============================
- name: Commit documentation changes
run: |
git clone https://github.com/upb-lea/gym-electric-motor.git --branch gh-pages --single-branch gh-pages
cp -r docs/_build/html/* gh-pages/
cd gh-pages
touch .nojekyll
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update documentation" -a || true
# The above command will fail if no changes were present, so we ignore
# that.
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
# ===============================