Skip to content

Commit 1c7f95d

Browse files
committed
🎨🧪 Convert doc.yml workflow to be reusable
This patch is meant to simplify the maintenance of multiple complex workflow definitions that are tied together into a single workflow later on.
1 parent c90a862 commit 1c7f95d

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

.github/workflows/build.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ permissions:
2828
contents: read
2929

3030
concurrency:
31-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
31+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
3232
cancel-in-progress: true
3333

3434
jobs:
@@ -37,6 +37,7 @@ jobs:
3737
runs-on: ubuntu-latest
3838
timeout-minutes: 10
3939
outputs:
40+
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
4041
run_tests: ${{ steps.check.outputs.run_tests }}
4142
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
4243
steps:
@@ -63,6 +64,28 @@ jobs:
6364
# https://github.com/python/core-workflow/issues/373
6465
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
6566
fi
67+
- name: Get a list of the changed documentation-related files
68+
if: github.event_name == 'pull_request'
69+
id: changed-docs-files
70+
uses: Ana06/[email protected]
71+
with:
72+
filter: |
73+
Doc/**
74+
Misc/**
75+
.github/workflows/reusable-docs.yml
76+
- name: Check for docs changes
77+
if: >-
78+
github.event_name == 'pull_request'
79+
&& steps.changed-docs-files.outputs.added_modified_renamed != ''
80+
id: docs-changes
81+
run: |
82+
echo "run-docs=true" >> "${GITHUB_OUTPUT}"
83+
84+
check-docs:
85+
name: 📝
86+
needs: check_source
87+
if: fromJSON(needs.check_source.outputs.run-docs)
88+
uses: ./.github/workflows/reusable-docs.yml
6689

6790
# Check if we should run hypothesis tests
6891
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}

.github/workflows/doc.yml renamed to .github/workflows/reusable-docs.yml

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
1-
name: Docs
1+
name: 📝
22

33
on:
4+
workflow_call:
45
workflow_dispatch:
5-
#push:
6-
# branches:
7-
# - 'main'
8-
# - '3.12'
9-
# - '3.11'
10-
# - '3.10'
11-
# - '3.9'
12-
# - '3.8'
13-
# - '3.7'
14-
# paths:
15-
# - 'Doc/**'
16-
pull_request:
17-
branches:
18-
- 'main'
19-
- '3.12'
20-
- '3.11'
21-
- '3.10'
22-
- '3.9'
23-
- '3.8'
24-
- '3.7'
25-
paths:
26-
- 'Doc/**'
27-
- 'Misc/**'
28-
- '.github/workflows/doc.yml'
296

307
permissions:
318
contents: read

0 commit comments

Comments
 (0)