Loading ci/setup_pages.py +33 −13 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ import sys from get_id_of_last_job_occurence import get_job_id PUBLIC_FOL_MAGIC = "-public" PROJECT_ID_FLOAT_REPO = 49 PROJECT_ID_BASOP_REPO = 77 JOBS_FLOAT_REPO = { "complexity-stereo-in-stereo-out": [PUBLIC_FOL_MAGIC], Loading @@ -17,36 +19,54 @@ JOBS_FLOAT_REPO = { "complexity-StereoDmxEVS-stereo-in-mono-out": [PUBLIC_FOL_MAGIC], "coverage-test-on-main-scheduled": ["coverage", "coverage_stv"], } JOBS_BASOP_REPO = { "ivas-pytest-mld-long-dec": ["mld.csv"], } JOBS_FOR_PROJECT_ID = {49: JOBS_FLOAT_REPO, 77: JOBS_BASOP_REPO} ARTIFACTS = "artifacts.zip" API_URL_BASE = "https://forge.3gpp.org/rep/api/v4/projects/{}/jobs" PUBLIC = "./public" PUBLIC_FOLDER = pathlib.Path("./public") def main(): public_folder = pathlib.Path(PUBLIC) public_folder.mkdir() failed_count = get_artifacts_for_jobs_and_return_num_failed( JOBS_FLOAT_REPO, public_folder ) project_id = os.environ["CI_PROJECT_ID"] jobs = JOBS_FOR_PROJECT_ID[project_id] PUBLIC_FOLDER.mkdir() if failed_count == len(JOBS_FLOAT_REPO): failed_count = get_artifacts_for_jobs_and_return_num_failed(jobs) if failed_count == len(jobs): print("Artifact collection failed for all jobs to check.") sys.exit(1) pathlib.Path("ci/index-pages.html").rename(public_folder.joinpath("index.html")) sys.exit(0) def get_artifacts_for_jobs_and_return_num_failed( jobs: dict, public_folder: pathlib.Path ) -> int: def setup_pages(project_id: int): if project_id == PROJECT_ID_FLOAT_REPO: pathlib.Path("ci/index-pages.html").rename(PUBLIC_FOLDER.joinpath("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()) else: raise ValueError(f"Invalid project ID: '{project_id}'") def get_artifacts_for_jobs_and_return_num_failed( jobs: dict) -> int: """ Get specified artifact folders for all jobs given and put them into the public folder. jobs: dictionary with the job names in the keys and a list of the public folders to copy from the artifacts in the values if "-public" is in the list, the actual folder name to copy is the key with "-public" appended public_folder: target folder to copy stuff to """ failed_count = 0 Loading @@ -59,7 +79,7 @@ def get_artifacts_for_jobs_and_return_num_failed( for fol in artifact_folders: if fol == PUBLIC_FOL_MAGIC: fol = job + fol pathlib.Path(fol).rename(public_folder.joinpath(fol)) pathlib.Path(fol).rename(PUBLIC_FOLDER.joinpath(fol)) except subprocess.CalledProcessError: print(f"Could not get artifacts for {job}") Loading Loading
ci/setup_pages.py +33 −13 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ import sys from get_id_of_last_job_occurence import get_job_id PUBLIC_FOL_MAGIC = "-public" PROJECT_ID_FLOAT_REPO = 49 PROJECT_ID_BASOP_REPO = 77 JOBS_FLOAT_REPO = { "complexity-stereo-in-stereo-out": [PUBLIC_FOL_MAGIC], Loading @@ -17,36 +19,54 @@ JOBS_FLOAT_REPO = { "complexity-StereoDmxEVS-stereo-in-mono-out": [PUBLIC_FOL_MAGIC], "coverage-test-on-main-scheduled": ["coverage", "coverage_stv"], } JOBS_BASOP_REPO = { "ivas-pytest-mld-long-dec": ["mld.csv"], } JOBS_FOR_PROJECT_ID = {49: JOBS_FLOAT_REPO, 77: JOBS_BASOP_REPO} ARTIFACTS = "artifacts.zip" API_URL_BASE = "https://forge.3gpp.org/rep/api/v4/projects/{}/jobs" PUBLIC = "./public" PUBLIC_FOLDER = pathlib.Path("./public") def main(): public_folder = pathlib.Path(PUBLIC) public_folder.mkdir() failed_count = get_artifacts_for_jobs_and_return_num_failed( JOBS_FLOAT_REPO, public_folder ) project_id = os.environ["CI_PROJECT_ID"] jobs = JOBS_FOR_PROJECT_ID[project_id] PUBLIC_FOLDER.mkdir() if failed_count == len(JOBS_FLOAT_REPO): failed_count = get_artifacts_for_jobs_and_return_num_failed(jobs) if failed_count == len(jobs): print("Artifact collection failed for all jobs to check.") sys.exit(1) pathlib.Path("ci/index-pages.html").rename(public_folder.joinpath("index.html")) sys.exit(0) def get_artifacts_for_jobs_and_return_num_failed( jobs: dict, public_folder: pathlib.Path ) -> int: def setup_pages(project_id: int): if project_id == PROJECT_ID_FLOAT_REPO: pathlib.Path("ci/index-pages.html").rename(PUBLIC_FOLDER.joinpath("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()) else: raise ValueError(f"Invalid project ID: '{project_id}'") def get_artifacts_for_jobs_and_return_num_failed( jobs: dict) -> int: """ Get specified artifact folders for all jobs given and put them into the public folder. jobs: dictionary with the job names in the keys and a list of the public folders to copy from the artifacts in the values if "-public" is in the list, the actual folder name to copy is the key with "-public" appended public_folder: target folder to copy stuff to """ failed_count = 0 Loading @@ -59,7 +79,7 @@ def get_artifacts_for_jobs_and_return_num_failed( for fol in artifact_folders: if fol == PUBLIC_FOL_MAGIC: fol = job + fol pathlib.Path(fol).rename(public_folder.joinpath(fol)) pathlib.Path(fol).rename(PUBLIC_FOLDER.joinpath(fol)) except subprocess.CalledProcessError: print(f"Could not get artifacts for {job}") Loading