Test gh integration

This commit is contained in:
Jeremy Rimpo
2020-09-21 07:47:12 -05:00
parent f8489eaca0
commit a3b89b18af
6 changed files with 25 additions and 5 deletions
+3
View File
@@ -79,6 +79,8 @@ config = {
'Distrib_Author': 'TanninOne', # the current distribution (and the original Author) 'Distrib_Author': 'TanninOne', # the current distribution (and the original Author)
'Work_Author': '', # yourself 'Work_Author': '', # yourself
'gh_cli_token': '',
# manualy set all versions # manualy set all versions
'7zip_version': '19.00', '7zip_version': '19.00',
'boost_version': '1.73.0', 'boost_version': '1.73.0',
@@ -159,6 +161,7 @@ config['paths'] = {
# 'graphviz': path_or_default("dot.exe", [["Graphviz2.38", "bin"]]), # 'graphviz': path_or_default("dot.exe", [["Graphviz2.38", "bin"]]),
'cmake': path_or_default("cmake.exe", [["CMake", "bin"]]), 'cmake': path_or_default("cmake.exe", [["CMake", "bin"]]),
'git': path_or_default("git.exe", [["Git", "bin"]]), 'git': path_or_default("git.exe", [["Git", "bin"]]),
'gh': path_or_default("gh.exe", [["GitHub CLI"]]),
'perl': path_or_default("perl.exe", [["StrawberryPerl", "perl", "bin"], ["Strawberry", "perl", "bin"]]), 'perl': path_or_default("perl.exe", [["StrawberryPerl", "perl", "bin"], ["Strawberry", "perl", "bin"]]),
#'svn': path_or_default("svn.exe", [["SlikSvn", "bin"]]), #'svn': path_or_default("svn.exe", [["SlikSvn", "bin"]]),
'7z': path_or_default("7z.exe", [["7-Zip"]]), '7z': path_or_default("7z.exe", [["7-Zip"]]),
+5 -1
View File
@@ -148,6 +148,10 @@ for author, git_path, path, branch, dependencies, Build in [
if config['Appveyor_Build']: if config['Appveyor_Build']:
appveyor_cmake_step = cmake.CMakeJOM().arguments(cmake_param).install() appveyor_cmake_step = cmake.CMakeJOM().arguments(cmake_param).install()
gh_pr_branch = None
if os.getenv('APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH') is not None:
gh_pr_branch = '{}:{}'.format(os.getenv('APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME'), os.getenv('APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH'))
if git_path != "cmake_common": if git_path != "cmake_common":
appveyor_cmake_step.depend("cmake_common") appveyor_cmake_step.depend("cmake_common")
@@ -158,7 +162,7 @@ for author, git_path, path, branch, dependencies, Build in [
if os.getenv("APPVEYOR_PROJECT_NAME","") == git_path: if os.getenv("APPVEYOR_PROJECT_NAME","") == git_path:
source_retrieval_step = appveyor.SetProjectFolder(os.getenv("APPVEYOR_BUILD_FOLDER", "")) source_retrieval_step = appveyor.SetProjectFolder(os.getenv("APPVEYOR_BUILD_FOLDER", ""))
else: else:
source_retrieval_step = github.Source(author, git_path, branch, feature_branch=config['Feature_Branch'], super_repository=tl_repo).set_destination(path) source_retrieval_step = github.Source(author, git_path, branch, feature_branch=config['Feature_Branch'], super_repository=tl_repo, gh_pr=gh_pr_branch).set_destination(path)
if git_path == "modorganizer" and config['override_build_version']: if git_path == "modorganizer" and config['override_build_version']:
#add patching step that depends on source retrieval #add patching step that depends on source retrieval
+8 -2
View File
@@ -80,7 +80,7 @@ class SuperRepository(Task):
class Clone(Repository): class Clone(Repository):
def __init__(self, url, branch, feature_branch=None, super_repository=None, update=True, commit=None, shallowclone=False): def __init__(self, url, branch, feature_branch=None, super_repository=None, update=True, commit=None, shallowclone=False, gh_pr=None):
if config['shallowclone']: if config['shallowclone']:
self.shallowclone = True self.shallowclone = True
super(Clone, self).__init__(url, branch, feature_branch) super(Clone, self).__init__(url, branch, feature_branch)
@@ -89,6 +89,7 @@ class Clone(Repository):
self.__update = update self.__update = update
self.__commit = commit self.__commit = commit
self.__shallowclone = shallowclone self.__shallowclone = shallowclone
self.__gh_pr = gh_pr
if self._feature_branch is not None: if self._feature_branch is not None:
proc = Popen([config['paths']['git'], "ls-remote", "--heads", "--exit-code", self._url, self._feature_branch], proc = Popen([config['paths']['git'], "ls-remote", "--heads", "--exit-code", self._url, self._feature_branch],
@@ -151,7 +152,12 @@ class Clone(Repository):
logging.error("failed to clone repository %s (returncode %s)", self._url, proc.returncode) logging.error("failed to clone repository %s (returncode %s)", self._url, proc.returncode)
return False return False
if self.__commit is not None: if self.__gh_pr is not None:
proc = Popen([config['paths']['gh'], "pr", "checkout", self.__gh_pr],
cwd=self.__super_repository.path,
env=config['__environment'])
proc.communicate()
elif self.__commit is not None:
if self.__shallowclone: if self.__shallowclone:
proc = Popen([config['paths']['git'], "checkout","--depth", "1", self.__commit], proc = Popen([config['paths']['git'], "checkout","--depth", "1", self.__commit],
cwd=self._context["build_path"], cwd=self._context["build_path"],
+2 -2
View File
@@ -43,10 +43,10 @@ class Tag(URLDownload):
class Source(Clone): class Source(Clone):
def __init__(self, author, project, branch="master", feature_branch=None, super_repository=None, update=True, commit=None, shallowclone=False): def __init__(self, author, project, branch="master", feature_branch=None, super_repository=None, update=True, commit=None, shallowclone=False, gh_pr=None):
if config['shallowclone']: if config['shallowclone']:
self.shallowclone = True self.shallowclone = True
super(Source, self).__init__("https://github.com/{author}/{project}.git".format(author=author, project=project), super(Source, self).__init__("https://github.com/{author}/{project}.git".format(author=author, project=project),
branch, feature_branch, super_repository, update, commit, shallowclone) branch, feature_branch, super_repository, update, commit, shallowclone, gh_pr)
self.set_destination(project) self.set_destination(project)
+1
View File
@@ -110,6 +110,7 @@ def dump_config():
logging.debug(" Config: config['paths']['cmake']=%s", config['paths']['cmake']) logging.debug(" Config: config['paths']['cmake']=%s", config['paths']['cmake'])
logging.debug(" Config: config['paths']['jom']=%s", config['paths']['jom']) logging.debug(" Config: config['paths']['jom']=%s", config['paths']['jom'])
logging.debug(" Config: config['paths']['git']=%s", config['paths']['git']) logging.debug(" Config: config['paths']['git']=%s", config['paths']['git'])
logging.debug(" Config: config['paths']['gh']=%s", config['paths']['gh'])
logging.debug(" Config: config['paths']['perl']=%s", config['paths']['perl']) logging.debug(" Config: config['paths']['perl']=%s", config['paths']['perl'])
#logging.debug(" Config: config['paths']['ruby']=%s", config['paths']['ruby']) #logging.debug(" Config: config['paths']['ruby']=%s", config['paths']['ruby'])
#logging.debug(" Config: config['paths']['svn']=%s", config['paths']['svn']) #logging.debug(" Config: config['paths']['svn']=%s", config['paths']['svn'])
+6
View File
@@ -87,6 +87,8 @@ def check_prerequisites_config():
return False return False
if not config['paths']['git']: if not config['paths']['git']:
return False return False
if not config['paths']['gh']:
return False
if not config['paths']['perl']: if not config['paths']['perl']:
return False return False
if config["Installer"]: if config["Installer"]:
@@ -118,6 +120,10 @@ def main():
print('\nMissing prerequisites listed above - cannot continue') print('\nMissing prerequisites listed above - cannot continue')
exit(1) exit(1)
from subprocess import Popen, PIPE
p = Popen([config['paths']['gh'], 'auth', 'login', '--with-token'], stdout=PIPE, stdin=PIPE, stderr=PIPE, text=True)
stdout_data = p.communicate(input=config['gh_cli_token'])[0]
for d in ["download", "build", "progress", "install"]: for d in ["download", "build", "progress", "install"]:
if not os.path.exists(config["paths"][d]): if not os.path.exists(config["paths"][d]):
os.makedirs(config["paths"][d]) os.makedirs(config["paths"][d])