Skip to content

Commit 8096c94

Browse files
committed
build docs only when //| matches
1 parent 0e46c77 commit 8096c94

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ jobs:
153153
id: set-matrix
154154
working-directory: tools
155155
env:
156+
BASE_SHA: ${{ steps.deepen-and-convert-depth-to-sha.outputs.commit }}
157+
HEAD_SHA: ${{ github.event.after }}
156158
CHANGED_FILES: ${{ steps.get-changes.outputs.changed_files }}
157159
LAST_FAILED_JOBS: ${{ steps.get-last-commit-with-checks.outputs.check_runs }}
158160
run: python3 -u ci_set_matrix.py

tools/ci_set_matrix.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import sys
2727
import json
2828
import pathlib
29+
import subprocess
2930
from concurrent.futures import ThreadPoolExecutor
3031

3132
tools_dir = pathlib.Path(__file__).resolve().parent
@@ -238,6 +239,15 @@ def set_docs_to_build(build_all):
238239
r"^(?:.github/workflows/|docs|extmod/ulab|(?:(?:ports/\w+/bindings|shared-bindings)\S+\.c|conf\.py|tools/extract_pyi\.py|requirements-doc\.txt)$)|(?:-stubs|\.(?:md|MD|rst|RST))$"
239240
)
240241
for p in changed_files:
242+
if (
243+
p.endswith(".c")
244+
and not subprocess.run(
245+
f"git diff -U0 {os.environ.get('BASE_SHA')}...{os.environ.get('HEAD_SHA')} {p} | grep -o -m 1 '^[+-]\/\/|'",
246+
capture_output=True,
247+
shell=True,
248+
).stdout
249+
):
250+
continue
241251
if doc_pattern.search(p):
242252
doc_match = True
243253
break

0 commit comments

Comments
 (0)