File: Travis.rst

package info (click to toggle)
emscripten 2.0.12~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 108,440 kB
  • sloc: ansic: 510,324; cpp: 384,763; javascript: 84,341; python: 51,362; sh: 50,019; pascal: 4,159; makefile: 3,409; asm: 2,150; lisp: 1,869; ruby: 488; cs: 142
file content (74 lines) | stat: -rw-r--r-- 3,080 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.. _Travis:

==============================
Building projects on Travis CI
==============================

`Travis CI <https://travis-ci.org/>`_ is a popular continuous integration service which offers free plans for open source projects. Thanks to a `Docker image by trzeci <https://hub.docker.com/r/trzeci/emscripten/>`_ installing emscripten in Travis CI is essentially a one line task.

A sample .travis.yml
====================

.. code-block:: yaml

    notifications:
      email: false

    language: node_js
    node_js:
      - node

    sudo: required

    services:
      - docker

    before_install:
      - docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-incoming-64bit bash

    script:
      - docker exec -it emscripten make helloworld.js
      - make test

Let's break it down:

.. code-block:: yaml

    notifications:
      email: false

    language: node_js
    node_js:
      - node

    sudo: required

    services:
      - docker

These lines set up the basic settings for the Travis container. Most people do not want email notifications, but feel free to leave out those lines if you do.

``language: node_js`` and ``node_js: - node`` tell Travis we are a Node.js project, and that we want the latest stable Node release.

``sudo: required`` and ``services: - docker`` are required to enable Docker in the Travis container.

.. code-block:: yaml

    before_install:
      - docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-incoming-64bit bash

In the before_install stage we download the Docker image, create a container with that image, and then give it the name ``emscripten``. The ``-dit`` options tell Docker that we want the container to run *bash* in the background.

This Docker image contains everything emscripten needs to run, as well as several additional build tools such as *make* and *cmake*. If you do not need them you can use the `emscripten-slim image <https://hub.docker.com/r/trzeci/emscripten-slim/>`_ instead, which excludes them and will be downloaded and installed slightly quicker. The emscripten versions available are listed at `the Docker Hub <https://hub.docker.com/r/trzeci/emscripten/tags/>`_.

.. code-block:: yaml

    script:
      - docker exec -it emscripten make helloworld.js
      - make test

In the script stage we can now run the commands we want, inside the Docker container we created earlier. In this sample we are using *make*, but you can call *emcc* directly if you prefer.

The Docker container is set up to use the same directories as Travis, so the second line uses the same *Makefile*, and can also depend on the output of the Docker command. If your test suite needs a later version of Node than what is installed by *emsdk* (Node v4), you will need to run the tests outside of Docker as a normal Travis command.

For an example of this setup in practice, see `the Travis page for emglken <https://travis-ci.org/curiousdannii/emglken>`_, which is also set up to use `Greenkeeper <https://greenkeeper.io/>`_ for automatic testing of dependency updates.