Beispiel #1
0
def rubocop_test():
    """
    Tests the style of the ruby project using rubocop
    :return: None
    """
    install_gem("rubocop")
    process_call(["rubocop"])
Beispiel #2
0
def progstats_transfer(data: str, topic: str, project: str):
    """
    Transfers progstats contents to the progstats instance using rsync
    :param data: The path to the data to transfer
    :param topic: The progstats topic name
    :param project: The progstats project name
    :return: None
    """

    progstats_data_path = os.environ["PROGSTATS_DATA_PATH"]
    progstats_data_port = os.environ["PROGSTATS_DATA_PORT"]
    progstats_host = progstats_data_path.split(":")[0]
    destination = os.path.join(progstats_data_path, topic, project)
    project_path = destination.split(":")[1]

    if os.path.isdir(data) and not data.endswith("/"):
        data += "/"
    elif os.path.isfile(data):
        destination += "." + data.rsplit(".")[1]

    mkdir_cmd = [
        "ssh", "-p", progstats_data_port, progstats_host,
        "mkdir -p " + project_path
    ]
    rsync_cmd = [
        "rsync", "-a", "--delete-after", "-e", "ssh -p " + progstats_data_port,
        data, destination
    ]
    process_call(mkdir_cmd)
    process_call(rsync_cmd)
Beispiel #3
0
def install_package(package: str):
    """
    Installs an npm package
    :param package: The name of the package to install
    :return: None
    """
    process_call(["npm", "install", package])
Beispiel #4
0
def install_gem(gem: str):
    """
    Installs a gem
    :param gem: The gem to install
    :return: None
    """
    make_sure_in_path()
    process_call(["gem", "install", gem])
Beispiel #5
0
def install_composer():
    """
    Installs composer locally
    :return: None
    """
    urlretrieve("https://getcomposer.org/installer", "install-composer")
    process_call(["php", "install-composer"])
    os.remove("install-composer")
Beispiel #6
0
def checkstyle():
    """
    Runs checkstyle on the PHP project
    :return: None
    """
    process_call(["./composer.phar", "update"])
    process_call([
        "php", "vendor/phpcheckstyle/phpcheckstyle/run.php", "--src", "src",
        "--src", "test", "--config", "config/checkstyle.xml"
    ])
Beispiel #7
0
def rdoc():
    """
    Creates documentation using rdoc and rsync it for use in progstats
    :return: None
    """
    install_gem("rdoc")
    process_call(["rdoc", "--exclude=virtual"])

    destination = os.environ["PROGSTATS_DATA_PATH"]
    project = os.environ["CI_PROJECT_NAME"]
    dest = os.path.join(destination, "doc_html", project)

    process_call(["rsync", "-a", "--delete-after", "doc/", dest])
Beispiel #8
0
def gem_build():
    """
    Builds gem for project
    :return: None
    """
    if not os.path.isdir("artifacts"):
        os.mkdir("artifacts")

    project = os.environ["CI_PROJECT_NAME"]

    process_call(["gem", "build", project + ".gemspec"])

    for child in os.listdir("."):
        if child.endswith(".gem"):
            os.rename(child, os.path.join("artifacts", child))
Beispiel #9
0
def gem_publish():
    """
    Publishes a gem
    :return: None
    """
    gemdir = os.path.join(os.path.expanduser("~"), ".gem")
    if not os.path.isdir(gemdir):
        os.mkdir(gemdir)

    cred_file = os.path.join(gemdir, "credentials")
    with open(cred_file, "w") as f:
        f.write(os.environ["RUBYGEMS_CREDENTIALS"])
    process_call(["chmod", "0600", cred_file])

    for gemfile in os.listdir("artifacts"):
        if gemfile.endswith(".gem"):
            process_call(["gem", "push", os.path.join("artifacts", gemfile)])

    os.remove(cred_file)
Beispiel #10
0
def docgen():
    """
    Generates documentation
    :return: None
    """
    process_call(["./composer.phar", "update"])
    process_call(["vendor/bin/phpdoc", "-d", "src"])

    dest = os.path.join(os.environ["PROGSTATS_DATA_PATH"], "doc_html",
                        os.environ["CI_PROJECT_NAME"])
    process_call(["rsync", "-a", "--delete-after", "output/", dest])
Beispiel #11
0
def unittest():
    """
    Runs PHP unit tests
    :return: None
    """
    process_call(["./composer.phar", "update"])
    copyfile("config/phpunit.xml", "phpunit.xml")
    process_call(["vendor/bin/phpunit", "test", "--coverage-html=coverage"])
    os.remove("phpunit.xml")

    dest = os.path.join(os.environ["PROGSTATS_DATA_PATH"], "coverage",
                        os.environ["CI_PROJECT_NAME"])
    process_call(["rsync", "-a", "--delete-after", "coverage/", dest])