change condition to run all jobs
This commit is contained in:
parent
67e0a49a1f
commit
4a6965ee76
@ -82,10 +82,12 @@ def git_diff(pattern: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
compute_diff = bool(os.environ.get("BASE_SHA") and os.environ.get("HEAD_SHA"))
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
print("Using files list on commandline")
|
print("Using files list on commandline")
|
||||||
changed_files = set(sys.argv[1:])
|
changed_files = set(sys.argv[1:])
|
||||||
elif os.environ.get("BASE_SHA") and os.environ.get("HEAD_SHA"):
|
elif compute_diff:
|
||||||
print("Using files list by computing diff")
|
print("Using files list by computing diff")
|
||||||
changed_files = git_diff("$BASE_SHA...$HEAD_SHA")
|
changed_files = git_diff("$BASE_SHA...$HEAD_SHA")
|
||||||
if os.environ.get("GITHUB_EVENT_NAME") == "pull_request":
|
if os.environ.get("GITHUB_EVENT_NAME") == "pull_request":
|
||||||
@ -116,7 +118,7 @@ def set_output(name: str, value):
|
|||||||
print(f"Would set GitHub actions output {name} to '{value}'")
|
print(f"Would set GitHub actions output {name} to '{value}'")
|
||||||
|
|
||||||
|
|
||||||
def set_boards(build_all=False):
|
def set_boards(build_all: bool):
|
||||||
all_board_ids = set()
|
all_board_ids = set()
|
||||||
boards_to_build = all_board_ids if build_all else set()
|
boards_to_build = all_board_ids if build_all else set()
|
||||||
|
|
||||||
@ -245,43 +247,49 @@ def set_boards(build_all=False):
|
|||||||
set_output("ports", json.dumps(port_to_boards_to_build))
|
set_output("ports", json.dumps(port_to_boards_to_build))
|
||||||
|
|
||||||
|
|
||||||
def set_docs(run=bool(last_failed_jobs.get("docs"))):
|
def set_docs(run: bool):
|
||||||
if not run:
|
if not run:
|
||||||
pattern_doc = re.compile(PATTERN_DOCS)
|
if last_failed_jobs.get("docs"):
|
||||||
github_workspace = os.environ.get("GITHUB_WORKSPACE") or ""
|
run = True
|
||||||
github_workspace = github_workspace and github_workspace + "/"
|
else:
|
||||||
for file in changed_files:
|
pattern_doc = re.compile(PATTERN_DOCS)
|
||||||
if pattern_doc.search(file) and (
|
github_workspace = os.environ.get("GITHUB_WORKSPACE") or ""
|
||||||
(
|
github_workspace = github_workspace and github_workspace + "/"
|
||||||
subprocess.run(
|
for file in changed_files:
|
||||||
f"git diff -U0 $BASE_SHA...$HEAD_SHA {github_workspace + file} | grep -o -m 1 '^[+-]\/\/|'",
|
if pattern_doc.search(file) and (
|
||||||
capture_output=True,
|
(
|
||||||
shell=True,
|
subprocess.run(
|
||||||
).stdout
|
f"git diff -U0 $BASE_SHA...$HEAD_SHA {github_workspace + file} | grep -o -m 1 '^[+-]\/\/|'",
|
||||||
)
|
capture_output=True,
|
||||||
if file.endswith(".c")
|
shell=True,
|
||||||
else True
|
).stdout
|
||||||
):
|
)
|
||||||
run = True
|
if file.endswith(".c")
|
||||||
break
|
else True
|
||||||
|
):
|
||||||
|
run = True
|
||||||
|
break
|
||||||
|
|
||||||
# Set the step outputs
|
# Set the step outputs
|
||||||
print("Building docs:", run)
|
print("Building docs:", run)
|
||||||
set_output("docs", run)
|
set_output("docs", run)
|
||||||
|
|
||||||
|
|
||||||
def set_windows(run=bool(last_failed_jobs.get("windows"))):
|
def set_windows(run: bool):
|
||||||
if not run:
|
if not run:
|
||||||
for file in changed_files:
|
if last_failed_jobs.get("windows"):
|
||||||
for pattern in PATTERN_WINDOWS:
|
run = True
|
||||||
if file.startswith(pattern) and not any(
|
else:
|
||||||
[file.startswith(path) for path in IGNORE_BOARD]
|
for file in changed_files:
|
||||||
):
|
for pattern in PATTERN_WINDOWS:
|
||||||
run = True
|
if file.startswith(pattern) and not any(
|
||||||
break
|
[file.startswith(path) for path in IGNORE_BOARD]
|
||||||
else:
|
):
|
||||||
continue
|
run = True
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
|
||||||
# Set the step outputs
|
# Set the step outputs
|
||||||
print("Building windows:", run)
|
print("Building windows:", run)
|
||||||
@ -289,10 +297,12 @@ def set_windows(run=bool(last_failed_jobs.get("windows"))):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
run_all = not changed_files and not compute_diff
|
||||||
|
print("Running: " + ("all" if run_all else "conditionally"))
|
||||||
# Set jobs
|
# Set jobs
|
||||||
set_docs()
|
set_docs(run_all)
|
||||||
set_windows()
|
set_windows(run_all)
|
||||||
set_boards()
|
set_boards(run_all)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user