Skip to content

Commit

Permalink
Merge pull request openshift-helm-charts#270 from komish/properly-det…
Browse files Browse the repository at this point in the history
…ect-workflow-changes

Prevent early exit in cases where a non-workflow file is also modified alongside workflow files
  • Loading branch information
mgoerens authored Oct 12, 2023
2 parents 16fa829 + 8a8c2ed commit b02ddf6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scripts/src/workflowtesting/checkprforci.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def check_if_ci_only_is_modified(api_url):

files = prartifact.get_modified_files(api_url)
workflow_files = [
re.compile(r".github/workflows/.*"),
re.compile(r".github/(workflows|actions)/.*"),
re.compile(r"scripts/.*"),
re.compile(r"tests/.*"),
]
Expand All @@ -33,19 +33,27 @@ def check_if_ci_only_is_modified(api_url):
re.compile(r"docs/([\w-]+)\.md"),
]

print(f"[INFO] The following files were modified in this PR: {files}")

workflow_found = False
others_found = False
tests_included = False

for filename in files:
if any([pattern.match(filename) for pattern in workflow_files]):
print(f"[DEBUG] Modified file {filename} is a workflow file.")
workflow_found = True
# Tests are considered workflow files AND test files to inform other actions
# so we detect both separately.
if any([pattern.match(filename) for pattern in test_files]):
print(f"[DEBUG] Modified file {filename} is also a test file.")
tests_included = True
elif any([pattern.match(filename) for pattern in skip_build_files]):
print(f"[DEBUG] Modified file {filename} is a skippable file.")
others_found = True
else:
return False
print(f"[DEBUG] Modified file {filename} did not match any file paths of interest. Ignoring.")
continue

if others_found and not workflow_found:
gitutils.add_output("do-not-build", "true")
Expand Down

0 comments on commit b02ddf6

Please sign in to comment.