-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only run xpack siem cypress in PRs when there are siem changes #60661
Merged
brianseeders
merged 10 commits into
elastic:master
from
brianseeders:implement/when-changed
Mar 23, 2020
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
624c8cc
Only run xpack siem cypress in PRs when there are siem changes
brianseeders 60ac58d
Missed new file
brianseeders a4d2913
Add support for both startsWith and regex to whenChanged
brianseeders 194c09b
Remove operator
brianseeders cb515ed
Allow lists of paths/regexes for whenChanged
brianseeders a463987
Add processNumber
brianseeders 3ed8513
Merge remote-tracking branch 'upstream/master' into implement/when-ch…
brianseeders f01c9bb
Remove test changes
brianseeders c6d283f
Add a little documentation for whenChanged()
brianseeders be838de
Merge branch 'master' into implement/when-changed
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
whenChanged('some/path') { yourCode() } can be used to execute pipeline code in PRs only when changes are detected on paths that you specify. | ||
The specified code blocks will also always be executed during the non-PR jobs for tracked branches. | ||
You have the option of passing in path prefixes, or regexes. Single or multiple. | ||
Path specifications are NOT globby, they are only prefixes. | ||
Specifying multiple will treat them as ORs. | ||
Example Usages: | ||
whenChanged('a/path/prefix/') { someCode() } | ||
whenChanged(startsWith: 'a/path/prefix/') { someCode() } // Same as above | ||
whenChanged(['prefix1/', 'prefix2/']) { someCode() } | ||
whenChanged(regex: /\.test\.js$/) { someCode() } | ||
whenChanged(regex: [/abc/, /xyz/]) { someCode() } | ||
*/ | ||
|
||
def call(String startsWithString, Closure closure) { | ||
return whenChanged([ startsWith: startsWithString ], closure) | ||
} | ||
|
||
def call(List<String> startsWithStrings, Closure closure) { | ||
return whenChanged([ startsWith: startsWithStrings ], closure) | ||
} | ||
|
||
def call(Map params, Closure closure) { | ||
if (!githubPr.isPr()) { | ||
return closure() | ||
} | ||
|
||
def files = prChanges.getChangedFiles() | ||
def hasMatch = false | ||
|
||
if (params.regex) { | ||
params.regex = [] + params.regex | ||
print "Checking PR for changes that match: ${params.regex.join(', ')}" | ||
hasMatch = !!files.find { file -> | ||
params.regex.find { regex -> file =~ regex } | ||
} | ||
} | ||
|
||
if (!hasMatch && params.startsWith) { | ||
params.startsWith = [] + params.startsWith | ||
print "Checking PR for changes that start with: ${params.startsWith.join(', ')}" | ||
hasMatch = !!files.find { file -> | ||
params.startsWith.find { str -> file.startsWith(str) } | ||
} | ||
} | ||
|
||
if (hasMatch) { | ||
print "Changes found, executing pipeline." | ||
closure() | ||
} else { | ||
print "No changes found, skipping." | ||
} | ||
} | ||
|
||
return this |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now have a TODO item to re-factor away having to worry about the
processNumber
argument anywhere, I just don't want to do it as part of this PR