Building Eiffel projects with TravisCI

by javier (modified: 2017 Aug 07)

Eiffel CI Tutorial: Getting Started with TravisCI

We know that we need to test our applications thoroughly to catch problems before they affect our users. Eiffel Developers has the advantages of Design by Contract, but we also need to double check our code. Forgetting to test can result in complications, endless debugging sessions, money, etc, but remembering to run test cases before each commit, pull-request or merge can be can be difficult if you have to do it manually.

Continuous Integration

Continuous Integration, often abbreviated to just CI, is the process of automatically building and running tests whenever a change is committed. In this tutorial, we will cover Travis.CI

You need to sign up for a GitHub account if you do not already have one.

Getting-Started with Travis CI

What is Travis CI?

It’s a Continuous Integration service that is free for open-source projects and has a monthly fee for closed-source projects based on how many simultaneous builds you want to run.

What does it do?

Travis sets up hooks with GitHub to automatically run tests at specified times. By default, these are set up to run after a pull request is created or when the code is pushed up to GitHub.

In this tutorial, we will use a public GitHub repo and the free version of Travis to set up tests that run every time you try to merge new changes into the repository.

  • Go to GitHub and fork the EiffelCI example.
  • Sign in to Travis CI with your GitHub account, accepting the GitHub access permissions confirmation.
  • Once you’re signed in,Travis synchronized your repositories from GitHub, go to your profile page and enable Travis CI builds for your fork of the EiffelCI repository. Take a look at .travis.yml, the file which tells Travis CI what to do:

language: eiffel before_script: - export current_dir=$PWD ; echo current_dir=$current_dir ; cd .. - export ISE_EIFFEL=$PWD/Eiffel_17.11; - export ISE_PLATFORM=linux-x86-64 - curl -sSL | tar -x --bzip2 - export PATH=$PATH:$ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin:$PATH:$ISE_EIFFEL/tools/spec/$ISE_PLATFORM/bin - echo `ec -version` - cd $current_dir script: #compile code - compile_all -ecb -melt -list_failures -log_verbose -clean -options dotnet=falseIn this file, we tell Travis-CI we are using Eiffel since Eiffel is not supported by default before to run the script, we download the EiffelStudio compiler, install it and then we compile the code

  • Edit the file, Application.e for example: add the variable id: STRING, commit and push, to trigger a Travis CI build.

git commit -m 'Testing Eiffel with Travis CI' git push

   Note: Travis only runs a build on the commits you push after adding the repository to Travis.
  • Fix the code by making sure that variable ‘id’ of type STRING’ is properly set. commit and push to GitHub. This time, the build does not fail.

That’s basically a simple configuration, now you know how to add a GitHub repository to Travis and learnt the basics of configuring builds and testing code for your Eiffel projects.