Skip to content

Commit bac9ca4

Browse files
authored
Run linkcheck on changed files only on PRs (#2111)
* Run linkcheck on changed files only on PRs * Fix job setup * Update Makefile
1 parent def16b7 commit bac9ca4

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

.github/workflows/CI.yml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,37 @@ jobs:
8383
run: |
8484
sphinx-build -D language=es -b html . _build/html
8585
86-
check-links:
86+
link-check-diff:
87+
# This job is sourced from https://github.com/aiven/devportal/blob/main/.github/workflows/linkcheck-changed-files.yaml
88+
# It is CC 4.0 I licensed: https://creativecommons.org/licenses/by/4.0/
89+
# Changes have been made.
8790
runs-on: ubuntu-latest
8891
steps:
89-
- uses: actions/checkout@v3
90-
with:
91-
fetch-depth: 0
92-
- uses: actions/setup-python@v4
93-
with:
94-
python-version: 3.9
95-
- name: Install Dependencies
96-
run: |
97-
pip install -r source/requirements.txt
98-
- name: Check Links
99-
run: |
100-
make linkcheck
92+
- uses: actions/checkout@v3
93+
with:
94+
fetch-depth: 0
95+
- name: Get changed files
96+
id: changed-files
97+
uses: tj-actions/changed-files@v24
98+
- uses: actions/setup-python@v4
99+
with:
100+
python-version: 3.9
101+
- name: Install Dependencies
102+
run: pip install -r source/requirements.txt
103+
- name: Run linkcheck on .rst files
104+
run: |
105+
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
106+
if [ "${file: -4}" == ".rst" ]
107+
then
108+
var="$var $file"
109+
fi
110+
done
111+
if [ -z "$var" ]
112+
then
113+
echo "No *.rst changed files to check."
114+
else
115+
make BUILDER_ARGS="$var" linkcheck
116+
fi
101117
102118
check-linting:
103119
runs-on: ubuntu-latest

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ LINTEROPTS = --ignore D001 # D001 is linelength
1111
SIZECHECKER = python3 -m scripts.imagesizechecker
1212
CONFEXCLUDE = --exclude-file source/conf.py
1313
SIZEMAX = 500
14+
BUILDER_ARGS ?=
1415

1516
ifeq ($(CI), true)
1617
SPHINXOPTS += --color
@@ -31,4 +32,4 @@ sizecheck:
3132
# Catch-all target: route all unknown targets to Sphinx using the new
3233
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
3334
%: Makefile
34-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(BUILDER_ARGS) $(SPHINXOPTS) $(O)

0 commit comments

Comments
 (0)