From db5b74eb23b95bc9ece5cd03ce991ff9247fa2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Wed, 31 May 2017 09:52:30 +0200 Subject: [PATCH 1/7] Add exercises.md --- exercises.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 exercises.md diff --git a/exercises.md b/exercises.md new file mode 100644 index 0000000..48a3293 --- /dev/null +++ b/exercises.md @@ -0,0 +1,110 @@ +# Set-up +Any problems with install instructions? + +Fork my repo https://github.com/lesteve/travis-tutorial. Clone your +own repo: +``` +git clone https://github.com//travis-tutorial +``` + +Activate your repo on Travis: https://travis-ci.org/profile//travis-tutorial +Click on "Activate repo" + +# Simple .travis.yml file +```yaml +language: python + +dist: trusty + +script: py.test +``` + +commit + push. Look at build on https://travis-ci.org//travis-tutorial + +# Broken .travis.yml +What happens if you have a broken .travis.yml? + +http://lint.travis-ci.org/ +Alternative: `gem install travis` + `travis lint`. + +# Pushing a commit +Add one commit (e.g. another assert) + watch the build on travis-ci.org. + +# Opening a PR +Open a PR on my repo https://github.com/lesteve/travis-tutorial + +Create a feature branch as the PR source and use `for-prs` as the target +branch. Maybe some conflicts will need to be solved along the line ... + +Try to follow best practices and put some minimal effort in your PR +title and PR description. +# Testing on multiple Python versions +Add test_division: + +Add this to `test_all.py`: +```py +def test_division(): + assert 3/2 == 1.5 +``` + +Add this to your `.travis.yml`: +``` +python: + - 2.7 + - 3.6 +``` + +# `install` step +New dependency: numpy. + +Add a new function test_partition with a simple test +for [numpy.partition](https://docs.scipy.org/doc/numpy/reference/generated/numpy.partition.html). + +What is the numpy version (already installed in the virtualenv)? Add +print statement in .travis.yml. + +Dependencies: Add multiple versions of numpy (1.7.1 and 1.12.1) in install step. + +Build matrix: More explicit way of defining build matrix. + +More complicated install step: test on Ubuntu. Hint: use deactivate +and use an install script. + +# Cache +The Python 3.6 + numpy 1.7.1 should take more time than the others, +any idea why? + +cache pip dependencies by adding this to your .travis.yml file: +```yaml +cache: pip +``` +Note: another useful cache setup is `cache: ccache` for C/C++ projects) + +Does it have an impact on the build timing? + +Do the same by caching the ~/.pip/cache folder. + +Find a dummy use case to feature custom directory caching. + +Read the Caching doc and test the things they mention: +* branch use cache from master if the branch does not have a cache yet +* per-environment cache, i.e. does multiple build matrix entries share the same cache? + +Clearing the cache via the UI. + +# Docker + +Using continuumio/miniconda docker image, creating a conda +environment with the right python + numpy version. + +# Additional things to play with +- set up Travis for your own project +- allow_failures +- Use Travis docker images to run Travis locally: + http://eng.localytics.com/best-practices-and-common-mistakes-with-travis-ci/ + docker run -it -v $(pwd):/code quay.io/travisci/travis-ruby /bin/bash +- try using ccache and caching the .ccache in scikit-learn, is it + faster (if yes by how much) than compiling each time from scratch. + How big does the cache grow (i.e. ccache defaults)? How much time + does it take to restore. What is a reasonable cache size to set ? + How quickly does the cache grow ? From e9bead0ba1b06444f269c2b0bb3767354cdffa99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Wed, 31 May 2017 10:15:16 +0200 Subject: [PATCH 2/7] Add exercises.md --- exercises.md | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/exercises.md b/exercises.md index 48a3293..7fb2961 100644 --- a/exercises.md +++ b/exercises.md @@ -57,18 +57,32 @@ python: # `install` step New dependency: numpy. -Add a new function test_partition with a simple test +Add a new function test_partition with a simple test. for [numpy.partition](https://docs.scipy.org/doc/numpy/reference/generated/numpy.partition.html). What is the numpy version (already installed in the virtualenv)? Add print statement in .travis.yml. -Dependencies: Add multiple versions of numpy (1.7.1 and 1.12.1) in install step. +Add build matrix entries with different versions of numpy (1.7.1 and 1.12.1). + +Add this to your .travis.yml: +```yml +env: + - NUMPY_VERSION=1.7.1 + - NUMPY_VERSION=1.12.1 + +install: pip install numpy==$NUMPY_VERSION +``` + +See [doc](https://docs.travis-ci.com/user/customizing-the-build) for +more details about all the build steps. Build matrix: More explicit way of defining build matrix. +See [doc](https://docs.travis-ci.com/user/customizing-the-build#Build-Matrix) More complicated install step: test on Ubuntu. Hint: use deactivate -and use an install script. +and use an install script. Also look at: +[apt plugin doc](https://docs.travis-ci.com/user/installing-dependencies/#Adding-APT-Packages). # Cache The Python 3.6 + numpy 1.7.1 should take more time than the others, @@ -80,17 +94,17 @@ cache: pip ``` Note: another useful cache setup is `cache: ccache` for C/C++ projects) -Does it have an impact on the build timing? +Does it have an impact on the build timings? Do the same by caching the ~/.pip/cache folder. -Find a dummy use case to feature custom directory caching. +Find a dummy use case to feature custom directory caching, e.g. a +function that sleeps a few seconds before returning. -Read the Caching doc and test the things they mention: +Read the [caching doc](https://docs.travis-ci.com/user/caching/) and test a few things they mention: * branch use cache from master if the branch does not have a cache yet * per-environment cache, i.e. does multiple build matrix entries share the same cache? - -Clearing the cache via the UI. +* clear the cache via the web UI. # Docker @@ -102,9 +116,17 @@ environment with the right python + numpy version. - allow_failures - Use Travis docker images to run Travis locally: http://eng.localytics.com/best-practices-and-common-mistakes-with-travis-ci/ - docker run -it -v $(pwd):/code quay.io/travisci/travis-ruby /bin/bash - try using ccache and caching the .ccache in scikit-learn, is it faster (if yes by how much) than compiling each time from scratch. How big does the cache grow (i.e. ccache defaults)? How much time does it take to restore. What is a reasonable cache size to set ? How quickly does the cache grow ? + +# Useful documentation pages +Some useful documentation pages: +https://docs.travis-ci.com/user/customizing-the-build +https://docs.travis-ci.com/user/languages/python/ +https://docs.travis-ci.com/user/ci-environment/ +https://docs.travis-ci.com/user/caching/ +https://docs.travis-ci.com/user/docker/ +https://docs.travis-ci.com/user/common-build-problems/ From ac1eab02ddf87ee142813dda95d755febbb53cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Wed, 31 May 2017 11:15:30 +0200 Subject: [PATCH 3/7] Fix md formatting --- exercises.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises.md b/exercises.md index 7fb2961..2c42b3c 100644 --- a/exercises.md +++ b/exercises.md @@ -7,7 +7,7 @@ own repo: git clone https://github.com//travis-tutorial ``` -Activate your repo on Travis: https://travis-ci.org/profile//travis-tutorial +Activate your repo on Travis: https://travis-ci.org/profile/your-github-account/travis-tutorial Click on "Activate repo" # Simple .travis.yml file @@ -19,7 +19,7 @@ dist: trusty script: py.test ``` -commit + push. Look at build on https://travis-ci.org//travis-tutorial +commit + push. Look at build on https://travis-ci.org/your-github-account/travis-tutorial # Broken .travis.yml What happens if you have a broken .travis.yml? From 7e7d3eb5228cbf3642f1512df9851c48da69290a Mon Sep 17 00:00:00 2001 From: JohnDoeAkira Date: Wed, 31 May 2017 11:34:33 +0200 Subject: [PATCH 4/7] Create .travis.yml --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e2723e0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: python + +dist: trusty + +script: py.test From b10e5605e58dc12cc03249b9e61713ff7e3453f3 Mon Sep 17 00:00:00 2001 From: JohnDoeAkira Date: Wed, 31 May 2017 11:40:02 +0200 Subject: [PATCH 5/7] Update test_all.py --- test_all.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test_all.py b/test_all.py index ca4655d..19357d1 100644 --- a/test_all.py +++ b/test_all.py @@ -1,2 +1,5 @@ def test_addition(): assert 1 + 1 == 2 + +def test_false(): + assert 1 == 2 From 1f710acc70e45b359bb8d8789a2cf53784df614f Mon Sep 17 00:00:00 2001 From: JohnDoeAkira Date: Wed, 31 May 2017 11:42:31 +0200 Subject: [PATCH 6/7] Update test_all.py --- test_all.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_all.py b/test_all.py index 19357d1..b9f2e6c 100644 --- a/test_all.py +++ b/test_all.py @@ -1,5 +1,5 @@ def test_addition(): assert 1 + 1 == 2 -def test_false(): - assert 1 == 2 +def test_True(): + assert 1 == 1 From 00edbc16b3dbbfd181acfabbc1917cff6623d239 Mon Sep 17 00:00:00 2001 From: Patrick Hudelot Date: Wed, 31 May 2017 11:47:18 +0200 Subject: [PATCH 7/7] Added simple test --- test_all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_all.py b/test_all.py index b9f2e6c..0918f92 100644 --- a/test_all.py +++ b/test_all.py @@ -2,4 +2,4 @@ def test_addition(): assert 1 + 1 == 2 def test_True(): - assert 1 == 1 + assert 3 == 3