Use uv for CI build and deploy on GitHub action and CircleCI #1265
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# As much as possible, this file should be kept in sync with | |
# https://github.com/napari/napari/blob/main/.github/workflows/build_docs.yml | |
# | |
# Note this workflow is also triggered by | |
# https://github.com/napari/napari/blob/main/.github/workflows/deploy_docs.yml when a | |
# commit to `main` occurs in `napari/napari` | |
# | |
# For builds: | |
# working directory: '/home/runner/work/docs/docs' | |
# docs and napari are in the same parent directory | |
# place docs in: '/home/runner/work/docs/docs/docs' | |
# place napari in: '/home/runner/work/docs/docs/napari' | |
name: Build & Deploy PR Docs | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
target_directory: | |
description: 'Deployment directory for generated docs' | |
required: true | |
default: 'dev' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
FORCE_COLOR: "1" | |
permissions: {} | |
jobs: | |
build-and-upload: | |
name: Build & Upload Artifact | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone docs repo | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: docs | |
fetch-depth: 1 | |
- name: Clone napari repo | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: napari | |
repository: napari/napari | |
# needs 0 depth to get the latest versions | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: astral-sh/setup-uv@v5 | |
with: | |
enable-cache: true | |
python-version: "3.10" | |
- name: Set up video dependency | |
run: sudo apt-get update && sudo apt-get install -y ffmpeg | |
- name: Create a virtual environment to use for the builds | |
run: | | |
uv venv | |
source .venv/bin/activate | |
- name: Install Qt Libraries | |
uses: tlambert03/setup-qt-libs@v1 | |
- name: Install Dependencies | |
run: | | |
uv pip install "napari/[pyqt5, docs]" | |
env: | |
PIP_CONSTRAINT: ${{ github.workspace }}/napari/resources/constraints/constraints_py3.10_docs.txt | |
- name: Test installation succeeded | |
run: | | |
python -c 'import napari; print(napari.__version__)' | |
python -c 'import napari.layers; print(napari.layers.__doc__)' | |
- name: Create fallback videos | |
run: make -C docs fallback-videos | |
- name: Build Docs | |
uses: aganders3/headless-gui@v2 | |
env: | |
GOOGLE_CALENDAR_ID: ${{ secrets.GOOGLE_CALENDAR_ID }} | |
GOOGLE_CALENDAR_API_KEY: ${{ secrets.GOOGLE_CALENDAR_API_KEY }} | |
PIP_CONSTRAINT: ${{ github.workspace }}/napari/resources/constraints/constraints_py3.10_docs.txt | |
with: | |
run: make -C docs html | |
# skipping setup stops the action from running the default (tiling) window manager | |
# the window manager is not necessary for docs builds at this time and it was causing | |
# problems with screenshots (https://github.com/napari/docs/issues/285) | |
linux-setup: "echo 'skip setup'" | |
linux-teardown: "echo 'skip teardown'" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html | |
path: docs/docs/_build/html/ | |
- name: Minimize uv cache | |
run: uv cache prune --ci | |
deploy: | |
name: Download & Deploy Artifact | |
needs: build-and-upload | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
# Working directory: '/home/runner/work/docs/docs' | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: html | |
# Downloads to '/home/runner/work/docs/docs/html' | |
path: html | |
- name: Deploy Docs | |
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main')) | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
external_repository: napari/napari.github.io | |
publish_dir: ./html | |
publish_branch: gh-pages | |
destination_dir: ${{ github.event.inputs.target_directory || 'dev' }} | |
cname: napari.org |