-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[CI][lint] Enable x-pack linting when OSS changes #23655
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
x-pack/libbeat/Jenkinsfile.yml
Outdated
@@ -33,3 +34,7 @@ stages: | |||
tags: true ## for all the tags | |||
build: | |||
mage: "mage build test" | |||
when: ## Override the top-level when. | |||
not_changeset_full_match: "^libbeat/.*" ## Disable the stage if ONLY changes for the OSS beats |
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.
If there are changes in the code of libbeat we should run the tests for x-pack/libbeat. I guess this is done now by @ci
or GetProjectDependencies
, but will this new condition prevent tests to be run if there are changes only in OSS?
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.
Aha! Then this is totally a different behaviour that I though! good catch. The @xpack
macro already contain the "^libbeat/.*"
, therefore we don't need this when
x-pack/metricbeat/Jenkinsfile.yml
Outdated
@@ -20,6 +21,10 @@ stages: | |||
make check-no-changes; | |||
unitTest: | |||
mage: "mage build unitTest" | |||
when: ## Override the top-level when. | |||
not_changeset_full_match: "^metricbeat/.*" ## Disable the stage if ONLY changes for the OSS beats |
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.
Same here (and with the other beats), will this prevent x-pack metricbeat tests to be run if there were changes in oss metricbeat only?
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.
Exactly, for clarity for the below x-pack/metricbeat
CI stages:
lint
stage (L18) will always run as long as the firstwhen
condition is set (see L1)unitTest
stage (L22) will run if thechangeset
does not contain ONLYmetricbeat
changes or it's a build in any branch/tag
not_changeset_full_match
is a negative condition, exactly the opposite of what the majority of the other when conditions
.
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.
But we want x-pack tests to be run if there are changes in some dependency in OSS (as detected by GetProjectDependencies
).
e.g. if we change only something in metricbeat/mb
, we want to run x-pack metricbeat tests as it can be affected.
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 gonna double check the expected behaviour works as expected, since I'm not convinced now if this might cause that particular regression :/
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 there is no an easy way with the proposal, I finally change a bit the implementation to exclude the x-pack/<beat>
stages if there are only <beat>/docs
changes.
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.
e.g. if we change only something in metricbeat/mb, we want to run x-pack metricbeat tests as it can be affected.
It should we now be covered. I just executed some tests for the not_changeset_full_match
when condition locally:
diff --git a/src/test/groovy/BeatsWhenStepTests.groovy b/src/test/groovy/BeatsWhenStepTests.groovy
index 9f53c52..792a3a2 100644
--- a/src/test/groovy/BeatsWhenStepTests.groovy
+++ b/src/test/groovy/BeatsWhenStepTests.groovy
+ @Test
+ void test_xpackmetricbeat_test_when_metricbeat_mb_changes() throws Exception {
+ def script = loadScript(scriptName)
+ def changeset = "metricbeat/mb/my-file.go"
+ helper.registerAllowedMethod('readFile', [String.class], { return changeset })
+ def ret = script.whenNotChangesetFullMatch(content: [ not_changeset_full_match: '^metricbeat/docs/.*'])
+ printCallStack()
+ assertTrue(ret)
+ }
+
$ ./mvnw test -Dtest=BeatsWhenStepTests#test_xpackmetricbeat_test_when_metricbeat_mb_changes
...[INFO] Running BeatsWhenStepTests
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.981 s - in BeatsWhenStepTests
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
This is already supported with the `@xpack` macro and in fact, it should always run if libbeat changes
…pack-when-oss-changes * upstream/master: [DOCS] Add setup content to Kubernetes and Cloud Foundry docs (elastic#23580) [CI] Mandatory windows support for all the versions (elastic#23615) Add check when retrieving the worker process id using performance counters (elastic#23647) Remove 4912 evtx from testing (elastic#23669) Add missing SSL settings (elastic#23632) Update X-Pack Packetbeat config (elastic#23666) Use hostname check from verify.go to handle patterns in TLS certs (elastic#23661) Fix: Dissect Cisco ASA 302013 message usernames (elastic#21196) Add FAQ entry for MADV settings in older versions (elastic#23429) Sync fixes from Integration Package Testing (elastic#23424) [Filebeat] Add Cisco ASA message '302023' parsing (elastic#23092) [Elastic Log Driver] Change hosts config flag (elastic#23628) Audit and Authentication Policy Change Events (elastic#20684)
…1v/beats into feature/linting-xpack-when-oss-changes * 'feature/linting-xpack-when-oss-changes' of github.com:v1v/beats: Apply suggestions from code review
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.
Thanks! It looks ok, but it is starting to get a bit complicated to follow.
when: ## Override the top-level when. | ||
not_changeset_full_match: "^auditbeat/docs/.*" ## Disable the stage if ONLY DOC changes for the OSS beats | ||
branches: true ## for all the branches | ||
tags: true ## for all the tags |
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.
Is there a reason to have this override in build
and windows*
, but not in arm
and macos
?
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.
A brief explanation:
Top-level when condition is the very first evaluation.
Then, any stages with a when condition will be evaluated again. Therefore when for stages and when for top-level don't work together. The initial approach didn't require anything further.
Is there a reason to have this override in build and windows*, but not in arm and macos?
Mandatory stages with this particular cross-project linting require the when: not_changeset_full_match...
while arm
and macos
are optional stages, so they do need to run on a PR basis unless any of the when conditions.
@@ -2,6 +2,7 @@ when: | |||
branches: true ## for all the branches | |||
changeset: ## when PR contains any of those entries in the changeset | |||
- "^x-pack/auditbeat/.*" | |||
- "^auditbeat/.*" ## when changes in the auditbeat |
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 guess this cannot be added for linting only, so we don't have to add the negation in all the other builds?
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 could not find a different approach with the existing declarative syntax :(
Although,I just found something that I wanna give a go in another PR
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.
My new proposal -> #23695
What does this PR do?
Changes in Beats should trigger builds of their x-pack counterparts
What beats have been enabled?
Why is it important?
#22584 changed the packetbeat but didn't update the x-pack/packbeat. This broke the linting job for x-pack/packetbeat, but was not detected.
Related issues
Similar to #23378 but the other way around.
Further details
Code changeSet discover is delegated to the
.ci/scripts/get-vendor-dependencies.sh
but for non-code changes this is the proposal.