build docs only when `//|` matches

This commit is contained in:
MicroDev 2023-01-07 18:17:48 +05:30
parent 0e46c77c14
commit 8096c94e1b
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
2 changed files with 12 additions and 0 deletions

View File

@ -153,6 +153,8 @@ jobs:
id: set-matrix id: set-matrix
working-directory: tools working-directory: tools
env: env:
BASE_SHA: ${{ steps.deepen-and-convert-depth-to-sha.outputs.commit }}
HEAD_SHA: ${{ github.event.after }}
CHANGED_FILES: ${{ steps.get-changes.outputs.changed_files }} CHANGED_FILES: ${{ steps.get-changes.outputs.changed_files }}
LAST_FAILED_JOBS: ${{ steps.get-last-commit-with-checks.outputs.check_runs }} LAST_FAILED_JOBS: ${{ steps.get-last-commit-with-checks.outputs.check_runs }}
run: python3 -u ci_set_matrix.py run: python3 -u ci_set_matrix.py

View File

@ -26,6 +26,7 @@ import os
import sys import sys
import json import json
import pathlib import pathlib
import subprocess
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
tools_dir = pathlib.Path(__file__).resolve().parent tools_dir = pathlib.Path(__file__).resolve().parent
@ -238,6 +239,15 @@ def set_docs_to_build(build_all):
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))$" 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))$"
) )
for p in changed_files: for p in changed_files:
if (
p.endswith(".c")
and not subprocess.run(
f"git diff -U0 {os.environ.get('BASE_SHA')}...{os.environ.get('HEAD_SHA')} {p} | grep -o -m 1 '^[+-]\/\/|'",
capture_output=True,
shell=True,
).stdout
):
continue
if doc_pattern.search(p): if doc_pattern.search(p):
doc_match = True doc_match = True
break break