Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Python version depending on env var (using travis-ci)

Is there a way to configure travis-ci to make the Python versions dependent on a certain env var?

Please consider the following travis.yml config:

language: python
python:
  - "2.5"
  - "2.6"
  - "2.7"
env:
  - DJANGO=1.3.4
  - DJANGO=1.4.2
  - DJANGO=https://github.com/django/django/zipball/master
install:
  - pip install -q Django==$DJANGO --use-mirrors
  - pip install -e . --use-mirrors
script:
  - python src/runtests.py

Among Django 1.3 (DJANGO=1.3.4) and 1.4 (DJANGO=1.4.2) i also want to test against the latest development version of Django (DJANGO=https://github.com/django/django/zipball/master), which is basically Django 1.5.

The problem i see is that travis-ci will automatically run the integration against all specified Python versions. Django 1.5 however doesn't support Python 2.5 anymore. Is it possible to omit it for the Django development version so that i get integrations like this only:

  • DJANGO=1.3.4 --> python "2.5", "2.6", "2.7"
  • DJANGO=1.4.2 --> python "2.5", "2.6", "2.7"
  • DJANGO=https://github.com/django/django/zipball/master --> python "2.6", "2.7"

UPDATE:

Here's a link to a live example based on Odi's answer which i've been using successfully for a few months: https://github.com/deschler/django-modeltranslation/blob/master/.travis.yml

like image 454
Dirk Eschler Avatar asked Oct 29 '12 12:10

Dirk Eschler


1 Answers

You can specify configurations that you want to exclude from the build matrix (i.e. combinations that you don't want to test).

Add this to your .travis.yml:

matrix:
  exclude:
   - python: "2.5"
     env: DJANGO=https://github.com/django/django/zipball/master

Note: only exact matches will be excluded.

See the build documentation (section The Build Matrix) for further information.

like image 60
Odi Avatar answered Nov 07 '22 07:11

Odi