From d0a455a2a00a0a4d4b4f5607afaffdeb62ce5879 Mon Sep 17 00:00:00 2001 From: Benedikt Daurer Date: Thu, 28 Nov 2024 15:37:55 +0000 Subject: [PATCH] Added CI for building docs --- .github/workflows/docs.yaml | 135 +++++++++++++++++++++ .github/workflows/{test.yml => tests.yaml} | 5 + docs/conf.py | 3 + docs/index.rst | 2 +- docs/reference/index.rst | 2 +- docs/requirements.txt | 1 + 6 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docs.yaml rename .github/workflows/{test.yml => tests.yaml} (97%) create mode 100644 docs/requirements.txt diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 000000000..5319e7c53 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,135 @@ +name: Documentation + +on: + push: + branches: + - master + +jobs: + build_docs_old: + runs-on: ubuntu-latest + steps: + - name: Checkout PtyPy Code + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + check-latest: true + + - name: Setup MPI + uses: mpi4py/setup-mpi@v1 + with: + mpi: mpich + + - name: Install Sphinx + run: pip install sphinx + + - name: Install PtyPy + run: pip install .[full] + + - name: Prepare Tutorials + working-directory: doc + run: python script2rst.py + + - name: Prepare Templates + working-directory: doc + run: python tmp2rst.py + + - name: Prepare Parameters + working-directory: doc + run: python parameters2rst.py + + - name: Set Path to Sphinx Build + run: echo "SPHINXBUILD=`which sphinx-build`" >> $GITHUB_ENV + + - name: Build Sphinx Documentation + working-directory: doc + run: make html + + - name: Upload Docs Artifact + uses: actions/upload-artifact@v4.4.3 + with: + name: old-docs + path: doc/build/html/ + + build_docs: + runs-on: ubuntu-latest + steps: + - name: Checkout PtyPy Code + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + check-latest: true + + - name: Setup MPI + uses: mpi4py/setup-mpi@v1 + with: + mpi: mpich + + - name: Install Sphinx + run: pip install sphinx + + - name: Install PtyPy + run: pip install .[full] + + - name: Install docs dependencies + run: pip install -r docs/requirements.txt + + - name: Set Path to Sphinx Build + run: echo "SPHINXBUILD=`which sphinx-build`" >> $GITHUB_ENV + + - name: Build Sphinx Documentation + working-directory: docs + run: make html + + - name: Upload Docs Artifact + uses: actions/upload-artifact@v4.4.3 + with: + name: new-docs + path: docs/_build/html/ + + publish_pages: + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + needs: + - build_docs_old + - build_docs + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Setup Pages + uses: actions/configure-pages@v5.0.0 + + - name: Download Old Docs Artifact + uses: actions/download-artifact@v4.1.8 + with: + name: old-docs + path: ./ + + - name: Download Docs Artifact + uses: actions/download-artifact@v4.1.8 + with: + name: new-docs + path: ./docs + + - name: Fix File Permissions for Pages + run: | + chmod -R +rX . + + - name: Upload Merged Artifact + uses: actions/upload-pages-artifact@v3.0.1 + with: + path: ./ + + - name: Publish Docs to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4.0.5 diff --git a/.github/workflows/test.yml b/.github/workflows/tests.yaml similarity index 97% rename from .github/workflows/test.yml rename to .github/workflows/tests.yaml index b37bc8c30..0e6bf2ed1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/tests.yaml @@ -6,11 +6,16 @@ on: push: branches: - master + paths-ignore: + - "docs/**" + - ".github/workflows/**" pull_request: branches: - master - dev - hotfixes + paths-ignore: + - "docs/**" # Also trigger on page_build, as well as release created events page_build: release: diff --git a/docs/conf.py b/docs/conf.py index a79956707..8e818a671 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,6 +11,8 @@ sys.path.insert(0, str(Path('..', 'ptypy').resolve())) +print(sys.path) + project = 'PtyPy' copyright = '2024, AUTHORS' author = 'AUTHORS' @@ -33,6 +35,7 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +#autodoc_mock_imports = ["numpy", "scipy"] # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output diff --git a/docs/index.rst b/docs/index.rst index af2e871a8..749f75bc7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,4 +15,4 @@ documentation for details. :maxdepth: 2 :caption: Contents: - reference/index \ No newline at end of file + reference/index diff --git a/docs/reference/index.rst b/docs/reference/index.rst index d997a431c..90233f608 100644 --- a/docs/reference/index.rst +++ b/docs/reference/index.rst @@ -5,4 +5,4 @@ API Reference .. toctree:: :maxdepth: 2 - utils \ No newline at end of file + utils diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..e47016789 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1 @@ +pydata-sphinx-theme