logstash
logstash copied to clipboard
Backport PR #15810 to 8.12: [CI] Send Java and ruby tests to sonarqube simultaneously
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 and Uncovered Lines on New Code: 2. That's because I added 2 lines puts('HEYA!') and both are not covered by existing tests.
logstash-core/src/main/java/org/logstash/Javafier.java shows 50% coverage and Uncovered 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 added HEYA! lines are covered by 14.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 pass
Checklist
- [ ] My code follows the style guidelines of this project
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
- [ ] I have added tests that prove my fix is effective or that my feature works
Related issues
- Closes https://github.com/elastic/ingest-dev/issues/2408
:broken_heart: Build Failed
- Buildkite Build
- Commit: e85e2f22ca0c61f06822a89e2c95281be2f43db2
Failed CI Steps
- :lab_coat: Integration Tests / part 1
- :lab_coat: Integration Tests / part 1
- :lab_coat: Integration Tests / part 1
- :lab_coat: Integration Tests / part 1
- :lab_coat: Integration Tests / part 2
- :lab_coat: Integration Tests / part 2
- :lab_coat: Integration Tests / part 2
- :lab_coat: Integration Tests / part 2
- :lab_coat: IT Persistent Queues / part 1
- :lab_coat: IT Persistent Queues / part 1
- :lab_coat: IT Persistent Queues / part 1
- :lab_coat: IT Persistent Queues / part 1
- :lab_coat: IT Persistent Queues / part 2
- :lab_coat: IT Persistent Queues / part 2
- :lab_coat: IT Persistent Queues / part 2
- :lab_coat: IT Persistent Queues / part 2
- :lab_coat: x-pack integration
- :lab_coat: x-pack integration
- :lab_coat: x-pack integration
- :lab_coat: x-pack integration
History
Quality Gate passed
Kudos, no new issues were introduced!
0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication