Skip to content

Commit

Permalink
Merge branch 'release/0.24.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Mar 7, 2019
2 parents 06f959a + 395ef90 commit 81b9109
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 59 deletions.
29 changes: 6 additions & 23 deletions .ci/travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,19 @@ set -e
set -x

if [[ "$(uname -s)" == 'Darwin' ]]; then
brew update || brew update
brew update
brew install openssl readline
brew outdated pyenv || brew upgrade pyenv
brew install pyenv-virtualenv

if which pyenv > /dev/null; then
eval "$(pyenv init -)"
fi
if which pyenv > /dev/null; then
eval "$(pyenv init -)"
fi
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

case "${PYVER}" in
py27)
pyenv install 2.7.10
pyenv virtualenv 2.7.10 conan
;;
py33)
pyenv install 3.3.6
pyenv virtualenv 3.3.6 conan
;;
py34)
pyenv install 3.4.3
pyenv virtualenv 3.4.3 conan
;;
py35)
pyenv install 3.5.0
pyenv virtualenv 3.5.0 conan
;;
py36)
pyenv install 3.6.0
pyenv virtualenv 3.6.0 conan
;;
py37)
pyenv install 3.7.1
pyenv virtualenv 3.7.1 conan
Expand All @@ -44,6 +25,8 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
esac
pyenv rehash
pyenv activate conan

python --version
else
sudo apt-get update
sudo apt-get install gcc-multilib g++-multilib
Expand Down
2 changes: 2 additions & 0 deletions .ci/travis/requirements_travis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tox-travis>=0.11
-r ../../cpt/requirements_test.txt
2 changes: 1 addition & 1 deletion .ci/travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ fi

conan user
mkdir ~/.conan/data
nosetests cpt.test --nocapture
tox
51 changes: 33 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
cache: pip
sudo: false
language: python
python:
- 2.7
- 3.6
os: linux
dist: xenial
dist: trusty

matrix:
include:
- language: generic
os: osx
env: PYVER=py27
jobs:
fast_finish: true
include:

- stage: Conan Latest - Linux
python: 2.7
env: TOXENV=py27-conanlatest
- python: 3.7
env: TOXENV=py37-conanlatest
dist: xenial

- stage: Conan Development - Linux
python: 2.7
env: TOXENV=py27-conandev
- python: 3.7
env: TOXENV=py37-conandev
dist: xenial

# Macos is slow, only if everything has passed
- stage: Macos - all Conan versions
language: generic
os: osx
osx_image: xcode8.3
env: PYVER=py27 TOXENV=py27-conanlatest
- language: generic
os: osx
osx_image: xcode8.3
env: PYVER=py37 TOXENV=py37-conanlatest

# command to install dependencies
install:
- ./.ci/travis/install.sh
before_script:
- export PYTHONPATH=$PYTHONPATH:$(pwd)
- export CONAN_TEST_SUITE=1
# command to run tests
- .ci/travis/install.sh

script:
- ./.ci/travis/run.sh
- .ci/travis/run.sh
4 changes: 2 additions & 2 deletions cpt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

__version__ = '0.23.0'
NEWEST_CONAN_SUPPORTED = "1.12"
__version__ = '0.24.0'
NEWEST_CONAN_SUPPORTED = "1.14.0-dev"
52 changes: 52 additions & 0 deletions cpt/ci_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def is_circle_ci():
return os.getenv("CIRCLECI", False)


def is_azure_pipelines():
return os.getenv("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", False)


def is_shippable():
return os.getenv("SHIPPABLE", False)


class CIManager(object):
def __init__(self, printer):

Expand All @@ -44,6 +52,10 @@ def __init__(self, printer):
self.manager = GitlabManager(printer)
elif is_jenkins():
self.manager = JenkinsManager(printer)
elif is_azure_pipelines():
self.manager = AzurePipelinesManager(printer)
elif is_shippable():
self.manager = ShippableManager(printer)
else:
self.manager = GenericManager(printer)

Expand Down Expand Up @@ -244,3 +256,43 @@ def get_commit_id(self):

def get_branch(self):
return os.getenv("BRANCH_NAME", None)


class AzurePipelinesManager(GenericManager):
def __init__(self, printer):
super(AzurePipelinesManager, self).__init__(printer)
self.printer.print_message("CI detected: Azure Pipelines")

def get_commit_msg(self):
return os.getenv("BUILD_SOURCEVERSIONMESSAGE", None)

def get_commit_id(self):
return os.getenv("BUILD_SOURCEVERSION", None)

def get_branch(self):
return os.getenv("BUILD_SOURCEBRANCHNAME", None)

def is_pull_request(self):
return os.getenv("BUILD_REASON", "false") == "PullRequest"


class ShippableManager(GenericManager):

