openfisca / openfisca-core

OpenFisca core engine. See other repositories for countries-specific code & data.
https://openfisca.org
GNU Affero General Public License v3.0
168 stars 75 forks source link

Add semantic version checks #1045

Closed bonjourmauko closed 2 years ago

bonjourmauko commented 2 years ago

Depends on #1044

New features

Example

$ make check-version

[⚙] Check if the current version is acceptable…
[i] Parsing files from HEAD…
[i] Parsing files from 35.5.1…                                                                      
[i] Checking for functional changes…                                                                
[!] ~ openfisca_tasks/check_version.py                                                              
[!] ~ openfisca_tasks/__main__.py                                                                   
[!] ~ openfisca_tasks/_repo.py                                                                      
[!] ~ openfisca_tasks/_parser.py                                                                    
[!] ~ openfisca_core/commons/decorators.py                                                          
[!] ~ openfisca_tasks/_builder.py                                                                   
[!] ~ CHANGELOG.md                                                                                  
[!] ~ openfisca_core/commons/dummy.py                                                               
[!] ~ openfisca_tasks/_progress_bar.py                                                              
[!] ~ setup.py                                                                                      
[!] ~ setup.cfg                                                                                     
[!] ~ openfisca_tasks/check_deprecated.py                                                           
[!] ~ openfisca_tasks/_bumper.py                                                                    
[!] ~ openfisca_tasks/__init__.py                                                                   
[!] ~ openfisca_core/commons/__init__.py                                                            
[!] ~ conftest.py                                                                                   
[!] ~ openfisca_tasks/_protocols.py                                                                 
[i] Checking for added functions…                                                                   
[!] + openfisca_tasks._builder.visit_FunctionDef                                                    
[!] + openfisca_tasks.check_version.__call__                                                        
[!] + openfisca_tasks._protocols.okay                                                               
[!] + openfisca_tasks._bumper.is_acceptable                                                         
[!] + openfisca_tasks._repo.before                                                                  
[!] + openfisca_tasks._protocols.init                                                               
[!] + openfisca_tasks._protocols.info                                                               
[!] + openfisca_tasks._repo.before(bis)                                                             
[!] + commons.decorators.__call__                                                                   
[!] + openfisca_tasks._protocols.fail                                                               
[!] + openfisca_tasks._progress_bar.init                                                            
[!] + openfisca_tasks._protocols.push                                                               
[!] + openfisca_tasks._protocols.then                                                               
[!] + openfisca_tasks._builder.__call__                                                             
[!] + openfisca_tasks.check_deprecated.__call__                                                     
[!] + openfisca_tasks.check_deprecated.visit_FunctionDef                                            
[!] + openfisca_tasks._bumper.__call__                                                              
[!] + openfisca_tasks._progress_bar.wipe                                                            
[!] + openfisca_tasks._progress_bar.info                                                            
[!] + openfisca_tasks._progress_bar.fail                                                            
[!] + openfisca_tasks._protocols.__init__                                                           
[!] + openfisca_tasks._protocols.__call__                                                           
[!] + openfisca_tasks._bumper.__init__                                                              
[!] + openfisca_tasks._repo.changed                                                                 
[!] + openfisca_tasks._parser.__init__                                                              
[!] + openfisca_tasks._progress_bar.warn                                                            
[!] + openfisca_tasks._repo.run                                                                     
[!] + openfisca_tasks._progress_bar.okay                                                            
[!] + openfisca_tasks._repo.show                                                                    
[!] + openfisca_tasks._parser.__call__(bis)                                                         
[!] + openfisca_tasks._protocols.wipe                                                               
[!] + openfisca_tasks._progress_bar.push                                                            
[!] + openfisca_tasks._progress_bar.then                                                            
[!] + commons.decorators.__init__                                                                   
[!] + openfisca_tasks._repo.actual                                                                  
[!] + openfisca_tasks._protocols.__call__(bis)                                                      
[!] + openfisca_tasks._parser.__call__                                                              
[!] + openfisca_tasks.check_version.__init__                                                        
[!] + openfisca_tasks._repo.actual(bis)                                                             
[!] + openfisca_tasks._protocols.warn                                                               
[!] + openfisca_tasks._builder.total#getter                                                         
[!] + openfisca_tasks.check_deprecated.__init__                                                     
[i] Checking for removed functions…                                                                 
[!] - commons.dummy.__init__                                                                        
[i] Version bump required: MAJOR!                                                                   
[✓] Current version: 36.0.0
[✓] check-version:passed ❤
MattiSG commented 2 years ago

This is very impressive work @maukoquiroga!

I remember talking about an automated semantic version checker a few weeks ago. I more had in mind a tool to help country packages (by checking the list of exposed parameters and variables) than Core contributors, but this looks fantastic as well.

However, the amount of code is quite large, and I am not sure such an automated semantic version checker should be specific to OpenFisca. Since it seems to (in a very relevant way) compare function signatures, could it maybe be a separate package? Is there not already some similar open-source project? 🙂

bonjourmauko commented 2 years ago

@MattiSG

However, the amount of code is quite large, and I am not sure such an automated semantic version checker should be specific to OpenFisca. Since it seems to (in a very relevant way) compare function signatures, could it maybe be a separate package?

Funnily, I was thinking about publishing this standalone this morning, that's why I marked it again as draft. And quite honestly, I'm not quite sure I'd like this to become part of core anymore.

Is there not already some similar open-source project?

None that I'm aware of —there are progress bars, and tools to lift the burden of AST parsing, but semantic validation, nopes.

I remember talking about an automated semantic version checker a few weeks ago. I more had in mind a tool to help country packages (by checking the list of exposed parameters and variables) than Core contributors.

Sure, you'd still have to run the WebAPI loaders with two different git revisions, or run the API with two different versions.

MattiSG commented 2 years ago

Alright, I'll go forth and close this PR then. I encourage you to ship that as an independent package, I find such a tool very promising!