[Cubicweb] a script to automatically upgrade your cube dependencies if they pass your tests

Laurent Peuch cortex at worlddomination.be
Thu May 2 14:43:21 CEST 2019

On Thu, May 02, 2019 at 02:21:46PM +0200, Laurent Peuch wrote:
> Hello everyone,
> In the context of migrating a CW instance to a more recent version of
> cubicweb one of the reccuring task is to upgrade all its dependencies.
> That can be a long a repetitive task (pick a new version, launch test,
> oupsi I forgot to change import for newstyle cube, relaunch test, fix
> bugs, repeats etc...) so I've made a script to automate as much as
> possible this part of the work.
> And it really does that workflow automatically:
> for every dependency in __pkginfo__.py:
> - update it
> - if it's a cube in newstyle, change imports
> - if it passes tests, commit
> - otherwise try to find the newest version that passes it then commit
> - print a nice summary with link to failed logs for debugging
> And the usage is very simple:
>     pip install --user git+https://github.com/Psycojoker/autoupgradedependencies
>     # in the folder with the .hg
>     autoupgradedependencies "test command"
>     # examples
>     autoupgradedependencies "tox -e py27 --recreate"
>     autoupgradedependencies "py.test tests"
> Be aware that this can be quite long since tests on cubes are
> generally quite long.
> This script will probably ends up in a jenkins or something similar at
> one point :)
> On of the limitation is that `__depends__` needs to be statically
> declared in the __pkginfo__.py (that means not generated in python
> with conditions and others) as it is parsed why RedBaron (but I've yet
> to see a `__pkginfo__.py` in which it's the case.)
> The code is available here
> https://github.com/Psycojoker/autoupgradedependencies it's pretty
> young so there might be bugs (but it works on one project on which
> I've used it), so feel free to seend patches, feedback etc... :)

Oh and one last thing on that regard: I've created a tox test to see
if you have outdated dependencies that you can add to your project,
here it is: https://gist.github.com/Psycojoker/34b70adcbe91c06064ccf7f10cf6d825

I'm probably going to merge all those tools (and others) in a "cubetk"
at some point I think, that will make things easier to discover.


Laurent Peuch -- Bram

More information about the Cubicweb mailing list