def test_build_no_name():
    build = Build(app='myapp',
                  version='1.0',
                  source=git_directory(path='/var/tmp/vdist',
                                       branch='release-1.0'),
                  profile='ubuntu-trusty')
    assert build.name == 'myapp-1.0-ubuntu-trusty'
Esempio n. 2
0
def test_generate_deb_from_git_directory():
    tempdir = tempfile.gettempdir()
    checkout_dir = os.path.join(tempdir, 'vdist')

    git_p = subprocess.Popen(
        ['git', 'clone',
         'https://github.com/objectified/vdist',
         checkout_dir])
    git_p.communicate()

    builder = Builder()
    builder.add_build(
        app='vdist-test-generate-deb-from-git-dir',
        version='1.0',
        source=git_directory(
            path=checkout_dir,
            branch='master'
        ),
        profile='ubuntu-trusty'
    )
    builder.build()

    homedir = os.path.expanduser('~')
    target_file = os.path.join(
        homedir,
        '.vdist',
        'dist',
        'vdist-test-generate-deb-from-git-dir-1.0-ubuntu-trusty',
        'vdist-test-generate-deb-from-git-dir_1.0_amd64.deb'
    )
    assert os.path.isfile(target_file)
    assert os.path.getsize(target_file) > 0
def test_build_get_safe_dirname():
    build = Build(name='my build',
                  app='myapp-foo @#^&_',
                  version='1.0',
                  source=git_directory(path='/var/tmp/vdist',
                                       branch='release-1.0'),
                  profile='ubuntu-trusty')
    assert build.get_safe_dirname() == 'myapp-foo______-1.0-ubuntu-trusty'
def test_build_projectroot_from_git_directory():
    build = Build(name='my build',
                  app='myapp',
                  version='1.0',
                  source=git_directory(path='/var/tmp/vdist',
                                       branch='release-1.0'),
                  profile='ubuntu-trusty')
    assert build.get_project_root_from_source() == 'vdist'
def test_build_no_name():
    build = Build(
        app='myapp',
        version='1.0',
        source=git_directory(
            path='/var/tmp/vdist',
            branch='release-1.0'
        ),
        profile='ubuntu-trusty'
    )
    assert build.name == 'myapp-1.0-ubuntu-trusty'
def test_build_get_safe_dirname():
    build = Build(
        name='my build',
        app='myapp-foo @#^&_',
        version='1.0',
        source=git_directory(
            path='/var/tmp/vdist',
            branch='release-1.0'
        ),
        profile='ubuntu-trusty'
    )
    assert build.get_safe_dirname() == 'myapp-foo______-1.0-ubuntu-trusty'
def test_build_projectroot_from_git_directory():
    build = Build(
        name='my build',
        app='myapp',
        version='1.0',
        source=git_directory(
            path='/var/tmp/vdist',
            branch='release-1.0'
        ),
        profile='ubuntu-trusty'
    )
    assert build.get_project_root_from_source() == 'vdist'
Esempio n. 8
0
 def _process_listable_arguments(self, arguments):
     argument_keys = set(arguments.keys())
     listable_arguments_found = LISTABLE_ARGUMENTS.intersection(
         argument_keys)
     for argument in listable_arguments_found:
         generated_list = _create_list(arguments[argument])
         if argument == "source_git":
             self.builder_parameters["source"] = source.git(
                 generated_list[0], generated_list[1])
         if argument == "source_git_directory":
             self.builder_parameters["source"] = source.git_directory(
                 generated_list[0], generated_list[1])
         if argument in ["runtime_deps", "build_deps"]:
             self.builder_parameters[argument] = generated_list
Esempio n. 9
0
def _generate_rpm_from_git_directory(centos_version):
    tempdir = tempfile.gettempdir()
    checkout_dir = os.path.join(tempdir, 'vdist')

    git_p = subprocess.Popen(
        ['git', 'clone', 'https://github.com/objectified/vdist', checkout_dir])
    git_p.communicate()

    builder_parameters = {
        "app": 'vdist-test-generate-deb-from-git-dir',
        "version": '1.0',
        "source": git_directory(path=checkout_dir, branch='master'),
        "profile": centos_version
    }
    _ = _generate_rpm(builder_parameters, centos_version)
Esempio n. 10
0
def generate_rpm_from_git_directory(centos_version):
    tempdir = tempfile.gettempdir()
    checkout_dir = os.path.join(tempdir, 'vdist')

    git_p = subprocess.Popen(
        ['git', 'clone',
         'https://github.com/objectified/vdist',
         checkout_dir])
    git_p.communicate()

    builder_parameters = {"app": 'vdist-test-generate-deb-from-git-dir',
                          "version": '1.0',
                          "source": git_directory(path=checkout_dir,
                                                  branch='master'),
                          "profile": centos_version}
    _ = _generate_rpm(builder_parameters, centos_version)
