Beispiel #1
0
def _clean_after_package(utils: Utils, docker: DockerWrapper, jobpair: JobPair,
                         image_name: str):
    for j in jobpair.jobs:
        # Remove repo.
        Utils.remove_file(utils.get_tar_file_in_jobpair_dir(j))
        # Remove original log.
        Utils.remove_file(utils.get_orig_log_path_in_jobpair_dir(j))
Beispiel #2
0
def modify_build_sh(repo: str, build_sh_path: str):
    """
    Travis builds are sometimes not reproducible when run using the build.sh script ("the build script") generated by
    travis-build. Thus, to increase the number of reproducible builds, we modify the build script.

    This function applies the necessary modifications to the build script located at `build_sh_path` and writes the
    modified file to that same location.

    This set of modifications was developed over time as we observed more build reproducibility issues that were likely
    caused by using the build script generated by travis-build.

    There's a file in Google Drive that explains the modifications applied to the build script.

    A previous version of this function included several additional build script modifications that have since been
    removed because travis-build was patched to generate build scripts that need fewer modifications. The BugSwarm
    pipeline utilizes the patched version of travis-build to generate build scripts.

    :param repo: A GitHub repository slug
    :param build_sh_path: The path to the unmodified build script (generated by travis-build).
    """
    if not isinstance(repo, str):
        raise TypeError
    if not repo:
        raise ValueError
    if not isinstance(build_sh_path, str):
        raise TypeError
    if not build_sh_path:
        raise ValueError

    log.debug('Modifying build script at {}.'.format(build_sh_path))

    # Read and modify the original build script.
    lines = []
    with open(build_sh_path) as f:
        skip = False
        for line in f:
            if 'start git.checkout' in line:
                skip = True
            elif 'travis_fold end git.checkout' in line:
                skip = False
                lines.append(r'travis_cmd cd\ ' + repo + ' --assert --echo\n')
            else:
                if not skip:
                    lines.append(line)

    # Overwrite the original build script with the modified build script.
    Utils.remove_file(build_sh_path)
    with open(build_sh_path, 'w') as f2:
        for l in lines:
            f2.write(l)