Commit e05c384b authored by Jan Kiene's avatar Jan Kiene
Browse files

use shutil to avoid cross-device move problems

parent 553a91a0
Loading
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import pathlib
import subprocess
import sys
import csv
import shutil
from collections import namedtuple
from tempfile import TemporaryDirectory

@@ -29,7 +30,10 @@ JOBS_BASOP_REPO = {
    Job("ivas-pytest-mld-long-dec", 1),
}

JOBS_FOR_PROJECT_ID = {PROJECT_ID_FLOAT_REPO: JOBS_FLOAT_REPO, PROJECT_ID_BASOP_REPO: JOBS_BASOP_REPO}
JOBS_FOR_PROJECT_ID = {
    PROJECT_ID_FLOAT_REPO: JOBS_FLOAT_REPO,
    PROJECT_ID_BASOP_REPO: JOBS_BASOP_REPO,
}

ARTIFACTS = "artifacts.zip"
API_URL_BASE = "https://forge.3gpp.org/rep/api/v4/projects/{}/jobs"
@@ -59,7 +63,8 @@ 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(index_html)
        src = pathlib.Path("ci/index-pages.html").absolute()
        shutil.move(src, index_html)
    elif project_id == PROJECT_ID_BASOP_REPO:
        pass
    else:
@@ -117,15 +122,11 @@ def get_artifacts_for_jobs_and_return_num_failed(
                    for artifact in tmp_dir.iterdir():
                        # this is only needed until the new naming of the csv files is on main
                        print(artifact)
                        src = tmp_dir.joinpath(artifact).absolute()
                        dst = PUBLIC_FOLDER.joinpath(artifact)
                        if project_id == PROJECT_ID_BASOP_REPO:
                            name_with_id = artifact.stem + f"-id_{job_id}" + artifact.suffix
                            tmp_dir.joinpath(artifact).rename(
                                PUBLIC_FOLDER.joinpath(name_with_id)
                            )
                        else:
                            tmp_dir.joinpath(artifact).rename(
                                PUBLIC_FOLDER.joinpath(artifact)
                            )
                            dst = artifact.stem + f"-id_{job_id}" + artifact.suffix
                        shutil.move(src, dst)

        except subprocess.CalledProcessError:
            print(f"Could not get artifacts for {job.name}")