|
83 | 83 | last_failed_jobs = json.loads(j)
|
84 | 84 |
|
85 | 85 |
|
86 |
| -def set_output(name, value): |
| 86 | +def set_output(name: str, value): |
87 | 87 | if "GITHUB_OUTPUT" in os.environ:
|
88 | 88 | with open(os.environ["GITHUB_OUTPUT"], "at") as f:
|
89 | 89 | print(f"{name}={value}", file=f)
|
90 | 90 | else:
|
91 | 91 | print(f"Would set GitHub actions output {name} to '{value}'")
|
92 | 92 |
|
93 | 93 |
|
94 |
| -def set_boards_to_build(build_all): |
| 94 | +def set_boards_to_build(build_all: bool): |
95 | 95 | # Get boards in json format
|
96 | 96 | boards_info_json = build_board_info.get_board_mapping()
|
97 | 97 | all_board_ids = set()
|
@@ -229,34 +229,34 @@ def get_settings(board):
|
229 | 229 | set_output(f"boards-{arch}", json.dumps(sorted(arch_to_boards[arch])))
|
230 | 230 |
|
231 | 231 |
|
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 |
256 | 256 |
|
257 | 257 | # 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) |
260 | 260 |
|
261 | 261 |
|
262 | 262 | def check_changed_files():
|
|
0 commit comments