-
Notifications
You must be signed in to change notification settings - Fork 554
ci: smart stages for PRs #2878
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
Closed
Closed
ci: smart stages for PRs #2878
Changes from all commits
Commits
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 hidden or 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 |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ pipeline { | |
| quietPeriod(10) | ||
| } | ||
| triggers { | ||
| issueCommentTrigger("${obltGitHubComments()}") | ||
| issueCommentTrigger("(${obltGitHubComments()}|^/test all)") | ||
| } | ||
| parameters { | ||
| string(name: 'stackVersion', defaultValue: '', description: 'Version of the stack to use for testing.') | ||
|
|
@@ -41,6 +41,10 @@ pipeline { | |
| deleteDir() | ||
| gitCheckout(basedir: "${BASE_DIR}") | ||
| stashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}") | ||
| dir("${BASE_DIR}"){ | ||
| // TODO: '^.ci/Jenkinsfile' too | ||
| setEnvVar('COMMON_CHANGES', isGitRegionMatch(patterns: [ '(^go.*|.go-version)' ], shouldMatchAll: false).toString()) | ||
| } | ||
| } | ||
| } | ||
| stage('Check Go sources') { | ||
|
|
@@ -61,7 +65,7 @@ pipeline { | |
| // Include hack to skip temporary files with "@tmp" suffix. | ||
| // For reference: https://issues.jenkins.io/browse/JENKINS-52750 | ||
| findFiles()?.findAll{ !it.name.endsWith('@tmp') }?.collect{ it.name }?.sort()?.each { | ||
| if (isPrAffected(it)) { | ||
| if (isPackageEnabled(it)) { | ||
| integrations[it] = { | ||
| withNode(labels: 'ubuntu-20 && immutable', sleepMin: 10, sleepMax: 100) { | ||
| stage("${it}: check") { | ||
|
|
@@ -146,7 +150,30 @@ def checkGitDiff() { | |
| } | ||
| } | ||
|
|
||
| def isPrAffected(integrationName) { | ||
| /** | ||
| * Helper function to validate if the given integration is enabled | ||
| * If it's a branch, a daily build, a GitHub comment or the changeset | ||
| * contains the integration or some common changes then it will be true, | ||
| * otherwise false. | ||
| */ | ||
| def isPackageEnabled(integrationName) { | ||
| if (isBranch()) { | ||
| log(level: 'INFO', text: "[${integrationName}] is affected: running on ${BRANCH_NAME} branch.") | ||
| return true | ||
| } | ||
| if (isDailyEnabled(integrationName)) { | ||
| return true | ||
| } | ||
| if (isPrAffected(integrationName)) { | ||
| return true | ||
| } | ||
| return env.GITHUB_COMMENT?.contains('all') || env.COMMON_CHANGES == 'true' | ||
| } | ||
|
|
||
| def isDailyEnabled(integrationName) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A similar question here, why do we need a separate function for Daily? |
||
| if (isPR()) { | ||
| return false | ||
| } | ||
| def manifest = readYaml(file: "${integrationName}/manifest.yml") | ||
|
|
||
| // Packages supported in Kibana >= 8.0.0, shouldn't be included in daily tests of the stack 7.x | ||
|
|
@@ -163,10 +190,11 @@ def isPrAffected(integrationName) { | |
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (env.BRANCH_NAME == "main") { | ||
| echo "[${integrationName}] PR is affected: running on main branch" | ||
| return true | ||
| def isPrAffected(integrationName) { | ||
| if (!isPR()) { | ||
| return false | ||
| } | ||
|
|
||
| // Source: https://github.com/elastic/apm-pipeline-library/blob/721115cf0fdb2b5a4e1cb6a576bfbb7035d14485/vars/getGitMatchingGroup.groovy#L40-L41 | ||
|
|
||
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'm not sure if I fully understand the intention here. Which part of the helper is the "smart" one (as in the PR title)?
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.
smartwas just a name, easy to change.I tried to explain what I did and why in the PR description, but in a nutshell, if I understood correctly, the packages should be triggered based on the below conditions:
2)won't allow to do so.2)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.
Re 5:
What about dependabot updates? We need to check all integrations then. Imagine that there is a bug in
elastic-package, and ~3/100 integrations may catch it.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.
Since it changes
go.modthen it triggers all the integrations. So that's also covered