Skip to content
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: enable coverage #377

Merged
merged 11 commits into from
Apr 28, 2022
Merged

ci: enable coverage #377

merged 11 commits into from
Apr 28, 2022

Conversation

v1v
Copy link
Member

@v1v v1v commented Apr 26, 2022

What does this PR do?

Report Test Coverage in the CI

Why is it important?

Help to visualise when the Test coverage gets increased or decreased (see #377 (comment))

Questions

Current implementation does run coverage for each platform (windows, linux and ARM), therefore the coverage results are not aggregated, I've seen https://github.com/elastic/beats/blob/main/dev-tools/aggregate_coverage.py.

  1. Is it required to aggregate the results from all platforms?
  2. Does the existing coverage in https://fleet-ci.elastic.co/job/elastic-agent/job/elastic-agent-mbp/job/PR-377/4/coverage/ reflect the real test coverage?

image

Tasks

@mergify mergify bot assigned v1v Apr 26, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 26, 2022

This pull request does not have a backport label. Could you fix it @v1v? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@elasticmachine
Copy link
Contributor

elasticmachine commented Apr 26, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-04-26T19:29:00.460+0000

  • Duration: 40 min 52 sec

Test stats 🧪

Test Results
Failed 0
Passed 3849
Skipped 21
Total 3870

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

go.sum Outdated
@@ -266,6 +266,7 @@ github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+Wji
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bonitoo-io/go-sql-bigquery v0.3.4-1.4.0/go.mod h1:J4Y6YJm0qTWB9aFziB7cPeSyc6dOZFyJdteSeybVpXQ=
github.com/boumenot/gocover-cobertura v1.2.0/go.mod h1:fz7ly8dslE42VRR5ZWLt2OHGDHjkTiA2oNvKgJEjLT0=
github.com/boumenot/gocover-cobertura v1.2.0/go.mod h1:fz7ly8dslE42VRR5ZWLt2OHGDHjkTiA2oNvKgJEjLT0=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also add a reference to tools.go file (on mobile, will paste link asap)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, lines 268 and 269 are exactly the same. Can you run go mod tidy and verify that?

@elasticmachine
Copy link
Contributor

elasticmachine commented Apr 26, 2022

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 95.652% (66/69)
Files 69.231% (144/208)
Classes 69.048% (290/420)
Methods 52.45% (792/1510)
Lines 38.789% (8529/21988)
Conditionals 100.0% (0/0) 💚

@v1v v1v marked this pull request as ready for review April 26, 2022 18:45
@v1v v1v requested a review from a team as a code owner April 26, 2022 18:45
@v1v v1v requested review from aleksmaus, narph and a team and removed request for a team April 26, 2022 18:45
.ci/Jenkinsfile Outdated
@@ -111,6 +112,7 @@ pipeline {
post {
always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/build/TEST-*.xml")
coverageReport(baseDir: "**/build", reportFiles: 'TEST-go-unit.html', coverageFiles: 'TEST-go-unit-cov.xml')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: is it required to aggregate the results from all the different platforms (windows, linux, arm)? If so, https://github.com/elastic/beats/blob/main/dev-tools/aggregate_coverage.py is the one in charge?

Copy link
Contributor

@jlind23 jlind23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having only the Linux coverage can be a good first step.

@ph
Copy link
Contributor

ph commented Apr 26, 2022

I am fine with only Linux, @jlind23 We should probably exclude dev-tools/* WDYT?

@v1v
Copy link
Member Author

v1v commented Apr 26, 2022

Having only the Linux coverage can be a good first step.

Thanks, 499e299 is the one only driving the test_coverage for linux

@v1v v1v added backport-v8.2.0 backport-v8.3.0 Automated backport with mergify labels Apr 27, 2022
@mergify mergify bot removed the backport-skip label Apr 27, 2022
@jlind23
Copy link
Contributor

jlind23 commented Apr 27, 2022

@ph agree, let's remove it.

@v1v
Copy link
Member Author

v1v commented Apr 27, 2022

@ph agree, let's remove it.

How? I could strip those entries in the generated cov file, but I'm not sure if the go coverage supports something natively, any hints?

@ph
Copy link
Contributor

ph commented Apr 27, 2022

@v1v I've look at that, seems not a simple solution other than removing the files or path from the coverage output https://stackoverflow.com/questions/50065448/how-to-ignore-generated-files-from-go-test-coverage

@v1v
Copy link
Member Author

v1v commented Apr 28, 2022

@ph,
do you think we can move on with this PR as is? Then someone in your team can help with ignoring nay giving list of files from the code coverage report in a follow up?

@jlind23
Copy link
Contributor

jlind23 commented Apr 28, 2022

@v1v sure move ahead, we will update it afterwards.

@v1v
Copy link
Member Author

v1v commented Apr 28, 2022

I only need some 👍 in the code review, so I can merge it :)

@v1v v1v merged commit 752c699 into elastic:main Apr 28, 2022
mergify bot pushed a commit that referenced this pull request Apr 28, 2022
(cherry picked from commit 752c699)
v1v added a commit that referenced this pull request May 17, 2022
(cherry picked from commit 752c699)

Co-authored-by: Victor Martinez <[email protected]>
v1v added a commit to v1v/elastic-agent that referenced this pull request May 18, 2022
…use-orka

* 'main' of github.com:elastic/elastic-agent: (23 commits)
  [Automation] Update go release version to 1.17.10 (elastic#432)
  [Automation] Update elastic stack version to 8.3.0-4149272f for testing (elastic#435)
  [Automation] Update elastic stack version to 8.3.0-19aba912 for testing (elastic#430)
  Add extra k8s resources in clusterRole (elastic#424)
  [Automation] Update elastic stack version to 8.3.0-8ee1196f for testing (elastic#422)
  [Automation] Update elastic stack version to 8.3.0-53513548 for testing (elastic#421)
  Add tags option during enroll/install (elastic#336)
  validate kubernetes templates in .CI (elastic#417)
  add missing kube-api resources from managed agent manifest (elastic#381)
  Create snyk-scan.yml (elastic#397)
  [Automation] Update elastic stack version to 8.3.0-d380914f for testing (elastic#414)
  [Automation] Update elastic stack version to 8.3.0-5c1ff35f for testing (elastic#413)
  [Automation] Update elastic stack version to 8.3.0-6ba9f710 for testing (elastic#410)
  [Automation] Update elastic stack version to 8.3.0-a1c5cfff for testing (elastic#406)
  [Automation] Update elastic stack version to 8.3.0-7f585873 for testing (elastic#401)
  [Automation] Update elastic stack version to 8.3.0-0b6ea9f2 for testing (elastic#399)
  ci: enable coverage (elastic#377)
  Remove last dependencies on beats repo (elastic#387)
  Remove dependency on libbeat (elastic#344)
  [Automation] Update elastic stack version to 8.3.0-cb2ce38c for testing (elastic#383)
  ...
alexsapran added a commit to alexsapran/elastic-agent that referenced this pull request Oct 14, 2024
This is something that was introduced with
elastic#377 and was meant to be
used with Jenkins to show coverage report.

Now with Jenkins been replace and BK + Sonar enabled on the repo, there
is no need to create such artifacts anymore.

Signed-off-by: Alexandros Sapranidis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.2.0 backport-v8.3.0 Automated backport with mergify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants