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

Sonarqube integration #2938

Merged
merged 8 commits into from
Sep 4, 2023
Merged

Sonarqube integration #2938

merged 8 commits into from
Sep 4, 2023

Conversation

pazone
Copy link
Contributor

@pazone pazone commented Aug 31, 2023

What is the problem this PR solves?

Enables sonarqube code scanning and coverage reports.

Sonar project for fleet-server is already created.

This configuration provides:

Pull request analysis: Analyses newly added code for a particular pull request
SonarQube automatically adds a comment with digest information. If no java files were changed in a pull request we will see “No coverage/duplication information” labels

Branch analysis: Runs on branches like main and analyzes the entire codebase. Associates received code coverage with the branch

Sonarqube Requires a quality profile

Quality profile is configured on the sonarqube side.
Questions to the team:

  • What is the desired code coverage for the project?
  • Minimal code coverage for pull request? (SonarQube has a separate measure for newly added/changed code)

Checklist

  • 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
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool

Related issues

@pazone pazone added the enhancement New feature or request label Aug 31, 2023
@pazone pazone requested a review from a team as a code owner August 31, 2023 15:12
@elasticmachine
Copy link
Contributor

elasticmachine commented Aug 31, 2023

💚 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: 2023-09-04T14:40:14.767+0000

  • Duration: 35 min 30 sec

Test stats 🧪

Test Results
Failed 0
Passed 815
Skipped 1
Total 816

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

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

  • /test : Re-trigger the build.

@jlind23
Copy link
Contributor

jlind23 commented Sep 1, 2023

@pazone our buildkite build seems to be failing due to
2023-08-31 15:13:34 FATAL Failed to upload and process pipeline: Pipeline upload rejected: Detected dependency cycle: :sonarqube: Continuous Code Inspection → :sonarqube: Continuous Code Inspection

If by any chance that rings a bell on your end.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@pazone pazone force-pushed the sonarqube branch 2 times, most recently from c779335 to 5dc099f Compare September 4, 2023 14:15
@pazone
Copy link
Contributor Author

pazone commented Sep 4, 2023

@jlind23 Do I understand correctly that now we don't need the Code coverage build stage made by Github actions?
https://github.com/elastic/fleet-server/blob/main/.github/workflows/build.yml
And we also run same unit tests in Jenkins on each PR: https://github.com/elastic/fleet-server/blob/main/.ci/Jenkinsfile#L75

I'd delete the Github Action workflow and the Jenkins step
We run unit tests in BK and use sonarQube for coverage

@elastic-sonarqube
Copy link

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

LGTM, just one doubt about when this new step needs to run

Comment on lines +46 to +55
- label: ":sonarqube: Continuous Code Inspection"
env:
VAULT_SONAR_TOKEN_PATH: "kv/ci-shared/platform-ingest/elastic/fleet-server/sonar-analyze-token"
agents:
image: "docker.elastic.co/cloud-ci/sonarqube/buildkite-scanner:latest"
command:
- "buildkite-agent artifact download build/coverage.out ."
- "/scan-source-code.sh"
depends_on:
- "unit-test"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be running in all branches and PRs or just PRs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All branches. We also need to analyse main

@pazone pazone merged commit 8304bdc into main Sep 4, 2023
5 checks passed
@pazone pazone deleted the sonarqube branch September 4, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants