Skip to content

Commit

Permalink
version check on from pr
Browse files Browse the repository at this point in the history
  • Loading branch information
branfosj committed May 6, 2024
1 parent 9e93904 commit 1ec53a5
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions easybuild/tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
from easybuild.tools.py2vs3 import HTTPError, URLError, ascii_letters, urlopen
from easybuild.tools.systemtools import UNKNOWN, get_tool_version
from easybuild.tools.utilities import nub, only_if_module_is_available
from easybuild.tools.version import FRAMEWORK_VERSION, different_major_versions


_log = fancylogger.getLogger('github', fname=False)
Expand Down Expand Up @@ -588,13 +589,38 @@ def fetch_files_from_pr(pr, path=None, github_user=None, github_account=None, gi
raise EasyBuildError("Couldn't find path to patched file %s", full_path)

if github_repo == GITHUB_EASYCONFIGS_REPO:
print('get ecs version', os.path.join(final_path, 'setup.py'))
ver = _get_version_for_repo(os.path.join(final_path, 'setup.py'))
elif github_repo == GITHUB_EASYBLOCKS_REPO:
print('get blocks version', sys.path, final_path)
ver = _get_version_for_repo(os.path.join(final_path, 'easybuild', 'easyblocks', '__init__.py'))

if different_major_versions(FRAMEWORK_VERSION, ver):
raise EasyBuildError("Framework (%s) is a different major version than PR target (%s)." % (FRAMEWORK_VERSION,
ver))

return files


def _get_version_for_repo(filename):
"""Extract version from filename."""
_log.debug("Extract version from %s" % filename)

try:
ver_line = ""
with open(filename) as f:
for line in f.readlines():
if line.startswith("VERSION "):
ver_line = line
break

# version can be a string or LooseVersion
res = re.search(r"""^VERSION = .*['"](.*)['"].?$""", ver_line)

_log.debug("PR target version is %s" % res.group(1))
return res.group(1)
except:
raise EasyBuildError("Couldn't determine version of PR from %s" % filename)


def fetch_easyblocks_from_pr(pr, path=None, github_user=None):
"""Fetch patched easyblocks for a particular PR."""
return fetch_files_from_pr(pr, path, github_user, github_repo=GITHUB_EASYBLOCKS_REPO)
Expand Down

0 comments on commit 1ec53a5

Please sign in to comment.