-
Notifications
You must be signed in to change notification settings - Fork 4
Conversation
💚 Build SucceededExpand to view the summary
Build stats
Test stats 🧪
|
from: 'b0de59d0ec1e2ae52103a238a2e9cb5b0d7fd9b8', | ||
to: '641fd600836abafa51def05260d63fab6eed4707', |
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.
Changeset from #524
from: '347185bd7e2b402ba8f6befa5ef4428ad417fbbc', | ||
to: '4d9fc25d258622c767ec4d38df38520647cc7dda') |
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.
ChangeSet from #516
def realData = '''CHANGELOG.next.asciidoc | ||
metricbeat/docs/modules/zookeeper.asciidoc | ||
metricbeat/docs/modules/zookeeper/connection.asciidoc | ||
metricbeat/docs/modules_list.asciidoc | ||
metricbeat/module/zookeeper/_meta/docs.asciidoc | ||
metricbeat/module/zookeeper/connection/_meta/docs.asciidoc | ||
metricbeat/module/zookeeper/connection/_meta/fields.yml | ||
metricbeat/module/zookeeper/connection/connection.go | ||
metricbeat/module/zookeeper/fields.go | ||
metricbeat/module/zookeeper/mntr/_meta/docs.asciidoc | ||
metricbeat/module/zookeeper/server/_meta/docs.asciidoc'''.stripMargin().stripIndent() |
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.
Changeset from elastic/beats#17043
vars/getBeatsModule.groovy
Outdated
@@ -0,0 +1,80 @@ | |||
// Licensed to Elasticsearch B.V. under one or more contributor |
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.
Question:
- I think this step can be called something more generic, but I don't have any sensitive naming off the top of my head, any suggestions?
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 did not see this comment :D #535 (comment)
I am afraid the number of calls to isGitRegionMatch will be the same, but this will help a lot to decrease the time to build on beats that support MODULE. |
void test_multiple_without_match() throws Exception { | ||
def script = loadScript(scriptName) | ||
def changeset = '''foo/bar/file.txt | ||
bar/foo/subfolder'''.stripMargin().stripIndent() | ||
helper.registerAllowedMethod('readFile', [String.class], { return changeset }) | ||
def module = script.call(pattern: '([^\\/]+)\\/.*') | ||
assertEquals('', module) | ||
assertTrue(assertMethodCallContainsPattern('log', 'getBeatsModule: not found')) | ||
assertJobStatusSuccess() | ||
} |
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 think the regexp return 2 matches
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.
as long as they don't have a folder name in common there is no match.
def module = script.call(pattern: '([^\\/]+)\\/.*', from: 'something') | ||
printCallStack() | ||
assertEquals('foo', module) | ||
assertTrue(assertMethodCallContainsPattern('sh', 'something...bar')) |
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.
bar
confused me until I realized that it is GIT_BASE_COMIT
vars/getBeatsModule.groovy
Outdated
- When exact match then all the files should match those patterns then it | ||
returns the region otherwise and empty string. | ||
|
||
def module = getBeatsModule(pattern: '([^\\/]+)\\/.*') |
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.
the step really searches for a pattern in the git diff and return the match group, what about to rename it to getGitDiffMatch or similar.
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.
getGitMatchingGroup
?
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.
Done -> 02bb896
vars/getBeatsModule.groovy
Outdated
if (!isExcluded(line, exclude)) { | ||
def matches = line =~ pattern | ||
def auxModule = matches.collect { it[1] }[0] ?: '' | ||
modules[auxModule] = auxModule |
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 a regular groovy developer so I may be off here, but shouldn't we only execute this line if auxModule != ''
?
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.
That's indeed a good point, I initially coded with d0a1bf6#diff-056e15bb189379e1f510e3402220ddb5R63.
There are three different output in this particular getGroup
method:
- if no matches then returns
''
- if a match for all the change set then returns
module_name
- if multiple matches then return
''
Therefore ''
is a valid output to be returned and that's the reason of no using auxModule != ''
, in other words:
Given the changeset
foo/bar/file.txt
And the pattern^unknown.txt
the output forgetGroup
should be''
For instance, https://github.com/elastic/apm-pipeline-library/pull/535/files#diff-57498ad4c893cd122338bfbdeb7d0aa0R131-R141
Another example that I did not code as an unit test is:
Given the changeset
foo/bar/file.txt
andbar/foo/file.txt
And the pattern^unknown.txt
the output forgetGroup
should be''
Let me know if what I said it's not clear
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.
Okay, I see why it's working the way it is implemented now.
58eba4a
to
02bb896
Compare
02bb896
to
2476123
Compare
What does this PR do?
Given the changeset and a regex pattern with group let's see if all the files in the changeset got in common the regex and gather the group match
For instance:
Why is it important?
isGitRegionMatch returns a boolean, so we need soemthing more specific to look for groups in the given regex. Then the pipelines could use it in favor of filtering what stages should or should not run.
Related issues
Caused by https://github.com/elastic/observability-robots/issues/113
Actions