How to Make Travis Ci Test Package for Linux, Os X, Windows

How to make Travis CI test package for Linux, OS X, Windows?

Update 3

Windows support has been released! You can now use Travis CI with Linux, macOS, and Windows. You can find their blog post about it here.

Update 2

This feature is enabled now (no need to send request to Travis team). Though still considered beta:

  • Multi-OS

Works fine for me, here is Linux + OSX configuration:

  • .travis.yml
  • build matrix

Windows support still in progress (see windows issues) as alternative AppVeyor can be used. Example of configuration file:

  • appveyor.yml

Update

  • Multi-OS beta testing

There is an open issue for Travis CI:

  • Issue #216

As a workaround for Linux + Mac OS X you can create two branches. One with default config (for Linux) and one with objective-c language (for Mac OS X).

Travis CI + Go: creating a specific build flow for different OS

It might be simple, but matrix environement can not be done for a specific OS ...

Then just select with local environement variable:

language: go
go:
- 1.5.1
branches:
only:
- master
os:
- osx
- linux
install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
export GIMME_OS=windows;
export GIMME_ARCH=amd64;
fi
before_script:
- go get -d -v ./...
script:
- go build -v ./...
after_script:
- go test -v ./...
before_deploy:
- ./before_deploy.sh

An other way:

language: go
go:
- 1.5.1
branches:
only:
- master
matrix:
include:
- os: linux
env: GIMME_OS=windows; GIMME_ARCH=amd64;
- os: osx
before_script:
- go get -d -v ./...
script:
- go build -v ./...
after_script:
- go test -v ./...
before_deploy:
- ./before_deploy.sh

Note: the commande: - chmod +x ./before_deploy.sh can be directly done in your repository and commited on it ...

Note: The environament variable can be accessibe: http://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables or calling \printenv`

How to run travis-ci locally

This process allows you to completely reproduce any Travis build job on your computer. Also, you can interrupt the process at any time and debug. Below is an example where I perfectly reproduce the results of job #191.1 on php-school/cli-menu
.

Prerequisites

  • You have public repo on GitHub
  • You ran at least one build on Travis
  • You have Docker set up on your computer

Set up the build environment

Reference: https://docs.travis-ci.com/user/common-build-problems/

  1. Make up your own temporary build ID

    BUILDID="build-$RANDOM"
  2. View the build log, open the show more button for WORKER INFORMATION and find the INSTANCE line, paste it in here and run (replace the tag after the colon with the newest available one):

    INSTANCE="travisci/ci-garnet:packer-1512502276-986baf0"
  3. Run the headless server

    docker run --name $BUILDID -dit $INSTANCE /sbin/init
  4. Run the attached client

    docker exec -it $BUILDID bash -l

Run the job

Now you are now inside your Travis environment. Run su - travis to begin.

This step is well defined but it is more tedious and manual. You will find every command that Travis runs in the environment. To do this, look for for everything in the right column which has a tag like 0.03s.

Sample Image

On the left side you will see the actual commands. Run those commands, in order.

Result

Now is a good time to run the history command. You can restart the process and replay those commands to run the same test against an updated code base.

  • If your repo is private: ssh-keygen -t rsa -b 4096 -C "YOUR EMAIL REGISTERED IN GITHUB" then cat ~/.ssh/id_rsa.pub and click here to add a key
  • FYI: you can git pull from inside docker to load commits from your dev box before you push them to GitHub
  • If you want to change the commands Travis runs then it is YOUR responsibility to figure out how that translates back into a working .travis.yml.
  • I don't know how to clean up the Docker environment, it looks complicated, maybe this leaks memory

How to build MacOSX executables on Travis CI?

The reason why it didn't work ist that the wxPython version installed via homebrew is not 32bit. You need to install the dmg from the wxPython homepage. I found a script that does that there: https://github.com/ayufan/travis-osx-vm-templates/blob/master/scripts/packages.sh

