diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index ac29986fa..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: 2.1 -jobs: - build-book: - docker: - - image: cimg/python:3.13 - steps: - - checkout - - run: - name: Restore mtimes from git history - command: | - sudo apt-get update - sudo apt-get install git-restore-mtime - git restore-mtime - - run: - name: setup environment - command: | - pip install --upgrade pip - pip install nox - pip list - - run: - name: Build book html - command: nox -s docs - - - store_artifacts: - path: _build/html - destination: html - -# Tell CircleCI to use this workflow when it builds the site -workflows: - version: 2 - build-book: - jobs: - - build-book diff --git a/.github/workflows/artifact_redirect.yml b/.github/workflows/artifact_redirect.yml deleted file mode 100644 index 4b43d9728..000000000 --- a/.github/workflows/artifact_redirect.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Book Preview Redirect -on: [status] - -concurrency: - group: docs-preview-${{ github.ref }} - cancel-in-progress: true - -jobs: - circleci_artifacts_redirector_job: - runs-on: ubuntu-latest - # For testing this action on a fork, remove the "github.repository =="" condition. - if: "github.event.context == 'ci/circleci: build-book'" - permissions: - statuses: write - name: Run CircleCI artifacts redirector - steps: - - name: GitHub Action step - uses: scientific-python/circleci-artifacts-redirector-action@5d358ff96e96429a5c64a969bb4a574555439f4f # v1.3.1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - api-token: ${{ secrets.CIRCLECI_TOKEN }} - artifact-path: 0/html/index.html - circleci-jobs: build-book - job-title: View rendered book here! diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 870475bf1..2f68cec00 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -256,7 +256,7 @@ Once you submit a pull request, a series of checks will be run to ensure that yo - **Code formatting and styles**: checks that your code is formatted correctly, by `pre-commit.ci - pr check`. - **docs build**: checks that the documentation builds correctly, using `circleci`. - +- **docs build / preview**: builds the guide and publishes a Netlify deploy preview (see [Pull request previews](#pull-request-previews) below). You will see the status of these checks in your pull request. ```{figure} images/contributing/pull-requests-checks.png @@ -280,6 +280,15 @@ An image showing the status of the checks in a pull request in GitHub. The check To get more information about the errors, you can click on the "Details" link next to the failed check. +### Pull request previews + +This guide uses [Netlify](https://www.netlify.com/) deploy previews. After +the Netlify check finishes on a pull request, click **Details** next to the +deploy-preview status to open a live build with your changes. + +The guide is still deployed live using GitHub Pages: +. + ### What to expect from the review process Once you submit a pull request, a maintainer of the repository will review your changes and provide feedback. The review process may involve: diff --git a/README.md b/README.md index 4851177b8..9483f63fd 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ [![DOI](https://zenodo.org/badge/556814582.svg)](https://zenodo.org/badge/latestdoi/556814582) -[![CircleCI](https://circleci.com/gh/pyOpenSci/python-package-guide.svg?style=svg)](https://circleci.com/gh/pyOpenSci/python-package-guide) - [![Mentioned in Awesome Scientific Python](https://awesome.re/mentioned-badge.svg)](https://github.com/rossant/awesome-scientific-python) ## What is pyOpenSci? diff --git a/conf.py b/conf.py index 8f2be65b6..a1413bbc7 100644 --- a/conf.py +++ b/conf.py @@ -51,7 +51,11 @@ # languages that will be included in the language dropdown # (ie. all that are being built in this nox build session) -if sphinx_env == "production": +# Netlify sets NETLIFY=true. Those builds publish the same languages as +# production. Link prefixes stay at "/" because SPHINX_ENV is development +# there (see netlify.toml). Local builds are unchanged. +on_netlify = os.environ.get("NETLIFY", "").lower() == "true" +if sphinx_env == "production" or on_netlify: build_languages = ["en"] + release_languages else: build_languages = ["en"] + languages diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 000000000..dd66da27e --- /dev/null +++ b/netlify.toml @@ -0,0 +1,15 @@ +# Netlify deploy previews for the pyOpenSci Python package guide (Sphinx). +# Production remains GitHub Pages: +# https://www.pyopensci.org/python-package-guide/ + +[build] + command = "bash scripts/netlify-build.sh" + publish = "_build/html" + +[build.environment] + PYTHON_VERSION = "3.13" + MPLBACKEND = "Agg" + # Previews are served from the preview URL root, so language-selector + # links use "/" (conf.py does that whenever SPHINX_ENV is not production). + # Netlify also sets NETLIFY=true, which limits the menu to release languages. + SPHINX_ENV = "development" diff --git a/scripts/netlify-build.sh b/scripts/netlify-build.sh new file mode 100755 index 000000000..8021d3524 --- /dev/null +++ b/scripts/netlify-build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Build the Sphinx Python package guide on Netlify (deploy previews). +set -euo pipefail + +# hatch-vcs reads the package version from git tags. Netlify's checkout +# often has no tags. The docs do not display this version. +export SETUPTOOLS_SCM_PRETEND_VERSION="${SETUPTOOLS_SCM_PRETEND_VERSION:-0.0.0}" + +python -m pip install --upgrade pip +python -m pip install nox +python -m nox -s docs