tasks/libs/junit_upload.py
def produce_junit_tar(files, result_path):
    """
    Produce a tgz file containing all given files JUnit XML files and add a special file
    with additional tags.
    """
    # NOTE: for now, we can't pass CI_JOB_URL through `--tags`, because
    # the parsing logic tags breaks on URLs, as they contain colons.
    # Therefore we pass it through environment variable.
    tags = {
        "os.platform": platform.system().lower(),
        "os.architecture": _normalize_architecture(platform.machine()),
        "ci.job.name": os.environ.get("CI_JOB_NAME", ""),
        # "ci.job.url": os.environ.get("CI_JOB_URL", ""),
    }
    with tarfile.open(result_path, "w:gz") as tgz:
        for f in files:
            tgz.add(f, arcname=f.replace(os.path.sep, "-"))

        tags_file = io.BytesIO()
        for k, v in tags.items():
            tags_file.write(f"--tags {k}:{v} ".encode("UTF-8"))
        tags_info = tarfile.TarInfo(TAGS_FILE_NAME)
        tags_info.size = tags_file.getbuffer().nbytes
        tags_file.seek(0)
        tgz.addfile(tags_info, tags_file)

        job_url_file = io.BytesIO()
        job_url_file.write(os.environ.get("CI_JOB_URL", "").encode("UTF-8"))
        job_url_info = tarfile.TarInfo(JOB_URL_FILE_NAME)
        job_url_info.size = job_url_file.getbuffer().nbytes
        job_url_file.seek(0)
        tgz.addfile(job_url_info, job_url_file)

    Produce a tgz file containing all given files JUnit XML files and add a special file
    with additional tags.
    
Produce a tgz file containing all given files JUnit XML files and add a special file
with additional tags.
Produce a tgz file containing all given files JUnit XML files and add a special file with additional tags .
def produce_junit_tar(files, result_path):
    tags = {
        "os.platform": platform.system().lower(),
        "os.architecture": _normalize_architecture(platform.machine()),
        "ci.job.name": os.environ.get("CI_JOB_NAME", ""),
    }
    with tarfile.open(result_path, "w:gz") as tgz:
        for f in files:
            tgz.add(f, arcname=f.replace(os.path.sep, "-"))
        tags_file = io.BytesIO()
        for k, v in tags.items():
            tags_file.write(f"--tags {k}:{v} ".encode("UTF-8"))
        tags_info = tarfile.TarInfo(TAGS_FILE_NAME)
        tags_info.size = tags_file.getbuffer().nbytes
        tags_file.seek(0)
        tgz.addfile(tags_info, tags_file)
        job_url_file = io.BytesIO()
        job_url_file.write(os.environ.get("CI_JOB_URL", "").encode("UTF-8"))
        job_url_info = tarfile.TarInfo(JOB_URL_FILE_NAME)
        job_url_info.size = job_url_file.getbuffer().nbytes
        job_url_file.seek(0)
        tgz.addfile(job_url_info, job_url_file)
def produce_junit_tar ( files , result_path ) : tags = { "os.platform" : platform . system ( ) . lower ( ) , "os.architecture" : _normalize_architecture ( platform . machine ( ) ) , "ci.job.name" : os . environ . get ( "CI_JOB_NAME" , "" ) , } with tarfile . open ( result_path , "w:gz" ) as tgz : for f in files : tgz . add ( f , arcname = f . replace ( os . path . sep , "-" ) ) tags_file = io . BytesIO ( ) for k , v in tags . items ( ) : tags_file . write ( f"--tags {k}:{v} " . encode ( "UTF-8" ) ) tags_info = tarfile . TarInfo ( TAGS_FILE_NAME ) tags_info . size = tags_file . getbuffer ( ) . nbytes tags_file . seek ( 0 ) tgz . addfile ( tags_info , tags_file ) job_url_file = io . BytesIO ( ) job_url_file . write ( os . environ . get ( "CI_JOB_URL" , "" ) . encode ( "UTF-8" ) ) job_url_info = tarfile . TarInfo ( JOB_URL_FILE_NAME ) job_url_info . size = job_url_file . getbuffer ( ) . nbytes job_url_file . seek ( 0 ) tgz . addfile ( job_url_info , job_url_file )
Produce a tgz file containing all given files JUnit XML files and add a special file
with additional tags.
Produce a tgz file containing all given files JUnit XML files and add a special file with additional tags .
"""
    Produce a tgz file containing all given files JUnit XML files and add a special file
    with additional tags.
    """ # NOTE: for now, we can't pass CI_JOB_URL through `--tags`, because # the parsing logic tags breaks on URLs, as they contain colons. # Therefore we pass it through environment variable. # "ci.job.url": os.environ.get("CI_JOB_URL", ""),
files
result_path