-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add im6 docker support for tests and update travis config
- Loading branch information
Showing
3 changed files
with
73 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,33 @@ | ||
language: go | ||
sudo: required | ||
|
||
go: | ||
- 1.9.x | ||
|
||
cache: | ||
directories: | ||
- "$HOME/opt" | ||
|
||
language: generic | ||
|
||
services: | ||
- docker | ||
|
||
env: | ||
global: | ||
- GOARCH=amd64 | ||
- IMAGEMAGICK_VERSION=$IMAGEMAGICK6_VERSION # Set externally by Travis | ||
|
||
- DOCKER_IMAGE=gographics/imagick.v2:im-$IMAGEMAGICK6_VERSION | ||
- CACHE_DIR=$HOME/.cache | ||
- DOCKER_CACHE_DIR=$CACHE_DIR/docker | ||
|
||
cache: | ||
directories: | ||
- $DOCKER_CACHE_DIR | ||
|
||
before_install: | ||
# Update PATH so that travis can find newer imagemagick | ||
- export PATH=$HOME/opt/bin:$PATH | ||
|
||
# Build ImageMagick from source | ||
- convert -version | grep $IMAGEMAGICK_VERSION || { | ||
export CORES=$(nproc) && | ||
echo "Using $CORES cores for compiling..." && | ||
cd /tmp && | ||
sudo apt-get install build-essential -y && | ||
sudo apt-get build-dep imagemagick -y && | ||
wget "https://github.com/ImageMagick/ImageMagick6/archive/${IMAGEMAGICK_VERSION}.tar.gz" && | ||
tar -xvf "${IMAGEMAGICK_VERSION}.tar.gz" && | ||
cd "ImageMagick6-${IMAGEMAGICK_VERSION}" && | ||
./configure --prefix=$HOME/opt --without-magick-plus-plus --without-perl --disable-openmp --with-gvc=no && | ||
make -j$CORES && sudo make install && sudo ldconfig && | ||
$HOME/opt/bin/convert -version | grep $IMAGEMAGICK_VERSION && | ||
cd $TRAVIS_BUILD_DIR; } | ||
|
||
# Update library paths for programs | ||
- export LD_FLAGS=-L$HOME/opt/lib | ||
- export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:$HOME/opt/lib | ||
- export CPATH=$CPATH:$HOME/opt/include | ||
- export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:$HOME/opt/lib | ||
- export PKG_CONFIG_PATH=$HOME/opt/lib/pkgconfig | ||
|
||
# Set the import path for the particular branch of imagick bindings | ||
- export IMAGICK_IMPORT_PATH=$(grep gopkg.in/gographics/imagick.v imagick/imagick.go | cut -d\" -f2) | ||
# load cached Docker images | ||
- if [[ -d $DOCKER_CACHE_DIR ]]; then ls $DOCKER_CACHE_DIR/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi | ||
|
||
install: | ||
- pkg-config --cflags --libs MagickWand | ||
- go get $IMAGICK_IMPORT_PATH | ||
- docker build -f Dockerfile --cache-from $DOCKER_IMAGE -t $DOCKER_IMAGE . | ||
|
||
script: | ||
- docker run -it --rm -v $PWD:/go/projects/imagick $DOCKER_IMAGE | ||
|
||
script: | ||
- go test -v $IMAGICK_IMPORT_PATH | ||
before_cache: | ||
# save tagged Docker images | ||
# https://github.com/travis-ci/travis-ci/issues/5358#issuecomment-248915326 | ||
- > | ||
mkdir -p $DOCKER_CACHE_DIR && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}' | ||
| xargs -n 2 -t sh -c 'test -e $DOCKER_CACHE_DIR/$1.tar.gz || docker save $0 | gzip -2 > $DOCKER_CACHE_DIR/$1.tar.gz' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM golang:1.13 | ||
|
||
# Ignore APT warnings about not having a TTY | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
wget build-essential \ | ||
pkg-config \ | ||
--no-install-recommends \ | ||
&& apt-get -q -y install \ | ||
libjpeg-dev \ | ||
libpng-dev \ | ||
libtiff-dev \ | ||
libgif-dev \ | ||
libx11-dev \ | ||
fontconfig fontconfig-config libfontconfig1-dev \ | ||
ghostscript gsfonts gsfonts-x11 \ | ||
libfreetype6-dev \ | ||
--no-install-recommends \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ARG IMAGEMAGICK_PROJECT=ImageMagick6 | ||
ARG IMAGEMAGICK_VERSION=6.9.10-11 | ||
ENV IMAGEMAGICK_VERSION=$IMAGEMAGICK_VERSION | ||
|
||
RUN cd && \ | ||
wget https://github.com/ImageMagick/${IMAGEMAGICK_PROJECT}/archive/${IMAGEMAGICK_VERSION}.tar.gz && \ | ||
tar xvzf ${IMAGEMAGICK_VERSION}.tar.gz && \ | ||
cd ImageMagick* && \ | ||
./configure \ | ||
--without-magick-plus-plus \ | ||
--without-perl \ | ||
--disable-openmp \ | ||
--with-gvc=no \ | ||
--with-fontconfig=yes \ | ||
--with-freetype=yes \ | ||
--with-gslib \ | ||
--disable-docs && \ | ||
make -j$(nproc) && make install && \ | ||
ldconfig /usr/local/lib | ||
|
||
WORKDIR /go/projects/imagick | ||
|
||
CMD go test -v ./imagick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module gopkg.in/gographics/imagick.v2 | ||
|
||
go 1.13 |