ci.py: refactoring