Skip to content

Commit 645499e

Browse files
committed
check //| only after a file matches the doc pattern
1 parent c94f83f commit 645499e

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

tools/ci_set_matrix.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@
8383
last_failed_jobs = json.loads(j)
8484

8585

86-
def set_output(name, value):
86+
def set_output(name: str, value):
8787
if "GITHUB_OUTPUT" in os.environ:
8888
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
8989
print(f"{name}={value}", file=f)
9090
else:
9191
print(f"Would set GitHub actions output {name} to '{value}'")
9292

9393

94-
def set_boards_to_build(build_all):
94+
def set_boards_to_build(build_all: bool):
9595
# Get boards in json format
9696
boards_info_json = build_board_info.get_board_mapping()
9797
all_board_ids = set()
@@ -229,34 +229,34 @@ def get_settings(board):
229229
set_output(f"boards-{arch}", json.dumps(sorted(arch_to_boards[arch])))
230230

231231

232-
def set_docs_to_build(build_all):
233-
if "build-doc" in last_failed_jobs:
234-
build_all = True
235-
236-
doc_match = build_all
237-
if not build_all:
238-
doc_pattern = re.compile(
239-
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))$"
240-
)
241-
github_workspace = os.environ.get("GITHUB_WORKSPACE") or ""
242-
github_workspace = github_workspace and github_workspace + "/"
243-
for p in changed_files:
244-
if (
245-
p.endswith(".c")
246-
and not subprocess.run(
247-
f"git diff -U0 $BASE_SHA...$HEAD_SHA {github_workspace + p} | grep -o -m 1 '^[+-]\/\/|'",
248-
capture_output=True,
249-
shell=True,
250-
).stdout
251-
):
252-
continue
253-
if doc_pattern.search(p):
254-
doc_match = True
255-
break
232+
def set_docs_to_build(build_doc: bool):
233+
if not build_doc:
234+
if "build-doc" in last_failed_jobs:
235+
build_doc = True
236+
else:
237+
doc_pattern = re.compile(
238+
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))$"
239+
)
240+
github_workspace = os.environ.get("GITHUB_WORKSPACE") or ""
241+
github_workspace = github_workspace and github_workspace + "/"
242+
for p in changed_files:
243+
if doc_pattern.search(p) and (
244+
(
245+
subprocess.run(
246+
f"git diff -U0 $BASE_SHA...$HEAD_SHA {github_workspace + p} | grep -o -m 1 '^[+-]\/\/|'",
247+
capture_output=True,
248+
shell=True,
249+
).stdout
250+
)
251+
if p.endswith(".c")
252+
else True
253+
):
254+
build_doc = True
255+
break
256256

257257
# Set the step outputs
258-
print("Building docs:", doc_match)
259-
set_output("build-doc", doc_match)
258+
print("Building docs:", build_doc)
259+
set_output("build-doc", build_doc)
260260

261261

262262
def check_changed_files():

0 commit comments

Comments
 (0)