forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip CI based on changes in PR (elastic#59939)
- Loading branch information
1 parent
8b174fe
commit 17ea665
Showing
5 changed files
with
72 additions
and
10 deletions.
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
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,52 @@ | ||
|
||
def getSkippablePaths() { | ||
return [ | ||
/^docs\//, | ||
/^rfcs\//, | ||
/^.ci\/.+\.yml$/, | ||
/^\.github\//, | ||
/\.md$/, | ||
] | ||
} | ||
|
||
def areChangesSkippable() { | ||
if (!githubPr.isPr()) { | ||
return false | ||
} | ||
|
||
try { | ||
def skippablePaths = getSkippablePaths() | ||
def files = getChangedFiles() | ||
|
||
// 3000 is the max files GH API will return | ||
if (files.size() >= 3000) { | ||
return false | ||
} | ||
|
||
files = files.findAll { file -> | ||
return !skippablePaths.find { regex -> file =~ regex} | ||
} | ||
|
||
return files.size() < 1 | ||
} catch (ex) { | ||
buildUtils.printStacktrace(ex) | ||
print "Error while checking to see if CI is skippable based on changes. Will run CI." | ||
return false | ||
} | ||
} | ||
|
||
def getChanges() { | ||
withGithubCredentials { | ||
return githubPrs.getChanges(env.ghprbPullId) | ||
} | ||
} | ||
|
||
def getChangedFiles() { | ||
def changes = getChanges() | ||
def changedFiles = changes.collect { it.filename } | ||
def renamedFiles = changes.collect { it.previousFilename }.findAll { it } | ||
|
||
return changedFiles + renamedFiles | ||
} | ||
|
||
return this |
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,9 @@ | ||
def call(closure) { | ||
withCredentials([ | ||
string(credentialsId: '2a9602aa-ab9f-4e52-baf3-b71ca88469c7', variable: 'GITHUB_TOKEN'), | ||
]) { | ||
closure() | ||
} | ||
} | ||
|
||
return this |