Backport PR #15810 to 8.12: [CI] Send Java and ruby tests to sonarqube simultaneously #15819
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.
Backport PR #15810 to 8.12 branch, original message:
What does this PR do?
Makes the CI pipeline to Generate coverage reports for Java and Ruby tests
Introduces an additional step to publish both tests results to SonarQube
Enables coverage thresholds
Code coverage measurement for pull requests
Now we measure coverage of new code on each pull request.

It shows whether newly added lines are covered or not.
Example: I changed 2 ruby and 2 java files by adding lines outputting a "HEYA!" message.
Only changed files are listed in the code coverage analisys:
logstash-core/lib/logstash/codecs/base.rb
shows 0% coverage andUncovered Lines on New Code: 2
. That's because I added 2 linesputs('HEYA!')
and both are not covered by existing tests.logstash-core/src/main/java/org/logstash/Javafier.java
shows 50% coverage andUncovered Lines on New Code: 1
. There are also 2 new lines. And 1 of them is covered by an existing test and the other line is not covered. Ideally we need to cover it by a test.It also shows
14.3%
coverage for the new code. That means my newly addedHEYA!
lines are covered by14.3%
.If we open
logstash-core/src/main/java/org/logstash/Javafier.java
in Sonarqube for further details we can find the uncovered new line:Code coverage threshold(s)
We can set a quality gate for coverage of new code or entire project. There's also an assigned quality gate for Logstash.
The gate also watches the maintainability level using sonar lint and it expects it to be at least
A
.But in fact we achieved only

C
, hence we can see a comment from sonarqube:And the PR merge is blocked.
If we change the required maintainability level to
C
- the PR checks will passChecklist
Related issues