mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-12 10:55:57 +08:00
1 parent
12958ce1c3
commit
6b2485d166
5 files changed
+60
-44
No files matched your search
@@ -4,11 +4,15 @@ import sys
|
||||
|
||||
import dcargs
|
||||
import yaml
|
||||
from rich.console import Console
|
||||
from rich.style import Style
|
||||
|
||||
console = Console(width=120)
|
||||
|
||||
LOCAL_TESTS = ["Run license checks", "Run isort", "Run Black", "Python Pylint", "Test with pytest"]
|
||||
|
||||
|
||||
def run_command(command: str, continue_on_fail: bool = False) -> None:
|
||||
def run_command(command: str, continue_on_fail: bool = False) -> bool:
|
||||
"""Run a command kill actions if it fails
|
||||
|
||||
Args:
|
||||
@@ -16,9 +20,10 @@ def run_command(command: str, continue_on_fail: bool = False) -> None:
|
||||
continue_on_fail: whether to continue running commands if the current one fails. Defaults to False.
|
||||
"""
|
||||
ret_code = subprocess.call(command, shell=True)
|
||||
if not continue_on_fail and ret_code != 0:
|
||||
print(f"\033[31mError: `{command}` failed. Exiting...\033[0m")
|
||||
sys.exit(1)
|
||||
if ret_code != 0:
|
||||
console.print(f"[bold red]Error: `{command}` failed.")
|
||||
if not continue_on_fail:
|
||||
sys.exit(1)
|
||||
return ret_code == 0
|
||||
|
||||
|
||||
@@ -33,8 +38,6 @@ def run_github_actions_file(filename: str, continue_on_fail: bool = False):
|
||||
my_dict = yaml.safe_load(f)
|
||||
steps = my_dict["jobs"]["build"]["steps"]
|
||||
|
||||
print_green = lambda x: print(f"\033[32m{x}\033[0m")
|
||||
print_red = lambda x: print(f"\033[31m{x}\033[0m")
|
||||
success = True
|
||||
|
||||
for step in steps:
|
||||
@@ -43,29 +46,31 @@ def run_github_actions_file(filename: str, continue_on_fail: bool = False):
|
||||
compressed = compressed.replace("--check", "")
|
||||
curr_command = f"{compressed}"
|
||||
|
||||
print("*" * 100)
|
||||
print_green(f"Running: {curr_command}")
|
||||
console.line()
|
||||
console.rule(f"[bold green]Running: {curr_command}")
|
||||
success = success and run_command(curr_command, continue_on_fail=continue_on_fail)
|
||||
else:
|
||||
print("*" * 100)
|
||||
print(f"Skipping {step}")
|
||||
skip_name = step["name"] if "name" in step else step["uses"]
|
||||
console.print(f"Skipping {skip_name}")
|
||||
|
||||
# Add checks for building documentation
|
||||
print_green("Adding notebook documentation metadata")
|
||||
success = success and run_command("python scripts/docs/add_nb_tags.py")
|
||||
print_green("Building Documentation")
|
||||
success = success and run_command("cd docs/; make html SPHINXOPTS='-W;'")
|
||||
console.line()
|
||||
console.rule("[bold green]Adding notebook documentation metadata")
|
||||
success = success and run_command("python scripts/docs/add_nb_tags.py", continue_on_fail=continue_on_fail)
|
||||
console.line()
|
||||
console.rule("[bold green]Building Documentation")
|
||||
success = success and run_command("cd docs/; make html SPHINXOPTS='-W;'", continue_on_fail=continue_on_fail)
|
||||
|
||||
if success:
|
||||
print("\n")
|
||||
print_green("=" * 100)
|
||||
print_green("ALL CHECKS PASSED")
|
||||
print_green("=" * 100)
|
||||
console.line()
|
||||
console.rule(characters="=")
|
||||
console.print("[bold green]:TADA: :TADA: :TADA: ALL CHECKS PASSED :TADA: :TADA: :TADA:", justify="center")
|
||||
console.rule(characters="=")
|
||||
else:
|
||||
print("\n")
|
||||
print_red("=" * 100)
|
||||
print_red("ERRORS FOUND")
|
||||
print_red("=" * 100)
|
||||
console.line()
|
||||
console.rule(characters="=", style=Style(color="red"))
|
||||
console.print("[bold red]:skull: :skull: :skull: ERRORS FOUND :skull: :skull: :skull:", justify="center")
|
||||
console.rule(characters="=", style=Style(color="red"))
|
||||
|
||||
|
||||
def run_code_checks(continue_on_fail: bool = False):
|
||||
|
||||
Reference in new issue
Block a user