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

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


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... :)

Have a nice day <3

-- 

Laurent Peuch -- Bram



More information about the Cubicweb mailing list