Exemplo n.º 1
0
def synchronize_branch_with_master(workspace, git_branch):
    with lcd(os.path.join(workspace)):
        exe("git checkout master", remote=False)
        exe("git fetch origin", remote=False)
        exe("git merge origin/master", remote=False)
        exe("git checkout {0}".format(git_branch), remote=False)
        exe("git merge origin/{}".format(git_branch), remote=False)
Exemplo n.º 2
0
        def release(self):
            """Create & upload the package

            """
            with self.cwd(self.path):
                # Edit the package version
                if not exe("sed -i 's/VERSION = .*/VERSION = \"{0}\"/g' setup.py"
                           .format(self.share_memory["latest_version"]), remote=self.remote):
                    raise CIBuildPackageFail("Failed to update the version")

                # Build package
                if not exe("make release", remote=self.remote):
                    raise CIBuildPackageFail("Release failed for the wheel package")

                self.logger.info("Wheel package built & uploaded")
Exemplo n.º 3
0
    def create_archive(self):
        """Create a zip archive for the quay build

        """
        archive_name = str(uuid4()) + ".tar.xz"
        compress_command = "tar Jcvf  {} .".format(archive_name)
        with self.cwd(self.path):
            if not exe(compress_command, remote=self.remote):
                raise CIBuildPackageFail("the command : {} executed in the directory {} return False"
                                         .format(compress_command, self.path))

        self.share_memory["archive_for_build"] = self.path + "/" + archive_name
        self.logger.info("Tar archive built")
Exemplo n.º 4
0
    def __command(self, cmd, force_return_code=None):
        """Run the command indicated in the yaml file in the package directory
            Args:
                cmd (str): the command that be executed
                force_return_code (bool): Force the return code if necessary

            Raise:
                CITestFail: An error occurred when the test failed
        """
        if cmd != "" and cmd is not None:
            with self.cwd(self.path):
                with settings(warn_only=True):
                    if not exe(cmd, remote=self.remote, force_return_code=force_return_code):
                        raise CITestFail("Test failed, on command: {}, remote: {}".format(cmd, self.remote))
Exemplo n.º 5
0
        def create_archive(self):
            """Create a zip archive for the quay build

            """
            if self.package_info["build_info"]["build_type"] == "url":
                archive_name = str(uuid4()) + ".zip"
                zip_command = "zip -r {} *".format(archive_name)
                with self.cwd(self.path):
                    if not exe(zip_command, remote=self.remote):
                        raise CIBuildPackageFail("the command : {} executed in the directory {} return False"
                                                 .format(zip_command, self.path))

                self.share_memory["archive_for_build"] = self.path + "/" + archive_name
                self.logger.info("Zip archive built")
            else:
                self.logger.info("Zip archive skipped, it' only for url build")
Exemplo n.º 6
0
def test_exe_force_return_code(mocker, fake_fabric, remote, force_return_code):
    fabric_object = fake_fabric(force_return_code)
    mocker.patch("loktar.cmd.local", return_value=fabric_object)
    mocker.patch("loktar.cmd.run", return_value=fabric_object)

    assert exe("ls -la", remote=remote, force_return_code=force_return_code) is force_return_code
Exemplo n.º 7
0
def test_exe_fail(mocker, remote):
    mocker.patch("loktar.cmd.local", return_value=FakeFabricFail())
    mocker.patch("loktar.cmd.run", return_value=FakeFabricFail())

    assert exe("ls -la", remote=remote) is False
Exemplo n.º 8
0
def test_exe(mocker, remote):
    mocker.patch("loktar.cmd.local", return_value=FakeFabricSuccess())
    mocker.patch("loktar.cmd.run", return_value=FakeFabricSuccess())

    assert exe("ls -la", remote=remote) is True
Exemplo n.º 9
0
def _find_modified_files_from_local_git(git_branch, **kwargs):
    with cwd(kwargs.get("workspace"), remote=kwargs.get("remote")):
        exe("git checkout {}".format(git_branch), remote=kwargs.get("remote"))
        git_diff = exe("git diff HEAD~ HEAD --name-only", remote=kwargs.get("remote"))
        return filter(None, list(set(git_diff.split("\n"))))