Skip to content

Instantly share code, notes, and snippets.

@fukamachi
Last active May 28, 2021 03:36
Show Gist options
  • Save fukamachi/52dce85caf477043ffeb to your computer and use it in GitHub Desktop.
Save fukamachi/52dce85caf477043ffeb to your computer and use it in GitHub Desktop.
Using Travis CI with Roswell

Using Travis CI with Roswell

Travis CI is the most prevalent cloud CI service. Though it has no Common Lisp support officially, by using Roswell, you can test your Common Lisp product with a few efforts.

WARNING: This document is based on Roswell v0.0.3.42 (not released yet) or above.

Enabling Travis CI

To use Travis CI, you must sign up and enable testing for your repository at your profile page.

Add .travis.yml

Travis CI build process can be customized with a file .travis.yml, which is located at the project root.

This is the simplest .travis.yml example which tests with the latest binary SBCL.

language: common-lisp
sudo: required

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh

script:
  - ros -s prove -e '(or (prove:run :quri-test) (uiop:quit -1))'

Testing with multiple implementations

If $LISP is set, Roswell CI installer sets up the corresponding Lisp implementation. With using env.matrix in .travis.yml, Travis creates a new build for each Lisp implementations.

language: common-lisp
sudo: required

env:
  matrix:
    - LISP=sbcl-bin
    - LISP=ccl-bin
    - LISP=abcl
    - LISP=clisp
    - LISP=ecl

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh

script:
  - ros -s prove -e '(or (prove:run :quri-test) (uiop:quit -1))'

Allow failures on some implementations

Add matrix.allow_failures directive.

language: common-lisp
sudo: required

env:
  matrix:
    - LISP=sbcl-bin
    - LISP=ccl-bin
    - LISP=abcl
    - LISP=clisp
    - LISP=ecl

matrix:
  allow_failures:
    - env: LISP=clisp

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh

script:
  - ros -s prove -e '(or (prove:run :quri-test) (uiop:quit -1))'

Using the latest version of dependencies

As Roswell CI installer adds ~/lisp to ASDF source registry, you can use the latest version of dependencies by cloning into there.

language: common-lisp
sudo: required

env:
  global:
    - PATH=~/.roswell/bin:$PATH
  matrix:
    - LISP=sbcl-bin
    - LISP=ccl-bin

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh
  - ros install prove
  # Using the latest fast-http and quri
  - git clone https://github.com/fukamachi/fast-http ~/lisp/fast-http
  - git clone https://github.com/fukamachi/quri ~/lisp/quri

script:
  - run-prove dexador-test.asd

Using a container-based infrastructure and caching directories

If sudo: false, Travis CI uses its new container-based infrastructure. We can expect faster startup unlike the older one with it.

Note that Roswell still requires sudo if $LISP is clisp or abcl because they need default-jre and clisp to be installed via APT. This .travis.yml works only for testing with other implementations.

language: common-lisp
sudo: false

env:
  global:
    - PATH=~/.roswell/bin:$PATH
    - ROSWELL_INSTALL_DIR=$HOME/.roswell
  matrix:
    - LISP=sbcl-bin
    - LISP=ccl-bin

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh

script:
  - ros -s prove -e '(or (prove:run :quri-test) (uiop:quit -1))'

Directory caching is available on the newer infrastructure by listing directories in cache.directories directive.

language: common-lisp
sudo: false

env:
  global:
    - PATH=~/.roswell/bin:$PATH
    - ROSWELL_INSTALL_DIR=$HOME/.roswell
  matrix:
    - LISP=sbcl-bin
    - LISP=ccl-bin

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh

cache:
  directories:
    - $HOME/.roswell

script:
  - ros -s prove -e '(or (prove:run :quri-test) (uiop:quit -1))'

Using Roswell script (run-prove)

Some libraries provide their Roswell scripts, like prove's run-prove command, which can be installed via ros install. To use those commands, ensure ~/.roswell/bin is in $PATH.

language: common-lisp
sudo: required

env:
  global:
    - PATH=~/.roswell/bin:$PATH
  matrix:
    - LISP=sbcl-bin
    - LISP=ccl-bin
    - LISP=abcl
    - LISP=clisp
    - LISP=ecl

matrix:
  allow_failures:
    - env: LISP=clisp

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh
  - ros install prove

script:
  - run-prove quri-test.asd

Measuring code coverage with Coveralls

Coveralls is another web service to record code coverage.

cl-coveralls is a library for measuring code coverage and posting to Coveralls. Note that it runs only if $COVERALLS is true.

language: common-lisp
sudo: required

env:
  global:
    - PATH=~/.roswell/bin:$PATH
  matrix:
    - LISP=sbcl-bin COVERALLS=true
    - LISP=ccl-bin
    - LISP=abcl
    - LISP=clisp
    - LISP=ecl

matrix:
  allow_failures:
    - env: LISP=clisp

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh

script:
  - ros -s prove -s cl-coveralls
        -e '(or (coveralls:with-coveralls (:exclude (list "t"))
                  (prove:run :quri-test))
                (uiop:quit -1))'

run-prove command has a special support for it:

language: common-lisp
sudo: required

env:
  global:
    - PATH=~/.roswell/bin:$PATH
    - COVERAGE_EXCLUDE=t/
  matrix:
    - LISP=sbcl-bin COVERALLS=true
    - LISP=ccl-bin
    - LISP=abcl
    - LISP=clisp
    - LISP=ecl

matrix:
  allow_failures:
    - env: LISP=clisp

install:
  - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh

script:
  - run-prove quri-test.asd

Using a fork of Roswell (for developers)

To choose where to get the source code of Roswell, configure these environment variables in .travis.yml.

  • ROSWELL_REPO: Roswell repository to install. The default is https://github.com/snmsts/roswell.
  • ROSWELL_BRANCH Roswell branch or tag name to install. The default is release. (ex. v0.0.3.41)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment