Exemple #1
0
def document_necessary(workspace,
                       docspace,
                       ros_distro,
                       repo,
                       rosdoc_lite_version,
                       jenkins_scripts_version,
                       force_doc=False):
    append_pymodules_if_needed()
    print "Working on distro %s and repo %s" % (ros_distro, repo)

    #Load the rosinstall configurations for the repository
    doc_conf, depends_conf = load_configuration(ros_distro, repo)

    #Install the repository
    install_repo(docspace, workspace, repo, doc_conf, depends_conf)

    #Load information about existing tags
    tags_db = TagsDb(ros_distro, workspace)

    #Check to see if we need to document this repo list by checking if any of
    #the repositories revision numbers/hashes have changed
    changes = False or force_doc
    for conf in [('%s' % repo, doc_conf), ('%s_depends' % repo, depends_conf)]:
        changes = rev_changes(conf[0], conf[1], docspace, tags_db) or changes

    #We also want to make sure that we run documentation generation anytime
    #jenkins_scripts or rosdoc_lite has changed since the last time this job was
    #run
    repo_hashes = tags_db.get_rosinstall_hashes(
        repo) if tags_db.has_rosinstall_hashes(repo) else {}
    old_rosdoc_lite_hash = repo_hashes.get('rosdoc_lite-sys', None)
    old_jenkins_scripts_hash = repo_hashes.get('jenkins_scripts-sys', None)
    print "REPO HASHES: %s" % repo_hashes

    if changes and old_rosdoc_lite_hash == rosdoc_lite_version and old_jenkins_scripts_hash == jenkins_scripts_version:
        print "There were no changes to any of the repositories we document. Not running documentation."
        copy_test_results(workspace, docspace)
        tags_db.delete_tag_index_repo()
        return False

    #Make sure to update the versions of jenkins_scripts and rosdoc_lite for this repo list
    repo_hashes['rosdoc_lite-sys'] = rosdoc_lite_version
    repo_hashes['jenkins_scripts-sys'] = jenkins_scripts_version
    tags_db.set_rosinstall_hashes(repo, repo_hashes)
    return {
        'doc_conf': doc_conf,
        'depends_conf': depends_conf,
        'tags_db': tags_db
    }
def document_necessary(workspace, docspace, ros_distro, repo,
                       rosdoc_lite_version, jenkins_scripts_version, force_doc=False):
    append_pymodules_if_needed()
    print "Working on distro %s and repo %s" % (ros_distro, repo)

    #Load the rosinstall configurations for the repository
    doc_conf, depends_conf = load_configuration(ros_distro, repo)

    #Install the repository
    install_repo(docspace, workspace, repo, doc_conf, depends_conf)

    #Load information about existing tags
    tags_db = TagsDb(ros_distro, workspace)

    #Check to see if we need to document this repo list by checking if any of
    #the repositories revision numbers/hashes have changed
    changes = False or force_doc
    for conf in [('%s' % repo, doc_conf), ('%s_depends' % repo, depends_conf)]:
        changes = rev_changes(conf[0], conf[1], docspace, tags_db) or changes

    #We also want to make sure that we run documentation generation anytime
    #jenkins_scripts or rosdoc_lite has changed since the last time this job was
    #run
    repo_hashes = tags_db.get_rosinstall_hashes(repo) if tags_db.has_rosinstall_hashes(repo) else {}
    old_rosdoc_lite_hash = repo_hashes.get('rosdoc_lite-sys', None)
    old_jenkins_scripts_hash = repo_hashes.get('jenkins_scripts-sys', None)
    print "REPO HASHES: %s" % repo_hashes

    if changes and old_rosdoc_lite_hash == rosdoc_lite_version and old_jenkins_scripts_hash == jenkins_scripts_version:
        print "There were no changes to any of the repositories we document. Not running documentation."
        copy_test_results(workspace, docspace)
        tags_db.delete_tag_index_repo()
        return False

    #Make sure to update the versions of jenkins_scripts and rosdoc_lite for this repo list
    repo_hashes['rosdoc_lite-sys'] = rosdoc_lite_version
    repo_hashes['jenkins_scripts-sys'] = jenkins_scripts_version
    tags_db.set_rosinstall_hashes(repo, repo_hashes)
    return {'doc_conf': doc_conf, 'depends_conf': depends_conf, 'tags_db': tags_db}
