Skip to content

Commit a3f4fec

Browse files
update suite_report
1 parent 00a6b16 commit a3f4fec

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

suite_report_git/suite_data.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
import shutil
1717
import yaml
1818
import re
19-
from bdiff.git_bdiff import GitBDiff, GitInfo
20-
from typing import Optional, List, Dict
19+
try:
20+
from bdiff.git_bdiff import GitBDiff, GitInfo
21+
except ImportError:
22+
from git_bdiff import GitBDiff, GitInfo
23+
from typing import Union, Optional, List, Dict
2124
from pathlib import Path
2225
from collections import defaultdict
2326

@@ -85,21 +88,24 @@ def clone_sources(self):
8588
"""
8689
Clone the sources defined in the dependencies file, to allow reading of files
8790
and creation of diffs.
88-
If the source is not a github url, then copy it using scp
91+
If the source is not a github url, then copy it using rsync
8992
"""
9093

9194
for dependency, data in self.dependencies.items():
9295
loc = self.temp_directory / dependency
9396
if data["source"].endswith(".git"):
9497
commands = [
95-
f"git clone {data["source"]} {loc}",
96-
f"git -C {loc} checkout {data["ref"]}",
98+
f"git clone {data['source']} {loc}",
99+
f"git -C {loc} checkout {data['ref']}",
97100
]
98101
for command in commands:
99102
self.run_command(command)
100103
else:
101-
command = f"scp -r -o StrictHostKeyChecking=no {data["source"]} {loc}"
102-
self.run_command(command)
104+
source = data["source"]
105+
if not source.endswith("/"):
106+
source = source + "/"
107+
command = f'rsync -e "ssh -o StrictHostKeyChecking=no" -avl {source} {loc}'
108+
self.run_command(command, shell=True)
103109

104110
def determine_primary_source(self) -> str:
105111
"""
@@ -259,7 +265,7 @@ def query_suite_database(
259265
return data
260266

261267
def run_command(
262-
self, command: str, shell: bool = False, rval: bool = False
268+
self, command: Union[str, List[str]], shell: bool = False, rval: bool = False
263269
) -> Optional[subprocess.CompletedProcess]:
264270
"""
265271
Run a subprocess command and return the result object
@@ -268,7 +274,7 @@ def run_command(
268274
Outputs:
269275
- result object from subprocess.run
270276
"""
271-
if not shell:
277+
if not shell and type(command) != list:
272278
command = command.split()
273279
result = subprocess.run(
274280
command,

suite_report_git/suite_report_git.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SuiteReport(SuiteData):
4646

4747
# str's for collapsed sections in markdown
4848
open_collapsed = "<details>"
49+
open_collapsed_show = "<details open>"
4950
close_collapsed = "</details>"
5051

5152
def __init__(self, suite_path: Path):
@@ -108,9 +109,9 @@ def create_task_tables(self, parsed_tasks: Dict[str, List[str]]):
108109
"""
109110

110111
# Ensure pink failures and then normal failures appear at the top
111-
sort_order = {"pink failure": 0, "failed": 1}
112+
sort_order = {"pink failure": 0, "failed": 1, "submit-failed": 2}
112113
order = list(parsed_tasks.keys())
113-
order.sort(key=lambda val: sort_order.get(val, 2))
114+
order.sort(key=lambda val: sort_order.get(val, len(sort_order)))
114115

115116
# Create summary table
116117
self.trac_log.extend(create_markdown_row("State", "Count", header=True))
@@ -130,7 +131,11 @@ def create_task_tables(self, parsed_tasks: Dict[str, List[str]]):
130131
continue
131132
if state == "pink failure":
132133
state = self.pink_text
133-
self.trac_log.append(self.open_collapsed)
134+
if "fail" in state:
135+
# Have the collapsed section expanded by default
136+
self.trac_log.append(self.open_collapsed_show)
137+
else:
138+
self.trac_log.append(self.open_collapsed)
134139
self.trac_log.append(f"<summary>{state} tasks</summary>")
135140
self.trac_log.append("")
136141
self.trac_log.extend(create_markdown_row("Task", "State", header=True))
@@ -229,7 +234,8 @@ def parse_args():
229234
"defaults to finding the suite directory from Cylc Env variables.",
230235
)
231236

232-
return parser.parse_args()
237+
args, _ = parser.parse_known_args()
238+
return args
233239

234240

235241
def main():

0 commit comments

Comments
 (0)