Loading ci/setup_pages.py +29 −6 Original line number Diff line number Diff line Loading @@ -45,23 +45,46 @@ def main(): print("Artifact collection failed for all jobs to check.") sys.exit(1) setup_pages(project_id) sys.exit(0) def setup_pages(project_id: int): index_html = PUBLIC_FOLDER.joinpath("index.html") if project_id == PROJECT_ID_FLOAT_REPO: pathlib.Path("ci/index-pages.html").rename(PUBLIC_FOLDER.joinpath("index.html")) pathlib.Path("ci/index-pages.html").rename(index_html) elif project_id == PROJECT_ID_BASOP_REPO: # basic test to see if mld file is collected correctly mld_file = pathlib.Path(PUBLIC_FOLDER.joinpath("mld.csv")) if mld_file.exists(): with open(PUBLIC_FOLDER.joinpath("index.html"), "w") as f: with open(mld_file) as mld_f: f.write(mld_f.read()) html_table_from_csv_file(mld_file, index_html) else: raise ValueError(f"Invalid project ID: '{project_id}'") def html_table_from_csv_file(csv_path, html_path): TABLE_ROW = "<tr>{}</tr>" TABLE_HEADER_CELL = "<th>{}</th>" TABLE_CELL = "<td>{}</td>" with open(csv_path) as csv: reader = csv.DictReader(csv, delimiter=";") with open(html_path, "w") as html: print("<table>", f=html) header_row = "".join( [TABLE_HEADER_CELL.format(x for x in reader.fieldnames)] ) print(header_row, f=html) for csv_row in reader: html_row = TABLE_ROW.format( "".join([TABLE_CELL.format(x for x in csv_row)]) ) print(html_row, f=html) print("</table>", f=html) def get_artifacts_for_jobs_and_return_num_failed( jobs: dict, project_id: int, success_only: bool ) -> int: Loading Loading
ci/setup_pages.py +29 −6 Original line number Diff line number Diff line Loading @@ -45,23 +45,46 @@ def main(): print("Artifact collection failed for all jobs to check.") sys.exit(1) setup_pages(project_id) sys.exit(0) def setup_pages(project_id: int): index_html = PUBLIC_FOLDER.joinpath("index.html") if project_id == PROJECT_ID_FLOAT_REPO: pathlib.Path("ci/index-pages.html").rename(PUBLIC_FOLDER.joinpath("index.html")) pathlib.Path("ci/index-pages.html").rename(index_html) elif project_id == PROJECT_ID_BASOP_REPO: # basic test to see if mld file is collected correctly mld_file = pathlib.Path(PUBLIC_FOLDER.joinpath("mld.csv")) if mld_file.exists(): with open(PUBLIC_FOLDER.joinpath("index.html"), "w") as f: with open(mld_file) as mld_f: f.write(mld_f.read()) html_table_from_csv_file(mld_file, index_html) else: raise ValueError(f"Invalid project ID: '{project_id}'") def html_table_from_csv_file(csv_path, html_path): TABLE_ROW = "<tr>{}</tr>" TABLE_HEADER_CELL = "<th>{}</th>" TABLE_CELL = "<td>{}</td>" with open(csv_path) as csv: reader = csv.DictReader(csv, delimiter=";") with open(html_path, "w") as html: print("<table>", f=html) header_row = "".join( [TABLE_HEADER_CELL.format(x for x in reader.fieldnames)] ) print(header_row, f=html) for csv_row in reader: html_row = TABLE_ROW.format( "".join([TABLE_CELL.format(x for x in csv_row)]) ) print(html_row, f=html) print("</table>", f=html) def get_artifacts_for_jobs_and_return_num_failed( jobs: dict, project_id: int, success_only: bool ) -> int: Loading