Esempio n. 11
0
def _generate_rpm_from_git_directory(centos_version):
    with temporary_directory() as temp_dir, temporary_directory() as output_dir:
        git_p = subprocess.Popen(
            ['git', 'clone',
             'https://github.com/dante-signal31/vdist',
             temp_dir])
        git_p.communicate()

        builder_parameters = {"app": 'vdist-test-generate-deb-from-git-dir',
                              "version": '1.0',
                              "source": git_directory(path=temp_dir,
                                                      branch='vdist_tests'),
                              "profile": centos_version,
                              "output_folder": output_dir,
                              "output_script": True}
        _ = _generate_rpm(builder_parameters)
Esempio n. 12
0
from vdist.builder import Builder
from vdist.source import directory, git_directory

builder = Builder()

# build from a local directory
builder.add_build(name='my directory based build',
                  app='myproject',
                  version='1.0',
                  source=directory(path='/home/user/dev/yourproject'),
                  profile='centos6')

# or, build from a git repo *inside* a local directory
builder.add_build(name='my directory based build',
                  app='myproject',
                  version='1.0',
                  source=git_directory(path='/home/user/dev/anotherproject',
                                       branch='your-release-branch'),
                  profile='centos6')

# .. and build them in parallel
builder.build()
Esempio n. 13
0
def test_source_type_git_directory():
    s = git_directory(path='/foo/bar/', branch='foo')
    assert s['branch'] == 'foo'
    assert s['path'] == '/foo/bar'
Esempio n. 14
0
from vdist.builder import Builder
from vdist.source import directory, git_directory

builder = Builder()

# build from a local directory
builder.add_build(
    name='my directory based build',
    app='myproject',
    version='1.0',
    source=directory(
        path='/home/user/dev/yourproject'
    ),
    profile='centos6'
)

# or, build from a git repo *inside* a local directory
builder.add_build(
    name='my directory based build',
    app='myproject',
    version='1.0',
    source=git_directory(
        path='/home/user/dev/anotherproject',
        branch='your-release-branch'
    ),
    profile='centos6'
)