I forked your example and managed to get it running (https://github.com/paulmueller/macapp/releases).

.travis.yml now looks like this:

language: objective-c
python:
- '2.7'
before_install:
- which python
- brew install python --universal --framework
- brew install wget
- which python
- export VERSIONER_PYTHON_PREFER_32_BIT=yes
- defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
- which python
- python --version
# https://github.com/Homebrew/homebrew/issues/34470
#- arch -i386 brew install wxpython --universal
- mkdir dl
- cd dl
- wget http://downloads.sourceforge.net/wxpython/wxPython3.0-osx-3.0.2.0-cocoa-py2.7.dmg
- ls
- cd ..
- sudo ./packages.sh
- arch -i386 python -c "import wx; print wx.__version__"
- arch -i386 pip install pyinstaller
- arch -i386 pyinstaller --noconsole --onefile hw.py
- ls
- hdiutil create dist/hw.dmg -srcfolder dist/ -ov
- zip -r dist/hw.zip dist/hw.app
- ls dist/
install: true
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: KjdN4hSHWU3ZDg6lpDNMB2we9jLayM9C8pwyQrV/Xzq8HNH5eNHP8ScI64tvnS0yJegOXnHFwUhUrkMtEs3X29TKrom+8tJ5E52IdBO7xO8fqOfeugC2239vLzc3tNI6RJX/K7CZTsSRu5U++1RJVgcWYjrCln87DuXG+HZRdOI=
file:
- "dist/hw.dmg"
- "dist/hw.zip"
on:
tags: true
all_branches: true
repo: paulmueller/macapp

How to pass Travis CI test for python click.version_option decorator?

Turning the comment into an answer:

You need to generate package metadata so the version can be read from. This can be done in different ways, the minimal being

$ python setup.py egg_info

However, much better is installing the package in editable mode:

$ pip install --editable .

For Travis, just add another command to the install section:

install:
- pip install --upgrade pip
- pip install -r requirements.txt
- pip install --editable .

You can even combine all three commands into one:

- pip install --upgrade pip -r requirements.txt --editable .

.NET Core - build/package for net451 on Linux (Travis CI)

To target .NET Framework targets e.g. net451 in Travis, you need Mono installed.

I fixed by changing mono: none to mono: 4.0.5.

How do I use Travis-CI with C# or F#

Travis CI now supports C#. Quoting liberally from that page:

Overview


The setup for C#, F#, and Visual Basic projects looks like this:

language: csharp
solution: solution-name.sln
mono:
- latest
- 3.12.0
- 3.10.0

Script


By default Travis will run xbuild solution-name.sln. Xbuild is a build tool designed to be an implementation for Microsoft's MSBuild tool. To override this, you can set the script attribute like this:

language: csharp
solution: solution-name.sln
script: ./build.sh

NuGet


By default, Travis will run nuget restore solution-name.sln, which restores all NuGet packages from your solution file. To override this, you can set the install attribute like this:

language: csharp
solution: solution-name.sln
install:
- sudo dosomething
- nuget restore solution-name.sln

using travis-ci with wxpython tests

I've been trying to do the same thing for quite some time. Here's what I've found:

Travis-CI:

One of the reasons things are a little difficult is that Travis-CI is running Ubunutu 12.04, and wxPython only has pre-built binaries up to 11.04. Another reason was that some ubuntu packages were disallowed on travis (though they have since been whitelisted).


Python 2 and wxPython 2.8:

This one is pretty easy, since it's in the ubuntu apt repositories. Have the following in your .travis.yml file:

addons:
apt:
packages:
# for wxPython:
- python-wxgtk2.8
- python-wxtools
- wx2.8-doc
- wx2.8-examples
- wx2.8-headers
- wx2.8-i18n

Source


For Python 2 and wxPython 3.0 (classic, not Phoenix):

You can use Conda to install it wxPython. Here's the relevent portion of .travis.yml:

before_install:
# get Conda
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a

install:
# install wxPython 3.0.0.0
- conda install -c https://conda.anaconda.org/travis wxpython

(I personally like it in before_install, but you could also put this towards the top of install).

Source


For Python 3 and wxPython Phoenix 3.0:

I've so far been unsuccessful with this. I've tried:

  • building from source using the build/build.py script provided by wxPython
  • building from source in the standard linux way (configure, make, make install)
  • using conda
  • pip install --upgrade --pre --trusted-host wxpython.org -vvv -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix

    • note the -vvv on pip: since the build takes ~20 minutes, Travis will abort if there's no console output (it assumes the cmd has locked up). Adding verbosity prevents that abort from happening.

and none of them have worked completely. Some got further than others: for example, installing via pip appears to get through the wxWidgets configure and make just fine, but fails somewhere in the SIP build (it also takes 20 minutes...)

Hopefully I figure it out soon.


Appveyor:

I know you only asked about Travis, but I use Travis + AppVeyor to cover all operating systems so I figured others do the same. Might as well keep all the info in one place.

These are much, much easier. Simply find a pre-built wheel file for the version of wxPython that you want and install it with pip:

- "%CMD_IN_ENV% pip install --upgrade --pre http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win32.whl"


Related Topics



Leave a reply



Submit