Skip to content

Commit

Permalink
#518 Allow uploading Boost packages
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <[email protected]>
  • Loading branch information
uilianries committed Nov 2, 2018
1 parent 0752c63 commit 264e192
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 deletions.
2 changes: 1 addition & 1 deletion bincrafters/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.17.4'
__version__ = '0.17.5'
7 changes: 1 addition & 6 deletions bincrafters/build_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
from cpt.tools import split_colon_env


def get_bool_from_env(var_name, default="0"):
val = os.getenv(var_name) or default
return str(val).lower() in ["1", "true", "yes", "y"]


def get_value_from_recipe(search_string, recipe="conanfile.py"):
with open(recipe, "r") as conanfile:
contents = conanfile.read()
Expand Down Expand Up @@ -119,7 +114,7 @@ def get_conan_remotes(username):


def get_upload_when_stable():
return get_bool_from_env("CONAN_UPLOAD_ONLY_WHEN_STABLE", default="1")
return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)


def get_os():
Expand Down
20 changes: 10 additions & 10 deletions bincrafters/build_template_boost_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
from bincrafters import build_shared
from bincrafters import build_template_default
from conans import tools


def add_boost_shared(build):
Expand All @@ -23,15 +24,14 @@ def get_builder(shared_option_name=None,

# Bincrafters default is to upload only when stable, but boost is an exception
# Empty string allows boost packages upload for testing branch
os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = ""
with tools.environment_append({"CONAN_UPLOAD_ONLY_WHEN_STABLE": ""}):
shared_option_name = False if shared_option_name is None and not build_shared.is_shared() else shared_option_name

shared_option_name = False if shared_option_name is None and not build_shared.is_shared() else shared_option_name
builder = build_template_default.get_builder(
shared_option_name=shared_option_name,
pure_c=pure_c,
dll_with_static_runtime=dll_with_static_runtime,
build_policy=build_policy)
builder.builds = map(add_boost_shared, builder.items)

builder = build_template_default.get_builder(
shared_option_name=shared_option_name,
pure_c=pure_c,
dll_with_static_runtime=dll_with_static_runtime,
build_policy=build_policy)
builder.builds = map(add_boost_shared, builder.items)

return builder
return builder
11 changes: 7 additions & 4 deletions bincrafters/build_template_boost_header_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

import os
from bincrafters import build_template_header_only
from conans import tools


def get_builder(**kwargs):

# Bincrafters default is to upload only when stable, but boost is an exception
# Empty string allows boost packages upload for testing branch
os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = ""
with tools.environment_append({"CONAN_UPLOAD_ONLY_WHEN_STABLE": ""}):

return build_template_header_only.get_builder(**kwargs)
# Bincrafters default is to upload only when stable, but boost is an exception
# Empty string allows boost packages upload for testing branch
os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = ""

return build_template_header_only.get_builder(**kwargs)
20 changes: 8 additions & 12 deletions tests/test_package_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def set_matrix_variables():
elif platform.system() == "Darwin":
os.environ["CONAN_APPLE_CLANG_VERSIONS"] = "9.0"


@pytest.fixture()
def set_minimal_build_environment():
os.environ["CONAN_ARCHS"] = "x86"
Expand All @@ -29,16 +30,8 @@ def set_minimal_build_environment():
del os.environ["CONAN_ARCHS"]
del os.environ["CONAN_BUILD_TYPES"]

@pytest.fixture()
def set_upload_when_stable():
os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = "FOOBAR"


def get_upload_when_stable():
return os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"]


def test_build_template_boost_default(set_upload_when_stable):
def test_build_template_boost_default():
builder = build_template_boost_default.get_builder()

for settings, options, env_vars, build_requires, reference in builder.items:
Expand All @@ -54,7 +47,7 @@ def test_build_template_boost_default(set_upload_when_stable):
elif platform.system() == "Darwin":
assert 4 == len(builder.items)

assert "" == get_upload_when_stable()
assert builder.upload_only_when_stable == ""


def test_build_template_default():
Expand Down Expand Up @@ -120,12 +113,12 @@ def test_build_header_only():
assert 1 == len(builder.items)


def test_build_boost_header_only(set_upload_when_stable):
def test_build_boost_header_only():
builder = build_template_boost_header_only.get_builder()
for settings, options, env_vars, build_requires, reference in builder.items:
assert 0 == len(options)
assert 1 == len(builder.items)
assert "" == get_upload_when_stable()
assert builder.upload_only_when_stable == ""


def test_get_os():
Expand All @@ -137,14 +130,17 @@ def test_ci_is_running():
expected = True if os.getenv("CI", None) is not None else False
assert expected == build_shared.is_ci_running()


def test_build_policy_not_set():
builder = build_template_default.get_builder()
assert None == builder.build_policy


def test_build_policy_set_in_args():
builder = build_template_default.get_builder(build_policy='missing')
assert 'missing' == builder.build_policy


def test_build_policy_set_header_only():
builder = build_template_header_only.get_builder(build_policy='missing')
assert 'missing' == builder.build_policy

0 comments on commit 264e192

Please sign in to comment.