Tsjerk / Insane

INSert membrANE - A simple, versatile tool for building coarse-grained simulation systems
GNU General Public License v2.0
39 stars 24 forks source link

Make travis build the zip package #56

Closed jbarnoud closed 6 years ago

jbarnoud commented 6 years ago

In order to have the changes in Insane available to the end user as soon as possible, we want to have the zip package built as soon as we make the changes. This commit makes travis build the zip package if all the tests pass, and have the package uploaded on a dedicated branch on github.

With this commit, Insane makes use of the new "stage" feature of travis: https://blog.travis-ci.com/2017-05-11-introducing-build-stages. Stages are set of jobs that depends on the previous sets so that the job in a set only run if all the job from the previous step succeeded. Here we use 3 successive stages: the "test" stage runs the unit tests and the regression tests; the "package" stage make sure the zip package can be built on both python 2 and 3 and that the package runs; finally, the "deploy" stage build the zip package and push it on github in a dedicated branch called "package".

The deployment script only runs if the travis job corresponds to a push (or a merge) on the master branch. If the travis job is triggered from an other branch, or if it is triggered by a pull request, then the deploy script exits with a message and a 0 exit code.

Two files can be created by the deployment script: for regular push and merge, the insane-dev file is created, for tags the insane and the insane-dev files are created. This allows to have both insane-dev being the latest development version, and insane being the latest stable version. insane and insane-dev should be accessible at https://github.com/Tsjerk/Insane/blob/package/insane and https://github.com/Tsjerk/Insane/blob/package/insane-dev, respectively.

Some preparation is required prior to merging this commit:

Configure travis

A new branch called "package" will be created. This branch is going to be updated every time the deploy script fully executes. By default, such activity will trigger a travis run that will fail. To avoid triggering useless travis job, we can configure travis to not run when the .travis.yml file is absent, which will be the case for the "package" branch.

As a logged user on travis, go to https://travis-ci.org/Tsjerk/Insane/settings and activate the option "Build only if .travis.yml is present".

Setup the "package" branch

On a local machine, create a new branch called "package" in the Insane repository:

git checkout -b package

Empty the content of the branch:

git rm -rf insane tests LICENSE  maintainers  README.md  setup.py .travis.yml
rm -rf insane tests LICENSE  maintainers  README.md  setup.py .travis.yml

Add and commit a non-empty file to the "package" branch (maybe a README.md file), then push the branch to github.

Create a github token for travis

Travis will need write access to the git repository on github. This access can be granted with an authentication token. Go to the "Personal access token" page of the giuhub settings (https://github.com/settings/tokens) and create the token. Only the "public repo" permission is needed.

Keep the token accessible for the next step.

Encrypt the github token

The github token will have to be written in the travis file, but it should not be written in clear text! Travis offers a encryption mechanism for sensible data: https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml

The encryption needs to be done using the "travis" command line tool. The tool is installed in /home/jon/.gem/ruby/2.3.0/bin/travis.

In the directory corresponding to the git repository of Insane, run:

travis encrypt GH_TOKEN="your github token"

Edit the pull request to update the encrypted key in .travis.yml.

Merge the pull request

You can now merge the pull request. This should trigger a travis job that will generate insane-dev in the "package" branch. insane will be generated at the next release.