# .. and build them in parallel
builder.build()
Esempio n. 15
0
def _get_builder_parameters(app_name, profile_name, temp_dir, output_dir):
    builder_configurations = {
        ## TODO: Some tests fail if I leave app_name at "app" but not hardcode it. Give it a second thought and leave coherent.
        ## TODO: To much code redundancy in these configurations. See how to reduce it.
        "vdist-test-generate-deb-from-dir": {
            "app": app_name,
            "version": '1.0',
            "source": directory(path=temp_dir, ),
            "profile": profile_name,
            "output_folder": output_dir,
            "output_script": True
        },
        'vdist-test-generate-rpm-from-dir': {
            "app": 'vdist-test-generate-rpm-from-dir',
            "version": '1.0',
            "source": directory(path=temp_dir, ),
            "profile": profile_name,
            "output_folder": output_dir,
            "output_script": True
        },
        "vdist-test-generate-pkg-from-dir": {
            "app": app_name,
            "version": '1.0',
            "source": directory(path=temp_dir, ),
            "profile": profile_name,
            "output_folder": output_dir,
            "output_script": True
        },
        "vdist-test-generate-deb-from-git-dir": {
            "app": app_name,
            "version": '1.0',
            "source": git_directory(path=temp_dir, branch='vdist_tests'),
            "profile": 'ubuntu-lts',
            "output_folder": output_dir,
            "output_script": True
        },
        "vdist-test-generate-rpm-from-git-dir": {
            "app": app_name,
            "version": '1.0',
            "source": git_directory(path=temp_dir, branch='vdist_tests'),
            "profile": profile_name,
            "output_folder": output_dir,
            "output_script": True
        },
        "vdist-test-generate-pkg-from-git-dir": {
            "app": app_name,
            "version": '1.0',
            "source": git_directory(path=temp_dir, branch='vdist_tests'),
            "profile": profile_name,
            "output_folder": output_dir,
            "output_script": True
        },
        "vdist-test-generate-deb-from-git-suffixed": {
            "app":
            app_name,
            "version":
            '1.0',
            "source":
            git(uri='https://github.com/dante-signal31/vdist.git',
                branch='vdist_tests'),
            "profile":
            profile_name,
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "vdist-test-generate-rpm-from-git-suffixed": {
            "app":
            app_name,
            "version":
            '1.0',
            "source":
            git(uri='https://github.com/dante-signal31/vdist.git',
                branch='vdist_tests'),
            "profile":
            profile_name,
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "vdist-test-generate-pkg-from-git-suffixed": {
            "app":
            app_name,
            "version":
            '1.0',
            "source":
            git(uri='https://github.com/dante-signal31/vdist.git',
                branch='vdist_tests'),
            "profile":
            profile_name,
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "jtrouble_nosetup_nocompile": {
            "app":
            'jtrouble',
            "version":
            '1.0.0',
            "source":
            git(uri='https://github.com/objectified/jtrouble',
                branch='master'),
            "profile":
            profile_name,
            "compile_python":
            False,
            # Here happens the same than in
            # test_generate_deb_from_git_setup_nocompile()
            # "python_version": '3.4.4',
            "python_basedir":
            '/root/custom_python',
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "geolocate-test-generate-deb-from-git-setup-nocompile": {
            "app":
            'geolocate',
            "version":
            '1.4.1',
            "source":
            git(uri='https://github.com/dante-signal31/geolocate',
                branch='vdist_tests'),
            "profile":
            profile_name,
            "compile_python":
            False,
            # "python_version": '3.5.3',
            # Lets suppose custom python package is already installed and its root
            # folder is /root/custom_python.
            "python_basedir":
            '/root/custom_python',
            "fpm_args":
            FPM_ARGS_GEOLOCATE,
            "requirements_path":
            '/REQUIREMENTS.txt',
            "build_deps": [
                "python3-all-dev", "build-essential", "libssl-dev",
                "pkg-config", "libdbus-glib-1-dev", "gnome-keyring",
                "libffi-dev"
            ],
            "runtime_deps": ["libssl1.0.0", "python3-dbus", "gnome-keyring"],
            "after_install":
            'packaging/postinst.sh',
            "after_remove":
            'packaging/postuninst.sh',
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "geolocate-test_generate_rpm_from_git_setup_nocompile_centos": {
            "app":
            'geolocate',
            "version":
            '1.4.1',
            "source":
            git(uri='https://github.com/dante-signal31/geolocate',
                branch='vdist_tests'),
            "profile":
            profile_name,
            "compile_python":
            False,
            # "python_version": '3.4.4',
            # Lets suppose custom python package is already installed and its root
            # folder is '/root/custom_python'.
            "python_basedir":
            '/root/custom_python',
            "fpm_args":
            FPM_ARGS_GEOLOCATE,
            "requirements_path":
            '/REQUIREMENTS.txt',
            "build_deps": [
                "python3-all-dev", "build-essential", "libssl-dev",
                "pkg-config", "libdbus-glib-1-dev", "gnome-keyring",
                "libffi-dev"
            ],
            "runtime_deps": ["libssl1.0.0", "python3-dbus", "gnome-keyring"],
            "after_install":
            'packaging/postinst.sh',
            "after_remove":
            'packaging/postuninst.sh',
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "geolocate-test-generate-pkg-from-git-setup-nocompile": {
            "app":
            'geolocate',
            "version":
            '1.4.1',
            "source":
            git(uri='https://github.com/dante-signal31/geolocate',
                branch='vdist_tests'),
            "profile":
            profile_name,
            "compile_python":
            False,
            # "python_version": '3.4.4',
            # Lets suppose custom python package is already installed and its root
            # folder is '/root/custom_python'.
            "python_basedir":
            '/root/custom_python',
            "fpm_args":
            FPM_ARGS_GEOLOCATE,
            "requirements_path":
            '/REQUIREMENTS.txt',
            "build_deps": [
                "python3", "base-devel", "openssl", "pkg-config", "dbus-glib",
                "gnome-keyring", "libffi"
            ],
            "runtime_deps": ["openssl", "python-dbus", "gnome-keyring"],
            "after_install":
            'packaging/postinst.sh',
            "after_remove":
            'packaging/postuninst.sh',
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "jtrouble-test-generate-package-from-git-nosetup-compile": {
            "app":
            'jtrouble',
            "version":
            '1.0.0',
            "source":
            git(uri='https://github.com/objectified/jtrouble',
                branch='master'),
            "profile":
            profile_name,
            "package_install_root":
            "/opt",
            "python_basedir":
            "/opt/python",
            "compile_python":
            True,
            "python_version":
            '3.4.4',
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "vdist-test-generate-package-from-git-setup-compile": {
            "app":
            'vdist',
            "version":
            '1.1.0',
            "source":
            git(uri='https://github.com/dante-signal31/vdist',
                branch='vdist_tests'),
            "profile":
            profile_name,
            "compile_python":
            True,
            "python_version":
            '3.5.3',
            "fpm_args":
            FPM_ARGS_VDIST,
            "requirements_path":
            '/REQUIREMENTS.txt',
            "runtime_deps": ["openssl", "docker-ce"],
            "after_install":
            'packaging/postinst.sh',
            "after_remove":
            'packaging/postuninst.sh',
            "output_folder":
            output_dir,
            "output_script":
            True
        },
        "vdist-test-generate-from-git": {
            "app":
            app_name,
            "version":
            '1.0',
            "source":
            git(uri='https://github.com/dante-signal31/vdist',
                branch='vdist_tests'),
            "profile":
            profile_name,
            "output_folder":
            output_dir,
            "output_script":
            True
        }
    }
    return builder_configurations[app_name]