Comments (10)
I have no idea what you're talking about, sorry π
from pybuilder.
Hmm.
The SonarQube plugin is one of the core plugins, right?
I know, I might struggle to word my questions clearly.
Let me try again.
- SonarQube is a protected resource (at least at my company). So, there are credentials needed to connect to it to publish code coverage and code scan results. Even if an external application is used for that. One of the credentials used (and I'm using it all the time at work) is 'authentication token' (it's just some long value). If it's not used (as per the plugin's code) then some other authentication information should be provided to the
sonar-scanner
, right? - I feel like there's a typo in the documentation. Instead of 'sonar-scanner' it says 'sonar-runner'. That what made me confused. But okay, the code references correct app (from the SQ site's downloads). I guess I need to make it available in the PATH so that plugin would run the command w/o path (though I would appreciate if the full path to the
sonar-scanner
was exposed as a plugin parameter).
One side note. I see you are building the command to run that 'scanner'. But you don't expose an attribute to point to the code coverage report file. This somewhat limits the applicability of the plugin, because w/o knowledge of the code nobody knows where the coverage report is expected to be located/placed.
from pybuilder.
SonarQube is one of the plugins yes, but I haven't heard of anybody using it and you're the first person to ask about it in years.
I think I've interacted with it in early 2010s in Java context but that's about it.
As far as the current plugin it invokes sonar-scanner
.
From the sonar-scanner
documentation, the environmental variable can be set to authenticate using token: https://docs.sonarsource.com/sonarqube/latest/user-guide/user-account/generating-and-using-tokens/#using-a-token
from pybuilder.
One side note. I see you are building the command to run that 'scanner'. But you don't expose an attribute to point to the code coverage report file. This somewhat limits the applicability of the plugin, because w/o knowledge of the code nobody knows where the coverage report is expected to be located/placed.
from pybuilder.
How can I add the path of the executable I downloaded so that your plugin actually discovers the scanner?
I tried a naΓ―ve
if not os.environ['PATH'].endswith(scannerPath):
os.environ['PATH'] += os.pathsep + scannerPath
in the analyze
task (which seems to b called b4 the SQ plugin's run_sonar_analysis
) but was still getting the Missing prerequisite sonar-scanner...
because if i sun the scanner from command line w/scannerPath
prefixed (like some/path/to/scanner/sonar-scanner
) then everything works as expected.
I'm just confused how to make sure the OS PATH var (which I update in my task) is used by PyBuilder plugin.
from pybuilder.
Set your environment outside the PyBuilder. It's why it's called "the environment".
from pybuilder.
You mean, the external process you call from the plugin disregards any PATH manipulations in the Python code?
from pybuilder.
No, I mean PATH=/path/to/scanner:$PATH pyb -vX
. Please google "using environmental variables".
Listen, I don't mean to be unfriendly, but this isn't "how do I learn programming" forum or a PyB support forum.
Please limit the issues to reporting actual purported product failures, attaching error logs, steps to reproduce and the description of the environment where the issue reproduces.
Otherwise I can offer you a consulting price list with hourly billable in 1 hour increments per incident.
from pybuilder.
@arcivanov That's totally fine. Apologies for sounding like I was asking for programming help.
In fact, I do know about the env vars etc. Tho, yes I'm relatively new to the Python world (and might not understand how everything works compared to much travelled Java world).
If you don't mind, I can open another discussion (still have a question about how you guys implement executing external processes from plugins).
My only issue w/that was there were almost no responses to the discussions.
from pybuilder.
All right. As a novice it took me a while to get everything running. I'ld appreciate if there would have been minimal working examples or tutorials on how to use every plugin. (I struggled with SonarQube and pytest.) Here is what I've done for SonarCube:
Assuming you are following the PyBuilder Tutorial you will have a virtual Python environment. (First learning: It's not a virtual environment specific for Linux but from Python and thus will work on Windows as well.)
You should add these two lines to the venv/bin/activate
file (replace the path and token):
export SONAR_TOKEN=YOUR_TOKEN_HERE
export PATH="/home/simon/Dokumente/data_science/1st_semester/software_engineering/sonar-scanner-5.0.1.3006-linux/bin:$PATH"
This adds the required environment variables to the virtual environment every time you source it.
Then you should add the uncommented line to you build.py
to the set_poperties
. Replace the :
@init
def set_properties(project):
project.set_property("sonarqube_project_key", "musicsuitmusicsuite:2024e")
# project.set_property("sonarqube_project_name", "Music Suite")
This should do the trick as far as I can reconstruct my steps and filter out the important parts.
I'm running the analysis with pyb run_sonar_analysis
. What is a little bit odd here is that SonarCube always states that the code passes even though test coverage is not met. Seems like the communication about the aimed for threshold is not working. You have to look at the output in your terminal therefore.
If you are using pytest instead of unittest you will want to add the following lines so the test coverage is shown correctly in SonarCube:
@init
def set_properties(project):
project.set_property("sonarqube_project_key", "musicsuitmusicsuite:2024e")
# project.set_property("sonarqube_project_name", "Music Suite")
project.set_property("pytest_coverage_xml", True)
And at sonar-project.properties
(set the path to test coverage file from pytest):
# must be unique in a given SonarQube instance
sonar.projectKey=musicsuite_2024
sonar.python.coverage.reportPaths=target/reports/pytest_coverage.xml
from pybuilder.
Related Issues (20)
- There is no option to make Pybuilder use pre-release versions of modules when resolving dependencies with pip HOT 5
- Setuptools 62.2+ and twine require non-empty `long_description` HOT 16
- Python 3.11: remote process start fails in `_posixsubprocess.fork_exec` HOT 1
- The XML coverage report generated via PyBuilder can show wrong filenames and packages HOT 2
- pybuilder/terminal.py:135: ResourceWarning: unclosed file
- Python venv management needs to account for debug builds
- Should flake8 still be pinned?
- requests is not a dependency of pybuilder HOT 2
- distutils build_binary_distribution should run before "package" not "publish" HOT 2
- Problem in Windows OS HOT 3
- Module `imp` is not available in Python 3.12
- pybuilder does not run unit tests "correctly" - ModuleNotFoundError: No module named 'src' HOT 1
- pycharm: imports are unresolved but pyb works, also running the application works HOT 2
- support for netbeans or vscode HOT 4
- Specify Python version for virtual env HOT 4
- Newer versions of virtualenv causing clash with vendored virturalenv HOT 1
- Permission denied [Errno 13] when using source_distribution_plugin HOT 7
- Executing arbitrary shell command HOT 9
- SonarQube passed ignoring test coverage threshold HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pybuilder.