def __init__(self, printer):
super(ShippableManager, self).__init__(printer)
self.printer.print_message("CI detected: Shippable")

def get_commit_msg(self):
return os.getenv("COMMIT_MESSAGE", None)

def get_commit_id(self):
return os.getenv("COMMIT", None)

def get_branch(self):
return os.getenv("BRANCH", None)

def is_pull_request(self):
return os.getenv("IS_PULL_REQUEST", None) == "true"

def is_tag(self):
return os.getenv("IS_GIT_TAG", None) == "true"
2 changes: 1 addition & 1 deletion cpt/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def add_common_builds(self, shared_option_name=None, pure_c=True,

if shared_option_name is None:
if os.path.exists(os.path.join(self.cwd, "conanfile.py")):
conanfile = load_cf_class("./conanfile.py", self.conan_api)
conanfile = load_cf_class(os.path.join(self.cwd, "conanfile.py"), self.conan_api)
if hasattr(conanfile, "options") and conanfile.options and "shared" in conanfile.options:
shared_option_name = "%s:shared" % self.reference.name

Expand Down
5 changes: 1 addition & 4 deletions cpt/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
idna==2.6
six>=1.10.0
requests[security]
conan>=1.7.0, <1.13.0
conan>=1.7.0, <1.14.0
tabulate==0.8.2
pyOpenSSL>=16.0.0, <19.0.0
4 changes: 3 additions & 1 deletion cpt/requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
nose>=1.3.7
nose_parameterized>=0.5.0, <0.6.0
mock>=1.3.0, <1.4.0
WebTest>=2.0.18, <2.1.0
WebTest>=2.0.18, <2.1.0
tox>=3.7.0
tox-venv>=0.3.1
17 changes: 17 additions & 0 deletions cpt/test/integration/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ class Pkg(ConanFile):
self.packager.add_common_builds(shared_option_name=False)
self.assertNotIn("lib2:shared", self.packager.items[0].options)

def test_auto_managed_subdirectory(self):
conanfile = """from conans import ConanFile
class Pkg(ConanFile):
name = "lib"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
"""
cwd = os.path.join(self.tmp_folder, "subdirectory")
tools.save(os.path.join(cwd, "conanfile.py"), conanfile)
self.packager = ConanMultiPackager(username="lasote", cwd=cwd)
self.packager.add_common_builds()
self.assertGreater(len(self.packager.items), 0)
self.assertIn("lib:shared", self.packager.items[0].options)

def test_exported_files(self):
conanfile = """from conans import ConanFile
Expand Down
3 changes: 2 additions & 1 deletion cpt/test/test_client/upload_checks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def test_upload_when_tag_is_false(self):

with environment_append({"CONAN_UPLOAD": ts.fake_url, "CONAN_LOGIN_USERNAME": "user",
"CONAN_PASSWORD": "password", "CONAN_USERNAME": "user",
"CONAN_CONFIG_URL": zip_path, "CONAN_UPLOAD_ONLY_WHEN_TAG": "1"}):
"CONAN_CONFIG_URL": zip_path, "CONAN_UPLOAD_ONLY_WHEN_TAG": "1",
"TRAVIS": "1"}):

mp = get_patched_multipackager(tc, exclude_vcvars_precommand=True)
mp.add_common_builds(shared_option_name=False)
Expand Down
56 changes: 49 additions & 7 deletions cpt/test/unit/ci_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ def test_skip(self):
ret = packager.run()
self.assertEquals(ret, 99)

def test_instance_correct(self):
# Bamboo
def test_bamboo_instance(self):
with tools.environment_append({"bamboo_buildNumber": "xx",
"bamboo_planRepository_branch": "mybranch"}):
manager = CIManager(self.printer)
self.assertEquals(manager.get_branch(), "mybranch")
self.assertIsNotNone(manager.get_commit_msg())

# Travis
def test_travis_instance(self):
with tools.environment_append({"TRAVIS": "1",
"TRAVIS_COMMIT_MESSAGE": "msg",
"TRAVIS_BRANCH": "mybranch",
Expand All @@ -52,7 +51,7 @@ def test_instance_correct(self):
self.assertEquals(manager.get_commit_msg(), "msg")
self.assertEquals(manager.get_commit_id(), "506c89117650bb12252db26d35b8c2385411f175")

# Appveyor
def test_appveyor_instance(self):
with tools.environment_append({"APPVEYOR": "1",
"APPVEYOR_REPO_COMMIT_MESSAGE": "msg",
"APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED": "more",
Expand Down Expand Up @@ -87,7 +86,7 @@ def test_instance_correct(self):
self.assertIsNone(manager.get_branch())
self.assertEquals(manager.get_commit_msg(), "msg")

# Circle CI
def test_circleci_instance(self):
with tools.environment_append({"CIRCLECI": "1",
"CIRCLE_BRANCH": "mybranch",
"CIRCLE_SHA1": "506c89117650bb12252db26d35b8c2385411f175",
Expand All @@ -97,7 +96,7 @@ def test_instance_correct(self):
self.assertIsNotNone(manager.get_commit_msg())
self.assertEquals(manager.get_commit_id(), "506c89117650bb12252db26d35b8c2385411f175")

# Gitlab
def test_gitlab_instance(self):
with tools.environment_append({"GITLAB_CI": "1",
"CI_BUILD_REF_NAME": "mybranch",
"CI_COMMIT_TITLE": "foo bar",
Expand All @@ -108,7 +107,7 @@ def test_instance_correct(self):
self.assertIsNotNone(manager.get_commit_msg())
self.assertEquals(manager.get_commit_id(), "506c89117650bb12252db26d35b8c2385411f175")

# Jenkins
def test_jenkins_instance(self):
with tools.environment_append({"JENKINS_URL": "1",
"BRANCH_NAME": "mybranch",
"GIT_COMMIT": "506c89117650bb12252db26d35b8c2385411f175",
Expand All @@ -118,6 +117,49 @@ def test_instance_correct(self):
self.assertIsNotNone(manager.get_commit_msg())
self.assertEquals(manager.get_commit_id(), "506c89117650bb12252db26d35b8c2385411f175")

def test_azure_instance(self):
with tools.environment_append({"SYSTEM_TEAMFOUNDATIONCOLLECTIONURI": "https://dev.azure.com/",
"BUILD_SOURCEVERSIONMESSAGE": "msg",
"BUILD_SOURCEVERSION": "506c89117650bb12252db26d35b8c2385411f175",
"BUILD_SOURCEBRANCHNAME": "mybranch",
"BUILD_REASON": "manual",
}):
manager = CIManager(self.printer)
self.assertEquals(manager.get_branch(), "mybranch")
self.assertEquals(manager.get_commit_msg(), "msg")
self.assertEquals(manager.get_commit_id(), "506c89117650bb12252db26d35b8c2385411f175")
self.assertEquals(manager.is_pull_request(), False)

def test_shippable_instance(self):
shippable_env = { "SHIPPABLE": "true",
"COMMIT_MESSAGE": "foobar [qux]",
"COMMIT": "98e984eacf4e3dfea431c8850c8c181a08e8cf3d",
"BRANCH": "testing/5.6.5",
"IS_GIT_TAG": "false",
"IS_PULL_REQUEST": "false"}
with tools.environment_append(shippable_env):
manager = CIManager(self.printer)
self.assertEquals(manager.get_branch(), shippable_env["BRANCH"])
self.assertEquals(manager.get_commit_msg(), shippable_env["COMMIT_MESSAGE"])
self.assertEquals(manager.get_commit_id(), shippable_env["COMMIT"])
self.assertEquals(manager.is_pull_request(), False)
self.assertEquals(manager.is_tag(), False)

shippable_env = { "SHIPPABLE": "true",
"COMMIT_MESSAGE": "new tag",
"COMMIT": "98e984eacf4e3dfea431c8850c8c181a08e8cf3d",
"BRANCH": "release/5.6.5",
"IS_GIT_TAG": "true",
"IS_PULL_REQUEST": "true"}
with tools.environment_append(shippable_env):
manager = CIManager(self.printer)
self.assertEquals(manager.get_branch(), shippable_env["BRANCH"])
self.assertEquals(manager.get_commit_msg(), shippable_env["COMMIT_MESSAGE"])
self.assertEquals(manager.get_commit_id(), shippable_env["COMMIT"])
self.assertEquals(manager.is_pull_request(), True)
self.assertEquals(manager.is_tag(), True)


def test_build_policy(self):
# Travis
with tools.environment_append({"TRAVIS": "1",
Expand Down
2 changes: 1 addition & 1 deletion cpt/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def upload_packages(self, reference, upload, package_id):
remote_name=remote_name,
force=True,
retry=int(self._upload_retry))
elif Version(client_version) < Version("1.13.0"):
elif Version(client_version) < Version("1.14.0"):
self.conan_api.upload(str(reference),
all_packages=True,
remote_name=remote_name,
Expand Down
20 changes: 20 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tox]
skipsdist = True

envlist =
py{27,37}-conan{latest,dev}

[testenv]
deps =
-rcpt/requirements_test.txt
tabulate
conanlatest: conan
conandev: https://github.com/conan-io/conan/archive/develop.tar.gz

setenv =
PYTHONDONTWRITEBYTECODE=1
PYTHONPATH = {toxinidir}:{env:PYTHONPATH:}
CONAN_TEST_SUITE=1

commands =
nosetests {posargs:cpt.test}

0 comments on commit 81b9109

Please sign in to comment.