Exemple #3
0
def document_necessary(workspace, docspace, ros_distro, repo,
                       rosdoc_lite_version, jenkins_scripts_version, force_doc=False):
    append_pymodules_if_needed()
    print("Working on distro %s and repo %s" % (ros_distro, repo))

    #Load the rosinstall configurations for the repository
    doc_conf, depends_conf = load_configuration(ros_distro, repo)

    #Install the repository
    try:
        install_repo(docspace, workspace, repo, doc_conf, depends_conf)
    except BuildException:
        # checkout failed, try to get default branches of repos to notify the maintainers
        print('Failed to checkout repositories, trying to checkout default branches to collect maintainer information for notification about failure')
        for tuple in doc_conf:
            for repo in tuple.values():
                repo['version'] = None
        install_repo(docspace, workspace, repo, doc_conf, [])
        extract_notification_recipients(docspace, doc_conf)
        raise

    extract_notification_recipients(docspace, doc_conf)

    #Load information about existing tags
    jenkins_scripts_path = os.path.join(workspace, 'jenkins_scripts')
    if not os.path.exists(jenkins_scripts_path):
        # if jenkins_scripts has not been checked out in the workspace
        # expect that the user call doc from within a jenkins_scripts checkout
        jenkins_scripts_path = os.getcwd()
    rosdoc_tag_index_path = os.path.join(workspace, 'rosdoc_tag_index')
    tags_db = TagsDb(ros_distro, jenkins_scripts_path, rosdoc_tag_index_path)

    #Check to see if we need to document this repo list by checking if any of
    #the repositories revision numbers/hashes have changed
    changes = False or force_doc
    for conf in [('%s' % repo, doc_conf), ('%s_depends' % repo, depends_conf)]:
        changes = rev_changes(conf[0], conf[1], docspace, tags_db) or changes

    #We also want to make sure that we run documentation generation anytime
    #jenkins_scripts or rosdoc_lite has changed since the last time this job was
    #run
    repo_hashes = tags_db.get_rosinstall_hashes(repo) if tags_db.has_rosinstall_hashes(repo) else {}
    old_rosdoc_lite_hash = repo_hashes.get('rosdoc_lite-sys', None)
    old_jenkins_scripts_hash = repo_hashes.get('jenkins_scripts-sys', None)
    print("REPO HASHES: %s" % repo_hashes)

    if not changes and old_rosdoc_lite_hash == rosdoc_lite_version and old_jenkins_scripts_hash == jenkins_scripts_version:
        print("There were no changes to any of the repositories we document. Not running documentation.")
        copy_test_results(workspace, docspace)
        tags_db.delete_tag_index_repo()

        # create marker files for all packages an upload them
        doc_path = os.path.realpath("%s/doc/%s" % (docspace, ros_distro))
        if os.path.exists(doc_path):
            shutil.rmtree(doc_path)
        repo_path = os.path.realpath("%s" % (docspace))
        stacks, manifest_packages, catkin_packages, _ = build_repo_structure(repo_path, doc_conf, depends_conf)
        folders = sorted(set(stacks.keys() + manifest_packages.keys() + catkin_packages.keys()))
        if folders:
            dsts = ['%s/api/%s/stamp' % (doc_path, f) for f in folders]
            for dst in dsts:
                os.makedirs(os.path.dirname(dst))
                with open(dst, 'w'):
                    pass
            print("Uploading marker files to identify that documentation is up-to-date.")
            command = ['bash', '-c', 'rsync -e "ssh -o StrictHostKeyChecking=no" -qr %s/api/ [email protected]:/home/rosbot/docs/%s/api' % (doc_path, ros_distro)]
            call_with_list(command)

        return False

    #Make sure to update the versions of jenkins_scripts and rosdoc_lite for this repo list
    repo_hashes['rosdoc_lite-sys'] = rosdoc_lite_version
    repo_hashes['jenkins_scripts-sys'] = jenkins_scripts_version
    tags_db.set_rosinstall_hashes(repo, repo_hashes)
    return {'doc_conf': doc_conf, 'depends_conf': depends_conf, 'tags_db': tags_db}
