Clean-ish way to get travis to build all plone versions

So far this seems to work for plone 4.0-5.0. I didn't know there is a undocumented feature that bootstrap.py can do annotate.

  - sed -ie "s#travis-4.x.cfg#travis-$PLONE_VERSION.x.cfg#" travis.cfg
  - mkdir -p buildout-cache/downloads
  - python bootstrap.py -c travis.cfg annotate
  - virtualenv .
  - export SETUPTOOLS_SPEC=`bin/python bootstrap.py -c travis.cfg annotate | grep 'setuptools= ' | sed 's/= /==/'`
  - export BUILDOUT_SPEC=`bin/python bootstrap.py -c travis.cfg annotate | grep 'zc.buildout= ' | sed 's/= /==/'`
  - bin/pip install --upgrade pip $SETUPTOOLS_SPEC $BUILDOUT_SPEC
  - bin/buildout -qNc travis.cfg

see it run on https://travis-ci.org/collective/collective.z3cform.datagridfield

1 Like

using the travis.cfg configuration is no longer considered a best practice; you better use Travis' container-based infrastructure.

this is what I normally do:

a more complex example to create builds with different features:

@hvelarde Thanks for the tip on containers but I think you missed the point. What you have doesn't work for plone versions 4.0.x, 4.1.x, 4.2.x. It currently only works for 4.3 and 5.0 but also might break in the future since bootstrap.py has proved unreliable. This is an attempt to use a more robust bootstrapping process that extracts the versions needed for zc.buildout and setuptools and installs them via virtualenv.

@djay thank, this solves a problem I had too.

@hvelarde I'd recommend to have a look at the advanced caching - considered as best practice - used by bobtemplates.plone

https://github.com/plone/bobtemplates.plone/blob/master/bobtemplates/plone_addon/.travis.yml.bob

I'am sure there is also room for improvements. I usually do not use bootstrap.py anymore but instead pip install zc.buildout setuptools like here

@jensens I was just thinking this could be improved by doing installing zc.buildout via pip first. using that to extract the right versions from the .cfg and then getting pip downgrade zc.buildout and setuptools. Then bootstrap.py could be remove completely.

Improved version

language: python
python: 2.7
sudo: false
cache:
  pip: true
  directories:
    - $HOME/buildout-cache
env:
  - PLONE_VERSION=4.2
  - PLONE_VERSION=4.3
  - PLONE_VERSION=5.0
matrix:
  include:
    - python: 2.6
      env: PLONE_VERSION=4.0
    - python: 2.6
      env: PLONE_VERSION=4.1
  allow_failures:
    - python: 2.6
      env: PLONE_VERSION=4.0
install:
  - sed -ie "s#travis-4.x.cfg#travis-$PLONE_VERSION.x.cfg#" travis.cfg
  - mkdir -p buildout-cache/{eggs,downloads}
  - virtualenv .
  - bin/pip install --upgrade pip zc.buildout
  - bin/buildout -c travis.cfg annotate | tee annotate.txt | grep -E 'setuptools= |zc.buildout= ' | sed 's/= /==/' > requirements.txt
  - cat annotate.txt
  - cat requirements.txt
  - bin/pip install --upgrade -r requirements.txt
  - bin/buildout -qNc travis.cfg
before_script:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start
  - firefox -v
script: bin/test

of course it works as you already noticed in your latest post; I've been using that solution for over 2 years as you can see here: collective.prettydate/.travis.yml at master · collective/collective.prettydate · GitHub

in general, most of the time I skip testing for Plone 4.0 as is really hard to keep compatibility with it unless your add-on is really simple.

I had problems in the past with bootstrap.py but keeping it updated in the latest version solved them all. I tried also different approaches but they seemed less reliable overall and I don't want to deal with different ways of doing things.

no, the travis.cfg configuration was a hack @datakurre developed before the Travis CI container-based infrastructure was available. it's totally unnecessary right now and adds overhead to the simple process of having just one buildout configuration for development and CI.

it must be removed from bobtemplates.plone as is not a best practice at all.

May you open a ticket there with an improved version, or even better a pull request?

done: https://github.com/plone/bobtemplates.plone/pull/162

1 Like

@hvelarde I've no idea what you think I noticed but perhaps you didn't read the code before commenting? This solution stands as a way to get a working buildout without needing to update bootstrap.py. It is bootstrap.py problem free, something I can't be bothered with.

I don't care about how you initialize your buildout; I care about how you install Plone and you are using a method that is outdated and most be deprecated.

I'm fixing the bobtemplates.plone to avoid more people making the same mistake, using something that is not a best practice since 2014.

IMO, a better solution is just to download the most recent version of bootstrap.py at build time so we don't have to invent yet another way of doing things… but that's only my opinion.

I don't care that you don't care how I initialise a buildout. I do care that "how to best initialize a buildout" is the entire point of this thread and you hijacked it. If you care so much about an optimisation like caching then start your own thread on it. It's irrelevant to this discussion.

then change the title of you thread, because "Clean-ish way to get travis to build all plone versions" is obviously not what you want.

have a nice weekend!