-
Notifications
You must be signed in to change notification settings - Fork 33
ci: enable sonar scanning and report results to sonacloud.io #788
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Arjun Rajappa <[email protected]>
Signed-off-by: Arjun Rajappa <[email protected]>
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. |
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.
Could you update the image of the final_job
to use python:3.13
, please?
@@ -296,7 +303,7 @@ jobs: | |||
- pip-install-deps | |||
- pip-install-tests-deps | |||
- store-pytest-results |
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.
You can remove those three steps and only install coverage
by changing line 96 to something like:
python -m venv venv
. venv/bin/activate
pip install --upgrade pip coverage
Signed-off-by: Arjun Rajappa <[email protected]>
Signed-off-by: Arjun Rajappa <[email protected]>
❌ @arjun-rajappa the
📝 What should I do to fix it?All proposed commits should include a sign-off in their messages, ideally at the end. ❔ Why it is requiredThe Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project. Here is the full text of the DCO, reformatted for readability:
Contributors sign-off that they adhere to these requirements by adding a
Git even has a
|
Signed-off-by: Arjun Rajappa <[email protected]>
2c81ec1
to
aa9f6bb
Compare
|
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.
A few questions and requests....
- image: public.ecr.aws/docker/library/python:3.13 | ||
working_directory: ~/repo | ||
steps: | ||
- checkout | ||
- check-if-tests-needed | ||
- pip-install-deps | ||
- pip-install-tests-deps | ||
- store-pytest-results | ||
# - run_sonarqube | ||
- run_sonarqube |
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.
You are still executing the pip install
commands that are not necessary here:
- image: public.ecr.aws/docker/library/python:3.13 | |
working_directory: ~/repo | |
steps: | |
- checkout | |
- check-if-tests-needed | |
- pip-install-deps | |
- pip-install-tests-deps | |
- store-pytest-results | |
# - run_sonarqube | |
- run_sonarqube | |
- image: public.ecr.aws/docker/library/python:3.13 | |
working_directory: ~/repo | |
steps: | |
- checkout | |
- check-if-tests-needed | |
- run_sonarqube |
python -m venv venv | ||
. venv/bin/activate | ||
coverage combine ./coverage_results | ||
coverage xml -i | ||
wget -O /tmp/sonar-scanner-cli.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023.zip | ||
unzip -d /tmp /tmp/sonar-scanner-cli.zip | ||
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then | ||
/tmp/sonar-scanner-4.8.1.3023/bin/sonar-scanner \ | ||
-Dsonar.host.url=${SONARQUBE_URL} \ | ||
-Dsonar.login="${SONARQUBE_LOGIN}" \ | ||
-Dsonar.pullrequest.key="${CIRCLE_PR_NUMBER}" \ | ||
pip install --upgrade pip coverage | ||
|
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.
Are the files used by the coverage
command you removed necessary for the sonar-scanner
execution?
If not, you can then continue to remove those two lines, but nothing else is necessary to install, then:
python -m venv venv | |
. venv/bin/activate | |
coverage combine ./coverage_results | |
coverage xml -i | |
wget -O /tmp/sonar-scanner-cli.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023.zip | |
unzip -d /tmp /tmp/sonar-scanner-cli.zip | |
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then | |
/tmp/sonar-scanner-4.8.1.3023/bin/sonar-scanner \ | |
-Dsonar.host.url=${SONARQUBE_URL} \ | |
-Dsonar.login="${SONARQUBE_LOGIN}" \ | |
-Dsonar.pullrequest.key="${CIRCLE_PR_NUMBER}" \ | |
pip install --upgrade pip coverage |
If they are necessary, you should keep those lines and change the order of them:
python -m venv venv | |
. venv/bin/activate | |
coverage combine ./coverage_results | |
coverage xml -i | |
wget -O /tmp/sonar-scanner-cli.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.1.3023.zip | |
unzip -d /tmp /tmp/sonar-scanner-cli.zip | |
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then | |
/tmp/sonar-scanner-4.8.1.3023/bin/sonar-scanner \ | |
-Dsonar.host.url=${SONARQUBE_URL} \ | |
-Dsonar.login="${SONARQUBE_LOGIN}" \ | |
-Dsonar.pullrequest.key="${CIRCLE_PR_NUMBER}" \ | |
pip install --upgrade pip coverage | |
python -m venv venv | |
. venv/bin/activate | |
pip install --upgrade pip coverage | |
coverage combine ./coverage_results | |
coverage xml -i |
-Dsonar.organization=instana \ | ||
-Dsonar.projectKey=instana_python-sensor \ | ||
-Dsonar.sources=. \ |
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.
Don't these lines overwrite the configuration of the sonar-project.properties
file?
In addition, I guess it should be the following to only check the library code, not everything in the repository:
-Dsonar.organization=instana \ | |
-Dsonar.projectKey=instana_python-sensor \ | |
-Dsonar.sources=. \ | |
-Dsonar.organization=instana \ | |
-Dsonar.projectKey=instana_python-sensor \ | |
-Dsonar.sources=.src/instana/ \ |
-Dsonar.organization=instana \ | ||
-Dsonar.projectKey=instana_python-sensor \ | ||
-Dsonar.sources=. \ |
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.
Same as the previous comment.
sonar.tests=tests/ | ||
sonar.test.inclusions=test/**/* |
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 the documentation mentions, if the sonar.tests
"property is not defined, no code will be analyzed as test code as there is no default value."
I guess we can remove those two lines:
sonar.tests=tests/ | |
sonar.test.inclusions=test/**/* |
@arjun-rajappa, perhaps we can use the |
No description provided.