Skip to content

Commit

Permalink
[clojure-emacs#2144] create a docker image to mimic the travis enviro…
Browse files Browse the repository at this point in the history
…nment
  • Loading branch information
gonewest818 committed Dec 20, 2017
1 parent 74889ac commit e3e43b2
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 12 deletions.
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM travisci/ci-garnet:packer-1490989530

RUN apt-get update -y \
&& apt-get install -y \
autogen \
ca-certificates \
curl \
gcc \
git \
libgmp-dev \
m4 \
make \
pkg-config \
python \
ruby \
xz-utils

USER travis
ENV HOME=/home/travis
ENV PATH="${HOME}/local/evm/bin:${HOME}/local/cask/bin:${HOME}/local/bin:${PATH}"

ADD travis-ci/ ${HOME}/cider-setup/travis-ci/

RUN ${HOME}/cider-setup/travis-ci/install-gnutls.sh
RUN ${HOME}/cider-setup/travis-ci/install-evm.sh
RUN ${HOME}/cider-setup/travis-ci/install-cask.sh

RUN evm install emacs-25.3-travis
RUN evm install emacs-26-pretest-travis
RUN evm install emacs-git-snapshot-travis

WORKDIR /home/travis/cider
CMD /bin/bash
66 changes: 66 additions & 0 deletions doc/hacking_on_cider.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,72 @@ You can also check for the presence of byte-compilation warnings in batch mode:
$ make test-bytecomp
```

#### Running the tests in Travis CI

If you prefer to see the full Travis test suite run successfully, the easiest
way to achieve that is to create your own personal account on
https://travis-ci.org. View your profile details on the Travis site, and toggle
the switch to enable builds on your fork of the cider project.

Subsequent pushes to your fork will generate a Travis build you can monitor for
success or failure.

#### Simulating the Travis tests locally in Docker

If you prefer not to wait for Travis all the time, or if you need to debug
something that fails in Travis but does not fail for you on your own machine,
then you can also run the Travis tests manually in Docker.

You will need to run some scripts to build and launch the Docker image.

To build:
```
$ docker/build.sh
```

The build script uses a base image provided by the engineers at Travis. Note: the
Travis docker image is currently more than 8GB, so be prepared with a good
internet connection and time to spare.

The resulting docker image is tagged simply `cider-travis`. You can run this
image by hand, but there is a convenience script available:
```
$ docker/run.sh
```

This script launches a docker container and bind-mounts your cider project
directory as `/home/travis/cider` such that you can instantly see any code
changes reflected inside the docker environment.

For instance, you can run tests on emacs 25.3
```
travis@c3936c77aae0:~/cider$ evm use emacs-25.3-travis
travis@c3936c77aae0:~/cider$ make elpaclean test
```

and then switch to emacs 26 and test again

```
travis@c3936c77aae0:~/cider$ evm use emacs-26-pretest-travis
travis@c3936c77aae0:~/cider$ make elpaclean test
```

You can test byte compilation too
```
travis@c3936c77aae0:~/cider$ make elpaclean test-bytecomp
```

When you are done working in docker, just `exit` the bash prompt, and the docker
container will also exit. Note that `docker/run.sh` runs the container with
`--rm`, meaning any changes to the docker container are discarded when the
container exits.

So for example, by default, the docker image pre-installs only the most recent
releases of emacs 25, emacs 26, and a recent snapshot of the emacs git
repository. The `evm` tool is available should you need to install some other
specific build. However additional versions of emacs will be discarded when
you exit the docker container.

## Hacking on cider-nrepl

### Obtaining the code
Expand Down
4 changes: 4 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker build -t cider-travis .

4 changes: 4 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker run -it --rm -v `pwd`:/home/travis/cider cider-travis bash

12 changes: 7 additions & 5 deletions travis-ci/install-cask.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash
#!/bin/bash -x

# Install cask for Travis CI
# or if already installed, then check for updates

set -x

WORKDIR=${HOME}/local
CASKDIR=$WORKDIR/cask
SCRIPTDIR=`dirname $(readlink -f $0)`

. travis-ci/retry.sh
. $SCRIPTDIR/retry.sh

cask_upgrade_cask_or_reset() {
cask upgrade-cask || { rm -rf $HOME/.emacs.d/.cask && false; }
Expand All @@ -30,4 +29,7 @@ fi
# Install dependencies for cider as descriped in ./Cask
# Effect is identical to "make elpa", but here we can retry
# in the event of network failures.
travis_retry cask_install_or_reset && touch elpa-emacs
if [ -f Cask ]
then
travis_retry cask_install_or_reset && touch elpa-emacs
fi
7 changes: 3 additions & 4 deletions travis-ci/install-evm.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash
#!/bin/bash -x

# Install evm for Travis CI
# or if already installed, then check for updates

set -x

WORKDIR=${HOME}/local
EVMDIR=$WORKDIR/evm
SCRIPTDIR=`dirname $(readlink -f $0)`

. travis-ci/retry.sh
. $SCRIPTDIR/retry.sh

if [ -d $EVMDIR ]
then
Expand Down
10 changes: 7 additions & 3 deletions travis-ci/install-gnutls.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
#!/bin/bash -x

# Setup a newer gnutls-cli on Travis CI
# We need this as long as the Travis workers are Ubuntu 14.04
# and the TLS cert chain on elpa.gnu.org is out-of-order

set -x

# adjust these versions as needed
export NETTLE_VERSION=3.4
export GNUTLS_VERSION=3.5.16
Expand All @@ -14,6 +12,12 @@ export WORKDIR=${HOME}/local/
export LD_LIBRARY_PATH=${WORKDIR}/lib/
export PKG_CONFIG_PATH=${WORKDIR}/lib/pkgconfig/

# make sure workdir exists
if [ ! -d ${WORKDIR} ]
then
mkdir $WORKDIR
fi

# exit if the cache is valid and up-to-date
if [ -f ${WORKDIR}/bin/gnutls-cli ] && \
[ -f ${WORKDIR}/nettle-${NETTLE_VERSION}.tar.gz ] && \
Expand Down

0 comments on commit e3e43b2

Please sign in to comment.