OCA / interface-github

Tools to interact with github from Odoo
GNU Affero General Public License v3.0
46 stars 77 forks source link

[13.0][IMP] github_connector: Code analysis #63

Closed victoralmau closed 3 years ago

victoralmau commented 4 years ago

Analysis source code

It's possible to create custom analaysis rule that can related to Organization and/or Repository to analyze repository code

. Go to 'Settings' / 'Analysis rule groups' and create records that allow to organize the rules

. Go to 'Settings' / 'Analysis rules' and create rules, for example:

  1. Name: All code, Group: General, Paths: *
  2. Name: Python code, Group: General, Paths: *.py
  3. Name: Xml code, Group: General, Paths: *.xml
  4. Name: Repository 1, Group: Custom, Paths: /path/

Note: Paths field in 'Analysis rule' allow to put multiple paths for line, path format is according to https://github.com/cpburnz/python-path-specification#tutorial definition

. Go to 'Organizations' and define Analysis rules (optional)

. Go to 'Repositories' and define Analysis rules (optional)

Analysis source code is executed when 'Update Source Code Analysis' button in some 'Repository Branch', get all the Analysis rules (Repository + Organization) and analyze code and generate info about it

In 'Repository Branh' / 'Code Analysis' show the info related to Analysis rules

Analysis source code is generated by https://github.com/roskakori/pygount

Please, @pedrobaeza review it

@Tecnativa TT25569

victoralmau commented 4 years ago

some remarks inline. I have to review it more deeply.

thanks for proposing this must have feature.

just a question : did you take a look on this module https://github.com/OCA/server-tools/tree/12.0/module_analysis ?

module_analysis is a similar addon, analyze the ir_module object and all the files related to addon.

In this case the funcionality is some different because is possible to define some repositories that not contain addons, or different branch with different files, and too create custom rules to analyze the line codes related to custom paths.

victoralmau commented 4 years ago

I have created a test related to download a OCA report to analyze code after but i have found this error: https://travis-ci.org/github/OCA/interface-github/jobs/729927007#L575 I think that this error is about not specify in config github credentials. Any suggestion about make this test possible?

Note: local_path in repository_branch is a readonly field and can't use it.

joao-p-marques commented 4 years ago

Maybe you can change the github_login variable to something different. If you used something like test would it work?

victoralmau commented 4 years ago

Maybe you can change the github_login variable to something different. If you used something like test would it work?

Thanks Joao, little change applied now and only test OCA organization (error github login disappear) but error in tests continue. I have to investigate more about it

victoralmau commented 4 years ago

Test problem solved!

victoralmau commented 4 years ago
  • Add admin user to GitHub manager group (in data, not in demo).

  • Add series 13.0 and 14.0 to OCA demo organization

It's changed now.

victoralmau commented 4 years ago

Functional review:

* Seems that some rules don't fetch results:

Selección_023

IMO you don't get data about rules because paths in demo rules not fine, changed now and works. Other option is modify analysis rules about tests.

pedrobaeza commented 4 years ago

Tests rule must be put on demo data on github_connector_odoo that makes more sense, but the rest should work. About repository branch rule definition, it can't be put at the other module level, as you can have differences in paths not talking about Odoo modules (for example, the ORM being hosted in openerp or in odoo folder), but don't think in this only for Odoo itself, but for Python libraries, so we need to add such definition here.

victoralmau commented 4 years ago

Tests rule must be put on demo data on github_connector_odoo that makes more sense, but the rest should work.

Now github_connector_odoo add other rules in data (in other PR) but rules defined in this PR work fine?

victoralmau commented 4 years ago

About repository branch rule definition, it can't be put at the other module level, as you can have differences in paths not talking about Odoo modules (for example, the ORM being hosted in openerp or in odoo folder), but don't think in this only for Odoo itself, but for Python libraries, so we need to add such definition here.

About it, it's necessary to add root_path field in repository_branch model and analysis rules apply about this path. It's correct?

pedrobaeza commented 4 years ago

root_path is something of this PR? I think only rules should be defined at repository branch level.

victoralmau commented 4 years ago

root_path is something of this PR? I think only rules should be defined at repository branch level.

Sorry for confusion. Now, rules can apply repository branch too and analyze all (organization + repository + repository_branch).

pedrobaeza commented 3 years ago

@victoralmau please rebase this and fix conflicts, and check if https://github.com/OCA/server-tools/pull/2036 applies here

victoralmau commented 3 years ago

The rebase has been applied.

This PR - https://github.com/OCA/server-tools/pull/2036 - was already applied here but you introduced me to a new addon that I didn't know: module_analysis.

Some things about it:

pedrobaeza commented 3 years ago

Talked by chat. Go ahead with it!

pedrobaeza commented 3 years ago

/ocabot merge major

OCA-git-bot commented 3 years ago

This PR looks fantastic, let's merge it! Prepared branch 13.0-ocabot-merge-pr-63-by-pedrobaeza-bump-major, awaiting test results.

OCA-git-bot commented 3 years ago

Congratulations, your PR was merged at 4b8b1e81c55a9e0fe7606ed29d32b5ebfcaab472. Thanks a lot for contributing to OCA. ❤️