diff --git a/.github/actions/docs.sh b/.github/actions/docs.sh new file mode 100755 index 0000000..8c26c68 --- /dev/null +++ b/.github/actions/docs.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# set -x +set -e + +echo ::group:: Initialize various paths + +repo_dir=$GITHUB_WORKSPACE/$INPUT_REPOSITORY_PATH +doc_dir=$repo_dir/$INPUT_DOCUMENTATION_PATH +# https://stackoverflow.com/a/4774063/4799273 +action_dir=$GITHUB_ACTION_PATH + +echo Action: $action_dir +echo Workspace: $GITHUB_WORKSPACE +echo Repository: $repo_dir +echo Documentation: $doc_dir + +echo Adding ~/.local/bin to system path +PATH=$HOME/.local/bin:$PATH +if ! command -v sphinx-build &>/dev/null; then + echo Sphinx is not successfully installed + exit 1 +else + echo Everything goes well +fi + +echo ::endgroup:: + +echo ::group:: Creating build directory +build_dir=/tmp/sphinxnotes-pages +mkdir -p $build_dir || true +echo Temp directory \"$build_dir\" is created + +echo ::group:: Running Sphinx builder +if ! sphinx-build -b html $INPUT_SPHINX_BUILD_OPTIONS "$doc_dir" "$build_dir"; then + # See: https://github.com/sphinx-notes/pages/issues/28 + # echo ::endgroup:: + # echo ::group:: Dumping Sphinx error log + # for l in $(ls /tmp/sphinx-err*); do + # cat $l + # done + exit 1 +fi +echo ::endgroup:: + +echo "artifact=$build_dir" >> $GITHUB_OUTPUT diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml index f4f03e2..4e11f97 100644 --- a/.github/actions/setup/action.yaml +++ b/.github/actions/setup/action.yaml @@ -22,13 +22,11 @@ runs: steps: - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4.3.0 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} - check-latest: true - cache: pip - cache-dependency-path: | - pyproject.toml + cache: 'pip' + cache-dependency-path: pyproject.toml - name: Install PyTorch ${{ inputs.torch-version }}+${{ inputs.cuda-version }} if: ${{ inputs.torch-version != 'nightly' }} diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index acde017..b3483d8 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -1,4 +1,4 @@ -name: Sphinx docs to gh-pages +name: Docs on: push: @@ -10,11 +10,22 @@ on: jobs: sphinx_docs_to_gh-pages: runs-on: ubuntu-22.04 - name: Sphinx docs to gh-pages + name: Docs + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + pages: write + id-token: write + concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + # Skip workflow if only certain files have been changed. - name: Get changed files id: changed-files-specific @@ -26,8 +37,6 @@ jobs: README.md CHANGELOG.md requirements.txt - setup.py - pyproject.toml - name: Setup packages if: steps.changed-files-specific.outputs.only_changed != 'true' @@ -40,12 +49,42 @@ jobs: run: | pip install -e .[docs] - - name: Running the Sphinx to gh-pages Action + - name: Enable github problem matcher + uses: sphinx-doc/github-problem-matcher@master + + - id: build + name: Build documentation + if: steps.changed-files-specific.outputs.only_changed != 'true' + run: ./.github/actions/docs.sh + shell: bash + env: + # See https://github.com/actions/runner/issues/665 + INPUT_DOCUMENTATION_PATH: './docs/source' + INPUT_SPHINX_BUILD_OPTIONS: '' + + - name: Setup Pages + uses: actions/configure-pages@v4 + if: steps.changed-files-specific.outputs.only_changed != 'true' + + - name: Fix file permissions + shell: sh + if: runner.os == 'Linux' + # https://github.com/actions/deploy-pages/issues/188 + run: | + chmod -c -R +rX "$INPUT_PATH" | + while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done + env: + INPUT_PATH: ${{ steps.build.outputs.artifact }} + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 if: steps.changed-files-specific.outputs.only_changed != 'true' - uses: uibcdf/action-sphinx-docs-to-gh-pages@v2.1.0 with: - branch: main - dir_docs: docs - sphinx-apidoc-opts: '--separate -o ./source/_include ../pyg_spectral' - sphinx-apidoc-exclude: '../*setup* ../*.ipynb' - sphinx-opts: '' + path: ${{ steps.build.outputs.artifact }} + + - id: deployment + name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 + if: steps.changed-files-specific.outputs.only_changed != 'true' diff --git a/README.md b/README.md index b5db59a..aebe3fc 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Benchmarking Spectral Graph Neural Networks -[![Docs](https://github.com/gdmnl/Spectral-GNN-Benchmark/actions/workflows/docs.yml/badge.svg?event=push)](https://pages.github.com/gdmnl/Spectral-GNN-Benchmark/) +[![Docs](https://github.com/gdmnl/Spectral-GNN-Benchmark/workflows/Docs/badge.svg)](https://pages.github.com/gdmnl/Spectral-GNN-Benchmark/) `pyg_spectral` is a [PyTorch Geometric](https://pyg.org)-based framework for analyzing, implementing, and benchmarking spectral GNNs with effectiveness and efficiency evaluations.