diff --git a/.github/workflows/cd-build.yml b/.github/workflows/cd-build.yml index a7a2152..b2ea973 100644 --- a/.github/workflows/cd-build.yml +++ b/.github/workflows/cd-build.yml @@ -1,87 +1,57 @@ +# Build the Sphinx API documentation. +# +# pull_request → build only, as a check (no deploy) +# push: develop/main → build + deploy to GitHub Pages name: CD on: push: branches: - - master + - develop + - main + pull_request: + branches: + - develop + - main + workflow_dispatch: jobs: - - coverage: - name: Deploy Coverage Results - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Conda with Python 3.8 - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: 3.8 - auto-activate-base: false - - - name: Install dependencies - shell: bash -l {0} - run: | - python -m pip install --upgrade pip - python -m pip install -r develop.txt - python -m pip install twine - python -m pip install . - - - name: Run Tests - shell: bash -l {0} - run: | - python setup.py test - - - name: Check distribution - shell: bash -l {0} - run: | - python setup.py sdist - twine check dist/* - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: coverage.xml - flags: unittests - - api: - name: Deploy API Documentation - needs: coverage + docs: + name: Build API Documentation runs-on: ubuntu-latest - if: success() + permissions: + contents: write steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Set up Conda with Python 3.8 - uses: conda-incubator/setup-miniconda@v2 + - name: Set up Python + uses: actions/setup-python@v5 with: - auto-update-conda: true - python-version: 3.8 - auto-activate-base: false + python-version: "3.12" + cache: pip - - name: Install dependencies - shell: bash -l {0} - run: | - conda install -c conda-forge pandoc - python -m pip install --upgrade pip - python -m pip install -r docs/requirements.txt - python -m pip install . + - name: Install package with docs dependencies + run: python -m pip install ".[docs]" - name: Build API documentation - shell: bash -l {0} run: | sphinx-apidoc -t docs/_templates -feTMo docs/source cs_util sphinx-apidoc -t docs/_script_templates -feTMo docs/source scripts - sphinx-build -E docs/source docs/_build + sphinx-build -b html docs/source docs/_build + + # Upload the rendered HTML so it can be previewed from the run summary + # on pull requests, where the deploy is skipped. + - name: Upload built docs + uses: actions/upload-artifact@v4 + with: + name: docs-html + path: docs/_build - name: Deploy API documentation - uses: peaceiris/actions-gh-pages@v3.5.9 + if: github.event_name == 'push' + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: docs/_build diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 20b2237..43a0592 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -1,12 +1,18 @@ name: CI on: + push: + branches: + - develop + - main pull_request: branches: - - master + - develop + - main + workflow_dispatch: jobs: - build: + test: name: Run Unit Tests runs-on: ${{ matrix.os }} @@ -14,76 +20,20 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - python-version: [3.10.12] + python-version: ["3.10", "3.12"] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Report WPS Errors - uses: wemake-services/wemake-python-styleguide@0.14.1 - continue-on-error: true + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 with: - reporter: 'github-pr-review' - path: './cs_util' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install Poetry - run: pip install poetry + python-version: ${{ matrix.python-version }} + cache: pip - - name: Install Dependencies - shell: bash -l {0} - run: poetry install - - - name: Build Package - run: poetry build + - name: Install package with test dependencies + run: python -m pip install ".[test]" - name: Run Tests - shell: bash -l {0} - run: | - export PATH=/usr/share/miniconda/bin:$PATH - python setup.py test - - - name: Save Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: unit-test-results-${{ matrix.os }}-${{ matrix.python-version }} - path: pytest.xml - - - name: Check API Documentation build - shell: bash -l {0} - run: | - conda install -c conda-forge pandoc - sphinx-apidoc -t docs/_templates -feTMo docs/source cs_util - sphinx-apidoc -t docs/_script_templates -feTMo docs/source scripts - sphinx-build -b doctest -E docs/source docs/_build - - - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: coverage.xml - flags: unittests - - test-results: - name: Deploy Test Results - needs: build - runs-on: ubuntu-latest - if: success() || failure() - - steps: - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: unit-test-results-ubuntu-latest-3.8 - path: artifacts - - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1.5 - with: - check_name: Unit Test Report - github_token: ${{ secrets.GITHUB_TOKEN }} - report_individual_runs: true - files: artifacts/pytest.xml + run: pytest diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 0461d39..0000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -jupyter==1.0.0 -nbsphinx==0.8.0 -nbsphinx-link==1.3.0 -numpydoc==1.1.0 -sphinx==3.3.1 -sphinxcontrib-bibtex==1.0.0 -sphinxawesome-theme==1.17.0 diff --git a/docs/source/conf.py b/docs/source/conf.py index 1ed7905..ea15559 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -4,7 +4,7 @@ # Import relevant modules import sys import os -from importlib_metadata import metadata +from importlib.metadata import metadata # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -18,7 +18,7 @@ project = "cs_util" mdata = metadata(project) -author = mdata["Author"] +author = mdata["Author"] or mdata["Author-email"] version = mdata["Version"] copyright = "2022, {}".format(author) gh_user = "martinkilbinger" diff --git a/pyproject.toml b/pyproject.toml index ad014c6..38eeaa6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,4 +40,13 @@ test = [ "pytest-pydocstyle", "pytest-cov", ] +docs = [ + "sphinx>=8.0", + "numpydoc>=1.8", + "sphinxcontrib-bibtex>=2.6", + # 6.0.3 is a broken wheel on PyPI (dist-info only, no python module) + "sphinxawesome-theme>=5.3,!=6.0.3", + "nbsphinx>=0.9", + "nbsphinx-link>=1.3", +]