Updated the error for providing both PR and

commit_hash to a warning.  This was causing
an error during PR triggered testing in github
actions as both of these are provided.  Perhaps
we actually can include both of these and can
get old PRs based on commit hash, but until
then we will just test using the PR number and
ignore the commit_hash if we find both.
This commit is contained in:
pyth0n1c
2022-01-12 10:38:23 -08:00
parent 4d9349084e
commit 3afef5d559
2 changed files with 11 additions and 6 deletions
@@ -98,7 +98,7 @@ def copy_local_apps_to_directory(apps: dict[str, dict], target_directory) -> Non
def ensure_security_content(branch: str, commit_hash: str, pr_number: Union[int, None], persist_security_content: bool) -> tuple[GithubService, bool]:
def ensure_security_content(branch: str, commit_hash: Union[str,None], pr_number: Union[int, None], persist_security_content: bool) -> tuple[GithubService, bool]:
if persist_security_content is True and os.path.exists("security_content"):
print("****** You chose --persist_security_content and the security_content directory exists. "
"We will not check out the repo again. Please be aware, this could cause issues if your "
@@ -508,6 +508,8 @@ def main(args: list[str]):
sys.exit(0)
else:
print("Test Execution Failed - review the logs for more details")
print("IN THE FUTURE, THIS WILL RETURN NONZERO CAUSING THE WORKFLOW TO FAIL!")
sys.exit(0)
sys.exit(1)
@@ -24,7 +24,7 @@ SECURITY_CONTENT_URL = "https://github.com/splunk/security_content"
class GithubService:
def __init__(self, security_content_branch: str, commit_hash: str, PR_number: int = None, persist_security_content: bool = False):
def __init__(self, security_content_branch: str, commit_hash: Union[str,None], PR_number: int = None, persist_security_content: bool = False):
self.security_content_branch = security_content_branch
if persist_security_content:
@@ -44,12 +44,15 @@ class GithubService:
"'git branch -a' to examine [%d] branches"%(security_content_branch, len(branch_names))))
if commit_hash is not None and PR_number is not None:
raise(Exception("Error - both the PR number [%d] and the commit hash [%s] were provided. "
"Only 0 or 1 can be passed." % (PR_number, commit_hash)))
if commit_hash is not None and PR_number is not None:
print(f"\n************\nWARNING - both the PR_number {PR_number} and the commit_hash {commit_hash} were provided. "
f"You should only pass neither or one of these. We will ASSUME you want to use the PR_number, not the commit_hash. "
f"Removing the commit_hash...\n************\n")
commit_hash = None
elif PR_number:
if PR_number:
ret = subprocess.run(["git", "-C", "security_content/", "fetch", "origin",
"refs/pull/%d/head:%s" % (PR_number, security_content_branch)], capture_output=True)
#ret = subprocess.call(["git", "-C", "security_content/", "fetch", "origin",