def package_pipeline(ci, repository, branch, upload=None, lockfile=None):
    job, job_folder = ci.new_job()
    job_folder += "_pkg"
    cache_folder = os.path.join(job_folder, "cache")
    os.makedirs(cache_folder, exist_ok=True)
    with setenv("CONAN_USER_HOME", cache_folder):
        ci.run("conan config set general.revisions_enabled=True")
        ci.run(
            "conan config set general.default_package_id_mode=recipe_revision_mode"
        )
        ci.run("conan remote remove conan-center")
        ci.run(
            "conan remote add master http://localhost:8081/artifactory/api/conan/ci-master -f"
        )
        ci.run("conan user admin -p=password -r=master")
        with chdir(job_folder):
            ci.run("git clone %s" % repository)
            repo_folder = os.path.basename(repository)
            with chdir(repo_folder):
                ci.run("git checkout %s" % branch)
                os.makedirs("build")
                with chdir("build"):
                    # This build is external to Conan
                    if lockfile:
                        save("conan.lock", lockfile)
                    else:
                        ci.run("conan graph lock ..")
                    ci.run("conan install .. --lockfile")
                    ci.run('cmake ../src -G "Visual Studio 15 Win64"')
                    ci.run('cmake --build . --config Release')
                    ci.run(
                        "conan export-pkg .. user/testing --ignore-dirty --lockfile"
                    )
        if upload:
            ci.run("conan upload * -r=%s --all --confirm" % upload)
def package_pipeline(ci, repository, branch):
    job, job_folder = ci.new_job()
    cache_folder = os.path.join(job_folder, "cache")
    os.makedirs(cache_folder, exist_ok=True)
    with setenv("CONAN_USER_HOME", cache_folder):
        ci.run("conan remote remove conan-center")
        ci.run("conan remote add master http://localhost:8081/artifactory/api/conan/ci-master -f")
        ci.run("conan user admin -p=password -r=master")
        with chdir(job_folder):
            ci.run("git clone %s" % repository)
            repo_folder = os.path.basename(repository)
            with chdir(repo_folder):
                ci.run("git checkout %s" % branch)
                ci.run("conan create . user/testing")
        if branch == "master":
            ci.run("conan upload * -r=master --all --confirm")
Beispiel #3
0
 def local_build(self, lockfile=None):
     lockfile = "" if not lockfile else " --lockfile=%s" % lockfile
     shutil.rmtree("build", ignore_errors=True)
     os.mkdir("build")
     with chdir("build"):
         self._run("conan install .. %s" % lockfile)
         self._run('cmake ../src -G "Visual Studio 15 Win64"')
         self._run('cmake --build . --config Release')
Beispiel #4
0
    def test_merge_pull_request(self):
        repo1 = self.setup_repo()
        repo2 = self.setup_clone(repo1)
        content = "this is s a dsafsdf"

        pull_request = PullRequest()
        pull_request.from_repo_id = repo2.id
        pull_request.from_branch = 'master'
        pull_request.to_repo_id = repo1.id
        pull_request.to_branch = 'master'
        pull_request.user_id = repo2.owner_id

        with mkdtemp() as work_path:
            with chdir(work_path):
                check_call(('git clone %s %s'%(repo1.clone_addr, work_path)).split())
                with open(join(work_path, 'orig'), 'w') as f:
                    f.write(content)
                check_call('git add .'.split())
                check_call('git commit -m"f"  -a'.split())
                check_call('git push origin master'.split())

        with mkdtemp() as work_path:
            with chdir(work_path):
                check_call(('git clone %s %s'%(repo2.clone_addr, work_path)).split())
                with open(join(work_path, 'new_file'), 'w') as f:
                    f.write(content)
                check_call('git add .'.split())
                check_call('git commit -m"f"  -a'.split())
                check_call('git push origin master'.split())

        pull_request.merge()

        with mkdtemp() as work_path:
            with chdir(work_path):
                check_call(('git clone %s %s'%(repo1.clone_addr, work_path)).split())
                with open("new_file") as f:
                    self.assertEqual(f.read(), content)
Beispiel #5
0
def create_new_repo(user, name, desc):
    new_repo = Repo()
    new_repo.owner_id = user.id
    new_repo.name = name
    new_repo.desc = desc
    check_call(('git init %s --bare'%new_repo.repo_path).split())
    with mkdtemp() as temp:
        check_call(['git','clone',new_repo.repo_path, temp])
        with chdir(temp):
            check_call(['touch','README'])
            check_call(['git', 'add', '.'])
            check_call(['git','commit','-m','first commit'])
            check_call(['git','push','origin', 'master'])
    new_repo.save()
    return new_repo
def product_pipeline(ci):
    job, job_folder = ci.new_job()
    job_folder += "_product"
    cache_folder = os.path.join(job_folder, "cache")
    os.makedirs(cache_folder, exist_ok=True)
    with setenv("CONAN_USER_HOME", cache_folder):
        ci.run("conan config set general.revisions_enabled=True")
        ci.run(
            "conan config set general.default_package_id_mode=recipe_revision_mode"
        )
        ci.run("conan remote remove conan-center")
        ci.run(
            "conan remote add master http://localhost:8081/artifactory/api/conan/ci-master -f"
        )
        ci.run("conan user admin -p=password -r=master")
        with chdir(job_folder):
            ci.run("conan graph lock app/[~1.0]@user/testing --build"
                   )  # Always all build, as soon as we export, it will change
            lockfile = load("conan.lock")
            ci.run(
                "conan graph build-order . --build=missing --json=build-order.json"
            )
            build_order = json.loads(load("build-order.json"))
            print("*********** BUILD-ORDER *******************\n%s" %
                  build_order)
            for level_to_build in build_order:
                for to_build in level_to_build:
                    ref = to_build[1].split(":")[0]
                    print("Building ", ref)
                    ci.run("conan inspect %s -a=scm --json=scm.json" % ref)
                    scm = json.loads(load("scm.json"))["scm"]
                    os.remove("scm.json")
                    url = scm["url"]
                    revision = scm["revision"]
                    package_pipeline(ci,
                                     url,
                                     branch=revision,
                                     lockfile=lockfile,
                                     upload="master")

            ci.run(
                "conan install app/[~1.0]@user/testing --lockfile -g=deploy")
            ci.run(r".\app\bin\main_app.exe")
Beispiel #7
0
 def wrapper(user, *args, **kwargs):
     with chdir(user.current_folder):
         with setenv("CONAN_USER_HOME", user.user_cache):
             return f(user, *args, **kwargs)