def document_necessary(
    workspace, docspace, ros_distro, repo, rosdoc_lite_version, jenkins_scripts_version, force_doc=False
):
    append_pymodules_if_needed()
    print("Working on distro %s and repo %s" % (ros_distro, repo))

    # Load the rosinstall configurations for the repository
    doc_conf, depends_conf = load_configuration(ros_distro, repo)

    # Install the repository
    try:
        install_repo(docspace, workspace, repo, doc_conf, depends_conf)
    except BuildException:
        # checkout failed, try to get default branches of repos to notify the maintainers
        print(
            "Failed to checkout repositories, trying to checkout default branches to collect maintainer information for notification about failure"
        )
        for tuple in doc_conf:
            for repo in tuple.values():
                repo["version"] = None
        install_repo(docspace, workspace, repo, doc_conf, [])
        extract_notification_recipients(docspace, doc_conf)
        raise

    extract_notification_recipients(docspace, doc_conf)

    # Load information about existing tags
    jenkins_scripts_path = os.path.join(workspace, "jenkins_scripts")
    if not os.path.exists(jenkins_scripts_path):
        # if jenkins_scripts has not been checked out in the workspace
        # expect that the user call doc from within a jenkins_scripts checkout
        jenkins_scripts_path = os.getcwd()
    rosdoc_tag_index_path = os.path.join(workspace, "rosdoc_tag_index")
    tags_db = TagsDb(ros_distro, jenkins_scripts_path, rosdoc_tag_index_path)

    # Check to see if we need to document this repo list by checking if any of
    # the repositories revision numbers/hashes have changed
    changes = False or force_doc
    for conf in [("%s" % repo, doc_conf), ("%s_depends" % repo, depends_conf)]:
        changes = rev_changes(conf[0], conf[1], docspace, tags_db) or changes

    # We also want to make sure that we run documentation generation anytime
    # jenkins_scripts or rosdoc_lite has changed since the last time this job was
    # run
    repo_hashes = tags_db.get_rosinstall_hashes(repo) if tags_db.has_rosinstall_hashes(repo) else {}
    old_rosdoc_lite_hash = repo_hashes.get("rosdoc_lite-sys", None)
    old_jenkins_scripts_hash = repo_hashes.get("jenkins_scripts-sys", None)
    print("REPO HASHES: %s" % repo_hashes)

    if (
        not changes
        and old_rosdoc_lite_hash == rosdoc_lite_version
        and old_jenkins_scripts_hash == jenkins_scripts_version
    ):
        print("There were no changes to any of the repositories we document. Not running documentation.")
        copy_test_results(workspace, docspace)
        tags_db.delete_tag_index_repo()

        # create marker files for all packages an upload them
        doc_path = os.path.realpath("%s/doc/%s" % (docspace, ros_distro))
        if os.path.exists(doc_path):
            shutil.rmtree(doc_path)
        repo_path = os.path.realpath("%s" % (docspace))
        stacks, manifest_packages, catkin_packages, _ = build_repo_structure(repo_path, doc_conf, depends_conf)
        folders = sorted(set(stacks.keys() + manifest_packages.keys() + catkin_packages.keys()))
        if folders:
            dsts = ["%s/api/%s/stamp" % (doc_path, f) for f in folders]
            for dst in dsts:
                os.makedirs(os.path.dirname(dst))
                with open(dst, "w"):
                    pass
            print("Uploading marker files to identify that documentation is up-to-date.")
            command = [
                "bash",
                "-c",
                'rsync -e "ssh -o StrictHostKeyChecking=no" -qr %s/api/ [email protected]:/home/rosbot/docs/%s/api'
                % (doc_path, ros_distro),
            ]
            call_with_list(command)

        return False

    # Make sure to update the versions of jenkins_scripts and rosdoc_lite for this repo list
    repo_hashes["rosdoc_lite-sys"] = rosdoc_lite_version
    repo_hashes["jenkins_scripts-sys"] = jenkins_scripts_version
    tags_db.set_rosinstall_hashes(repo, repo_hashes)
    return {"doc_conf": doc_conf, "depends_conf": depends_conf, "tags_db": tags_db}