From 54f798974099a7fd230e0741b668d666114ebdc9 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Thu, 25 Sep 2025 11:37:17 +0200 Subject: [PATCH 1/4] use shared workflows for build docs --- .github/workflows/build_and_deploy.yml | 87 ++-------------- .github/workflows/build_docs.yml | 100 ++----------------- .github/workflows/label_triggered_build.yml | 7 +- .github/workflows/triggered_target_build.yml | 20 +++- 4 files changed, 40 insertions(+), 174 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index a7dd13ca7..e39b86073 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -27,85 +27,14 @@ concurrency: jobs: build-and-upload: name: Build & Upload Artifact - runs-on: ubuntu-latest - env: - XDG_CACHE_HOME: ${{ github.workspace }}/.cache - steps: - - name: Clone docs repo - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - # place in '/home/runner/work/docs/docs/docs' - path: docs # place in a named directory - - - name: Clone main repo - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - # place in '/home/runner/work/docs/docs/napari' - path: napari # place in a named directory - repository: napari/napari - # ensure version metadata is proper - fetch-depth: 0 - - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 - with: - python-version: "3.12" - cache-dependency-path: | - napari/pyproject.toml - - - name: Cache pooch downloads - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4 - with: - path: | - ${{ github.workspace }}/.cache/scikit-image - ${{ github.workspace }}/.cache/napari-* - ${{ github.workspace }}/.cache/pooch - key: pooch - - - name: Setup headless display - uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 - with: - qt: true - wm: herbstluftwm - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - python -m pip install "napari/[pyqt5, docs]" - env: - PIP_CONSTRAINT: ${{ github.workspace }}/napari/resources/constraints/constraints_py3.12_docs.txt - - - name: Testing - run: | - python -c 'import napari; print(napari.__version__)' - python -c 'import napari.layers; print(napari.layers.__doc__)' - - - name: Create fallback videos - run: | - sudo apt-get update && sudo apt-get install -y ffmpeg - cd docs - make fallback-videos - - - name: Build Docs - run: make -C docs html - 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.12_docs.txt - - - name: Upload artifact - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: html - path: docs/docs/_build/html/ - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - - with: - name: Upload Logs - path: | - /tmp/*.log + uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs + secrets: inherit + with: + main-repo: ${{ github.repository }} + main-ref: ${{ github.sha }} + docs-repo: napari/docs + docs-ref: main + make_target: "html" deploy: name: Download & Deploy Artifact diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 3f85d0d88..404521b6f 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -1,5 +1,3 @@ -# As much as possible, this file should be kept in sync with -# https://github.com/napari/docs/blob/main/.github/workflows/build_and_deploy_docs.yml name: Build PR Docs on: @@ -12,98 +10,18 @@ on: description: "Enter make target: html html-noplot docs slimfast slimgallery" type: string default: "slimfast" - workflow_call: - inputs: - make_target: - description: "Enter make target: html html-noplot docs slimfast slimgallery" - type: string - default: "slimfast" - pr_number: - description: "PR number" - type: string - required: false concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - build-and-upload: - name: Build & Upload Artifact - runs-on: ubuntu-latest - env: - XDG_CACHE_HOME: ${{ github.workspace }}/.cache - steps: - - name: Clone docs repo - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - # Check out to '/home/runner/work/docs/docs/docs' - path: docs - ref: ${{ inputs.pr_number && format('refs/pull/{0}/merge', inputs.pr_number) || github.ref }} - - - - name: Clone main repo - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - # Check out to '/home/runner/work/docs/docs/napari' - path: napari - repository: napari/napari - # fetch history ensure napari version metadata is read properly - fetch-depth: 0 - - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 - with: - python-version: "3.12" - cache-dependency-path: | - napari/pyproject.toml - - - name: Cache pooch downloads - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4 - with: - path: | - ${{ github.workspace }}/.cache/scikit-image - ${{ github.workspace }}/.cache/napari-* - ${{ github.workspace }}/.cache/pooch - key: pooch - - - name: Setup headless display - uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 - with: - qt: true - wm: herbstluftwm - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - python -m pip install "napari/[pyqt5, docs]" - env: - PIP_CONSTRAINT: ${{ github.workspace }}/napari/resources/constraints/constraints_py3.12_docs.txt - - - name: Check napari can be imported - run: | - python -c 'import napari; print(napari.__version__)' - python -c 'import napari.layers; print(napari.layers.__doc__)' - - - name: Build Docs - run: make -C docs ${{ inputs.make_target || 'slimfast' }} - 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.12_docs.txt - - - name: Upload artifact - id: upload - if: always() - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: docs - path: docs/docs/_build/html - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - - with: - name: Upload Logs - path: | - /tmp/*.log + artifact-build: + uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs + secrets: inherit + with: + main-repo: ${{ github.repository }} + main-ref: ${{ github.sha }} + docs-repo: napari/docs + docs-ref: ${{ github.ref }} + make_target: ${{ inputs.make_target || 'slimfast' }} diff --git a/.github/workflows/label_triggered_build.yml b/.github/workflows/label_triggered_build.yml index 283a0a26f..d851c95c6 100644 --- a/.github/workflows/label_triggered_build.yml +++ b/.github/workflows/label_triggered_build.yml @@ -8,8 +8,13 @@ on: jobs: full-artifact-build: if: contains(github.event.pull_request.labels.*.name, 'ready to merge') - uses: ./.github/workflows/build_docs.yml + uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs + secrets: inherit with: + main-repo: ${{ github.repository }} + main-ref: ${{ github.sha }} + docs-repo: napari/docs + docs-ref: main make_target: "html" report-artifact-status: diff --git a/.github/workflows/triggered_target_build.yml b/.github/workflows/triggered_target_build.yml index d1bef46ee..a02a0c091 100644 --- a/.github/workflows/triggered_target_build.yml +++ b/.github/workflows/triggered_target_build.yml @@ -4,7 +4,7 @@ name: Trigger target build of docs # If started by a comment, the workflow runs on the PR branch and updates the PR status. # Note: This workflow runs only once per trigger and does not execute on every push to the PR branch. # This workflow triggers both the CircleCI doc build, using CircleCI-Public/trigger-circleci-pipeline-action. -# as well as an artifact build using the reusable workflow: .github/build_docs.yml +# as well as an artifact build using the reusable workflow from napari/shared-workflows. on: issue_comment: @@ -30,6 +30,7 @@ jobs: pr_ref: ${{ steps.get-pr-info.outputs.pr_ref }} pr_sha: ${{ steps.get-pr-info.outputs.pr_sha }} pr_number: ${{ steps.get-pr-info.outputs.pr_number }} + docs_ref: ${{ steps.set-docs-ref.outputs.docs_ref }} if: | (github.event_name == 'issue_comment' && github.event.issue.pull_request != '' && @@ -85,6 +86,15 @@ jobs: core.setOutput('pr_ref', pr.data.head.ref); core.setOutput('pr_sha', pr.data.head.sha); core.setOutput('pr_number', context.issue.number); + + - name: Set docs ref + id: set-docs-ref + run: | + if [ "${{ github.event_name }}" = "issue_comment" ]; then + echo "docs_ref=refs/pull/${{ github.event.issue.number }}/merge" >> "$GITHUB_OUTPUT" + else + echo "docs_ref=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + fi trigger-circleci: needs: determine-make-target @@ -100,10 +110,14 @@ jobs: trigger-artifact-build: needs: determine-make-target - uses: ./.github/workflows/build_docs.yml + uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs + secrets: inherit with: + main-repo: ${{ github.repository }} + main-ref: ${{ github.sha }} + docs-repo: napari/docs + docs-ref: ${{ needs.determine-make-target.outputs.docs_ref }} make_target: ${{ needs.determine-make-target.outputs.target }} - pr_number: ${{ needs.determine-make-target.outputs.pr_number }} report-artifact-status: # reusable workflows can't be a step in a job From d212ece96306e0841e420f521f2be7d088b4c5ff Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Thu, 25 Sep 2025 11:46:28 +0200 Subject: [PATCH 2/4] fix calling workflow --- .github/workflows/build_and_deploy.yml | 8 ++++---- .github/workflows/build_docs.yml | 6 +++--- .github/workflows/label_triggered_build.yml | 8 ++++---- .github/workflows/triggered_target_build.yml | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index e39b86073..cc42daba6 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -30,10 +30,10 @@ jobs: uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs secrets: inherit with: - main-repo: ${{ github.repository }} - main-ref: ${{ github.sha }} - docs-repo: napari/docs - docs-ref: main + main-repo: "napari/napari" + main-ref: "main" + docs-repo: ${{ github.repository }} + docs-ref: ${{ github.ref }} make_target: "html" deploy: diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 404521b6f..6c03d5243 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -20,8 +20,8 @@ jobs: uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs secrets: inherit with: - main-repo: ${{ github.repository }} - main-ref: ${{ github.sha }} - docs-repo: napari/docs + main-repo: "napari/napari" + main-ref: "main" + docs-repo: ${{ github.repository }} docs-ref: ${{ github.ref }} make_target: ${{ inputs.make_target || 'slimfast' }} diff --git a/.github/workflows/label_triggered_build.yml b/.github/workflows/label_triggered_build.yml index d851c95c6..f94bd3968 100644 --- a/.github/workflows/label_triggered_build.yml +++ b/.github/workflows/label_triggered_build.yml @@ -11,10 +11,10 @@ jobs: uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs secrets: inherit with: - main-repo: ${{ github.repository }} - main-ref: ${{ github.sha }} - docs-repo: napari/docs - docs-ref: main + main-repo: "napari/napari" + main-ref: "main" + docs-repo: ${{ github.repository }} + docs-ref: ${{ github.ref }} make_target: "html" report-artifact-status: diff --git a/.github/workflows/triggered_target_build.yml b/.github/workflows/triggered_target_build.yml index a02a0c091..2dcc10bb2 100644 --- a/.github/workflows/triggered_target_build.yml +++ b/.github/workflows/triggered_target_build.yml @@ -113,9 +113,9 @@ jobs: uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs secrets: inherit with: - main-repo: ${{ github.repository }} - main-ref: ${{ github.sha }} - docs-repo: napari/docs + main-repo: "napari/napari" + main-ref: "main" + docs-repo: ${{ github.repository }} docs-ref: ${{ needs.determine-make-target.outputs.docs_ref }} make_target: ${{ needs.determine-make-target.outputs.target }} From e2c01652df77affeac628d59f989899369e3497c Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Fri, 26 Sep 2025 19:56:04 +0200 Subject: [PATCH 3/4] Apply suggestions from code review --- .github/workflows/build_and_deploy.yml | 2 +- .github/workflows/build_docs.yml | 2 +- .github/workflows/label_triggered_build.yml | 2 +- .github/workflows/triggered_target_build.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index cc42daba6..a092a7ca3 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -27,7 +27,7 @@ concurrency: jobs: build-and-upload: name: Build & Upload Artifact - uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs + uses: napari/shared-workflows/.github/workflows/build_docs.yml secrets: inherit with: main-repo: "napari/napari" diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 6c03d5243..4156b5cb5 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -17,7 +17,7 @@ concurrency: jobs: artifact-build: - uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs + uses: napari/shared-workflows/.github/workflows/build_docs.yml secrets: inherit with: main-repo: "napari/napari" diff --git a/.github/workflows/label_triggered_build.yml b/.github/workflows/label_triggered_build.yml index f94bd3968..dc3440853 100644 --- a/.github/workflows/label_triggered_build.yml +++ b/.github/workflows/label_triggered_build.yml @@ -8,7 +8,7 @@ on: jobs: full-artifact-build: if: contains(github.event.pull_request.labels.*.name, 'ready to merge') - uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs + uses: napari/shared-workflows/.github/workflows/build_docs.yml secrets: inherit with: main-repo: "napari/napari" diff --git a/.github/workflows/triggered_target_build.yml b/.github/workflows/triggered_target_build.yml index 2dcc10bb2..4b055e771 100644 --- a/.github/workflows/triggered_target_build.yml +++ b/.github/workflows/triggered_target_build.yml @@ -110,7 +110,7 @@ jobs: trigger-artifact-build: needs: determine-make-target - uses: napari/shared-workflows/.github/workflows/build_docs.yml@build_docs + uses: napari/shared-workflows/.github/workflows/build_docs.yml secrets: inherit with: main-repo: "napari/napari" From 0a7b010c7aa5c3dc63d3bbbc14859d3de924f514 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Fri, 26 Sep 2025 19:59:23 +0200 Subject: [PATCH 4/4] Apply suggestions from code review --- .github/workflows/build_and_deploy.yml | 2 +- .github/workflows/build_docs.yml | 2 +- .github/workflows/label_triggered_build.yml | 2 +- .github/workflows/triggered_target_build.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index a092a7ca3..4b773999a 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -27,7 +27,7 @@ concurrency: jobs: build-and-upload: name: Build & Upload Artifact - uses: napari/shared-workflows/.github/workflows/build_docs.yml + uses: napari/shared-workflows/.github/workflows/build_docs.yml@main secrets: inherit with: main-repo: "napari/napari" diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 4156b5cb5..b9af301e4 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -17,7 +17,7 @@ concurrency: jobs: artifact-build: - uses: napari/shared-workflows/.github/workflows/build_docs.yml + uses: napari/shared-workflows/.github/workflows/build_docs.yml@main secrets: inherit with: main-repo: "napari/napari" diff --git a/.github/workflows/label_triggered_build.yml b/.github/workflows/label_triggered_build.yml index dc3440853..45e4733c0 100644 --- a/.github/workflows/label_triggered_build.yml +++ b/.github/workflows/label_triggered_build.yml @@ -8,7 +8,7 @@ on: jobs: full-artifact-build: if: contains(github.event.pull_request.labels.*.name, 'ready to merge') - uses: napari/shared-workflows/.github/workflows/build_docs.yml + uses: napari/shared-workflows/.github/workflows/build_docs.yml@main secrets: inherit with: main-repo: "napari/napari" diff --git a/.github/workflows/triggered_target_build.yml b/.github/workflows/triggered_target_build.yml index 4b055e771..bf96f2d99 100644 --- a/.github/workflows/triggered_target_build.yml +++ b/.github/workflows/triggered_target_build.yml @@ -110,7 +110,7 @@ jobs: trigger-artifact-build: needs: determine-make-target - uses: napari/shared-workflows/.github/workflows/build_docs.yml + uses: napari/shared-workflows/.github/workflows/build_docs.yml@main secrets: inherit with: main-repo: "napari/napari"