Skip to content

Commit

Permalink
Run macOS jobs on GHA when neither Travis nor AZP are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Croydon committed Dec 13, 2020
1 parent 1e57056 commit 813ee46
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bincrafters/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.29.4'
__version__ = '0.30.0'
34 changes: 34 additions & 0 deletions bincrafters/generate_ci_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
from bincrafters.utils import *


def _run_macos_jobs_on_gha():
if utils_file_contains("azure-pipelines.yml", "name: bincrafters/templates")\
and utils_file_contains("azure-pipelines.yml", "template: .ci/azure.yml@templates"):
return False

if utils_file_contains(".travis.yml", "import: bincrafters/templates:.ci/travis"):
return False

return True


def generate_ci_jobs(platform: str, recipe_type: str = autodetect(), split_by_build_types: bool = False) -> str:
if platform != "gha" and platform != "azp":
return ""
Expand All @@ -19,6 +30,7 @@ def generate_ci_jobs(platform: str, recipe_type: str = autodetect(), split_by_bu
split_by_build_types = get_bool_from_env("BPT_SPLIT_BY_BUILD_TYPES", get_bool_from_env("splitByBuildTypes", False))

if platform == "gha":
run_macos = _run_macos_jobs_on_gha()
if recipe_type == "installer":
matrix["config"] = [
{"name": "Installer Linux", "compiler": "GCC", "version": "7", "os": "ubuntu-18.04", "dockerImage": "conanio/gcc7-centos6"},
Expand Down Expand Up @@ -62,12 +74,25 @@ def generate_ci_jobs(platform: str, recipe_type: str = autodetect(), split_by_bu
{"name": "CLANG 9 Debug", "compiler": "CLANG", "version": "9", "os": "ubuntu-18.04", "buildType": "Debug"},
{"name": "CLANG 9 Release", "compiler": "CLANG", "version": "9", "os": "ubuntu-18.04", "buildType": "Release"}
]
if run_macos:
matrix["config"] += [
{"name": "macOS Apple-Clang 10 Release", "compiler": "APPLE_CLANG", "version": "10.0", "os": "macOS-10.14", "buildType": "Release"},
{"name": "macOS Apple-Clang 10 Debug", "compiler": "APPLE_CLANG", "version": "10.0", "os": "macOS-10.14", "buildType": "Debug"},
{"name": "macOS Apple-Clang 11 Release", "compiler": "APPLE_CLANG", "version": "11.0", "os": "macOS-10.15", "buildType": "Release"},
{"name": "macOS Apple-Clang 11 Debug", "compiler": "APPLE_CLANG", "version": "11.0", "os": "macOS-10.15", "buildType": "Debug"},
]
matrix_minimal["config"] = [
{"name": "GCC 7 Debug", "compiler": "GCC", "version": "7", "os": "ubuntu-18.04", "buildType": "Debug"},
{"name": "GCC 7 Release", "compiler": "GCC", "version": "7", "os": "ubuntu-18.04", "buildType": "Release"},
{"name": "CLANG 8 Debug", "compiler": "CLANG", "version": "8", "os": "ubuntu-18.04", "buildType": "Debug"},
{"name": "CLANG 8 Release", "compiler": "CLANG", "version": "8", "os": "ubuntu-18.04", "buildType": "Release"},
]
if run_macos:
matrix_minimal["config"] += [
{"name": "macOS Apple-Clang 11 Debug", "compiler": "APPLE_CLANG", "version": "11.0", "os": "macOS-10.15", "buildType": "Debug"},
{"name": "macOS Apple-Clang 11 Release", "compiler": "APPLE_CLANG", "version": "11.0", "os": "macOS-10.15", "buildType": "Release"},
]

else:
matrix["config"] = [
{"name": "GCC 4.9", "compiler": "GCC", "version": "4.9", "os": "ubuntu-18.04"},
Expand All @@ -84,10 +109,19 @@ def generate_ci_jobs(platform: str, recipe_type: str = autodetect(), split_by_bu
{"name": "CLANG 8", "compiler": "CLANG", "version": "8", "os": "ubuntu-18.04"},
{"name": "CLANG 9", "compiler": "CLANG", "version": "9", "os": "ubuntu-18.04"},
]
if run_macos:
matrix["config"] += [
{"name": "macOS Apple-Clang 10", "compiler": "APPLE_CLANG", "version": "10.0", "os": "macOS-10.14"},
{"name": "macOS Apple-Clang 11", "compiler": "APPLE_CLANG", "version": "11.0", "os": "macOS-10.15"},
]
matrix_minimal["config"] = [
{"name": "GCC 7", "compiler": "GCC", "version": "7", "os": "ubuntu-18.04"},
{"name": "CLANG 8", "compiler": "CLANG", "version": "8", "os": "ubuntu-18.04"},
]
if run_macos:
matrix_minimal["config"] += [
{"name": "macOS Apple-Clang 11", "compiler": "APPLE_CLANG", "version": "11.0", "os": "macOS-10.15"},
]
elif platform == "azp":
if split_by_build_types:
matrix["config"] = [
Expand Down
16 changes: 16 additions & 0 deletions bincrafters/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,19 @@ def utils_git_get_changed_dirs(base: str, head: str = None) -> list:
remove_newlines=False)

return dirs.splitlines()


def utils_file_contains(file, word):
""" Read file and search for word
:param file: File path to be read
:param word: word to be found
:return: True if found. Otherwise, False
"""
if os.path.isfile(file):
with open(file) as ifd:
content = ifd.read()
if word in content:
return True
return False

0 comments on commit 813ee46

Please sign in to comment.