mirror of
https://github.com/MAGICGrants/truenas-apps.git
synced 2026-01-08 04:03:51 -05:00
apply suggestions from code review
This commit is contained in:
52
.github/scripts/ci.py
vendored
52
.github/scripts/ci.py
vendored
@@ -25,11 +25,35 @@ def print_stderr(msg):
|
|||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--app", required=True, help="The name of the app")
|
parser.add_argument(
|
||||||
parser.add_argument("--train", required=True, help="The name of the train for the app")
|
"--app",
|
||||||
parser.add_argument("--test-file", required=True, help="Name of the test file to use as values")
|
required=True,
|
||||||
parser.add_argument("--render-only", required=False, default=False, type=bool, help="Prints the rendered docker-compose file")
|
help="The name of the app",
|
||||||
parser.add_argument("--render-only-debug", required=False, default=False, type=bool, help="Prints the rendered docker-compose file even if it's not a valid yaml")
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--train",
|
||||||
|
required=True,
|
||||||
|
help="The name of the train for the app",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--test-file",
|
||||||
|
required=True,
|
||||||
|
help="Name of the test file to use as values",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--render-only",
|
||||||
|
required=False,
|
||||||
|
default=False,
|
||||||
|
type=bool,
|
||||||
|
help="Prints the rendered docker-compose file",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--render-only-debug",
|
||||||
|
required=False,
|
||||||
|
default=False,
|
||||||
|
type=bool,
|
||||||
|
help="Prints the rendered docker-compose file even if it's not a valid yaml",
|
||||||
|
)
|
||||||
parsed = parser.parse_args()
|
parsed = parser.parse_args()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -188,9 +212,9 @@ def get_failed_containers():
|
|||||||
# Outputs one container per line, in json format
|
# Outputs one container per line, in json format
|
||||||
cmd = f"{get_base_cmd()} ps --all --format json"
|
cmd = f"{get_base_cmd()} ps --all --format json"
|
||||||
print_cmd(cmd)
|
print_cmd(cmd)
|
||||||
failed = subprocess.run(cmd, shell=True, capture_output=True).stdout.decode("utf-8")
|
all_containers = subprocess.run(cmd, shell=True, capture_output=True).stdout.decode("utf-8")
|
||||||
failed_containers = []
|
failed_containers = []
|
||||||
for line in failed.split("\n"):
|
for line in all_containers.split("\n"):
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
@@ -199,9 +223,10 @@ def get_failed_containers():
|
|||||||
print_stderr(f"Failed to parse container status output:\n {line}")
|
print_stderr(f"Failed to parse container status output:\n {line}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
actual_failed = []
|
failed = []
|
||||||
for container in failed_containers:
|
for container in failed_containers:
|
||||||
# Skip containers that are exited with 0 (eg init containers), but not restarting (during a restart exit code is 0)
|
# Skip containers that are exited with 0 (eg init containers),
|
||||||
|
# but not restarting (during a restart exit code is 0)
|
||||||
if all(
|
if all(
|
||||||
[
|
[
|
||||||
container.get("Health", "") == "" or container.get("Health", "") == "healthy",
|
container.get("Health", "") == "" or container.get("Health", "") == "healthy",
|
||||||
@@ -209,11 +234,14 @@ def get_failed_containers():
|
|||||||
not container.get("State", "") == "restarting",
|
not container.get("State", "") == "restarting",
|
||||||
]
|
]
|
||||||
):
|
):
|
||||||
print_stderr(f"Skipping container [{container['Name']}({container['ID']})] with status [{container.get('State')}] because it exited with 0 and has no health status")
|
print_stderr(
|
||||||
|
f"Skipping container [{container['Name']}({container['ID']})] with status [{container.get('State')}]"
|
||||||
|
+ " because it exited with 0 and has no health status"
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
actual_failed.append(container)
|
failed.append(container)
|
||||||
|
|
||||||
return actual_failed
|
return failed
|
||||||
|
|
||||||
|
|
||||||
def get_container_name(container):
|
def get_container_name(container):
|
||||||
|
|||||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -9,7 +9,7 @@
|
|||||||
"editor.formatOnSave": false,
|
"editor.formatOnSave": false,
|
||||||
"editor.formatOnPaste": false
|
"editor.formatOnPaste": false
|
||||||
},
|
},
|
||||||
"black-formatter.args": ["--line-length", "250"],
|
"black-formatter.args": ["--line-length", "120"],
|
||||||
"[python]": {
|
"[python]": {
|
||||||
"editor.defaultFormatter": "ms-python.black-formatter",
|
"editor.defaultFormatter": "ms-python.black-formatter",
|
||||||
"editor.defaultFoldingRangeProvider": "ms-python.flake8",
|
"editor.defaultFoldingRangeProvider": "ms-python.flake8",
|
||||||
|
|||||||
Reference in New Issue
Block a user