pybuilder icon indicating copy to clipboard operation
pybuilder copied to clipboard

Basic Pybuilder project with Sonarqube

Open debasishdebs opened this issue 5 years ago • 1 comments

Don't know if the docs aren't clear or I'm doing something wrong. I've been using PyBuilder since years now but without SonarQube. This is 1st time I'm bringing SonarQube integration into my project. Trying to create a minimalistic project but build fails. Any help here?

(master) D:\Projects\Edge_Analytics_Training\MLOps_Stream2>pip show pybuilder
Name: pybuilder
Version: 0.12.6
Summary: PyBuilder — an easy-to-use build automation tool for Python.
Home-page: https://pybuilder.io
Author: Arcadiy Ivanov, Alexander Metzner, Maximilien Riehl, Michael Gruber, Udo Juettner, Marcel Wolf, Valentin Haenel
Author-email: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
License: Apache License, Version 2.0
Location: c:\users\debasishkanhar\anaconda3\envs\master\lib\site-packages
Requires:
Required-by:

OS: Windows. Python: 3.6

Here is my build.py

from pybuilder.core import use_plugin, init

use_plugin("python.core")
use_plugin("python.unittest")
use_plugin("python.install_dependencies")
use_plugin("python.sonarqube")
use_plugin("python.distutils")
# use_plugin("python.sphinx")
# use_plugin("python.integrationtest")

default_task = ["clean", "install_dependencies", "analyze", "publish"]

name = "MLOps_Stream2"

@init
def initialize(project):
    project.build_depends_on_requirements("req.txt")

@init
def set_properties(project):
    project.set_property("verbose", True)

    project.set_property("sonarqube_project_key", "xkyjskks")
    project.set_property("sonarqube_project_name", name)

    project.set_property("sphinx_config_path", "docs/")
    project.set_property("sphinx_source_dir", "docs/")
    project.set_property("sphinx_output_dir", "docs/")
    pass

And here is error I get when running both pyb or pyb -xV

(master) D:\Projects\Edge_Analytics_Training\MLOps_Stream2>pyb
PyBuilder version 0.12.6
Build started at 2020-07-08 15:01:17
------------------------------------------------------------
------------------------------------------------------------
BUILD FAILED - Missing task 'analyze' required for task 'run_sonar_analysis' (site-packages\pybuilder\execution.py:516)
------------------------------------------------------------
Build finished at 2020-07-08 15:01:30
Build took 13 seconds (13075 ms)

If I remove sonarqube plugin and analyze task the build passes with following logs:

(master) D:\Projects\Edge_Analytics_Training\MLOps_Stream2>pyb -xV
PyBuilder version 0.12.6
Build started at 2020-07-08 15:10:04
------------------------------------------------------------
[INFO]  Building MLOps_Stream2 version 1.0.dev0
[INFO]  Executing build in d:\projects\edge_analytics_training\mlops_stream2
[INFO]  Going to execute tasks: clean, install_dependencies, publish
[INFO]  Removing target directory d:\projects\edge_analytics_training\mlops_stream2\target
[INFO]  Processing plugin packages 'pypandoc~=1.4' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'setuptools>=38.6.0' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'twine>=1.15.0' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'unittest-xml-reporting~=2.5.2' to be installed with {'upgrade': True}
[INFO]  Processing plugin packages 'wheel>=0.34.0' to be installed with {'upgrade': True}
[INFO]  Creating target 'build' VEnv in 'd:\projects\edge_analytics_training\mlops_stream2\target\venv\build\cpython-3.6.10.final.0'
[INFO]  Processing dependency packages 'build_requirements.txt' to be installed with {}
[INFO]  Creating target 'test' VEnv in 'd:\projects\edge_analytics_training\mlops_stream2\target\venv\test\cpython-3.6.10.final.0'
[INFO]  Installing all dependencies
[INFO]  Processing dependency packages 'build_requirements.txt' to be installed with {}
[INFO]  Running unit tests
[INFO]  Executing unit tests from Python modules in d:\projects\edge_analytics_training\mlops_stream2\src\unittest\python
[WARN]  No unit tests executed.
[INFO]  All unit tests passed.
[INFO]  Building distribution in d:\projects\edge_analytics_training\mlops_stream2\target\dist\mlops_stream2-1.0.dev0
[INFO]  Copying scripts to d:\projects\edge_analytics_training\mlops_stream2\target\dist\mlops_stream2-1.0.dev0\scripts
[INFO]  Writing setup.py as d:\projects\edge_analytics_training\mlops_stream2\target\dist\mlops_stream2-1.0.dev0\setup.py
[INFO]  Building binary distribution in d:\projects\edge_analytics_training\mlops_stream2\target\dist\mlops_stream2-1.0.dev0
[INFO]  Running Twine check for generated artifcats
------------------------------------------------------------
BUILD SUCCESSFUL
------------------------------------------------------------
Build Summary
             Project: MLOps_Stream2
             Version: 1.0.dev0
      Base directory: d:\projects\edge_analytics_training\mlops_stream2
        Environments:
               Tasks: clean [349 ms] prepare [129882 ms] install_dependencies [76272 ms] compile_sources [0 ms] run_unit_tests [377 ms] package [5 ms] run_integration_tests [0 ms] verify [0 ms] publish [2480 ms]
Build finished at 2020-07-08 15:13:45
Build took 221 seconds (221185 ms)

Only thing, I can think maybe error can be, I've dummy key and name in sonarqube project proerties. Can that be reason?

debasishdebs avatar Jul 08 '20 09:07 debasishdebs

For me it worked running pyb run_sonar_analysis after setting everything up correctly which took me a while since I'm still a IT student. I will document what I have done at #902 .

Famondir avatar Feb 07 '24 08:02 Famondir