Skip to content

Commit

Permalink
coala-bears.cabal: Create and use
Browse files Browse the repository at this point in the history
coala has three haskell dependencies:

- ghc-mod 5.6.0.0
- hlint 1.9.26
- ShellCheck 0.4.1

Currently CI pulls these haskell packages from various sources
including Ubuntu apt-get package database, manually installing debs,
and running `cabal install foo` using two different Cabal versions.

This barely works, and those versions are not compatible.
The closest compatible combination requires bumping hlint to 1.9.27.

The dependencies have been placed into a `coala-bears.cabal` so they
can be easily fetched and installed using `cabal install`, which
will look for a combination of versions that meets all criteria.

On Travis, removing 'haskell-platform' from the apt-get package list
reduces the number of packages fetched, most of which were not
the correct version needed by the coala dependencies.
Removing this prevents conflicts, and speeds up the build.
Instead 'happy' is added as this is an executable needed to build
the dependencies.

Using cabal properly with a .cabal file also solves the
cabal caching problems.

Fixes #1380
  • Loading branch information
jayvdb committed Feb 15, 2017
1 parent 2a931b7 commit 06329a5
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 58 deletions.
11 changes: 11 additions & 0 deletions .ci/deps.cabal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -e

# cabal-install 1.22 is the minimum tested version
cabal --version

cabal update

cabal install --only-dependencies --avoid-reinstalls

# Force ghc-mod to resolve its Cabal version
~/.cabal/bin/ghc-mod modules
30 changes: 7 additions & 23 deletions .ci/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ case $CIRCLE_BUILD_IMAGE in

# The non-apt go provided by Circle CI is acceptable
deps=${deps/golang-go/}
# Add packages which are available in xenial
# The xenial hlint is >= 1.9.1
deps="$deps hlint"
# Add packages which are already in the precise image
deps="$deps g++-4.9 libxml2-utils php-codesniffer"
# gfortran on CircleCI precise is 4.6 and R irlba compiles ok,
Expand Down Expand Up @@ -82,27 +79,14 @@ fi
# Change environment for flawfinder from python to python2
sudo sed -i '1s/.*/#!\/usr\/bin\/env python2/' /usr/bin/flawfinder

# Update hlint to latest version (not available in apt)
if [[ -z "$(which hlint)" ]]; then
hlint_deb=$(ls -vr ~/.apt-cache/hlint_1.9.* 2>/dev/null | head -1)
if [[ -z "$hlint_deb" ]]; then
hlint_deb_filename=hlint_1.9.26-1_amd64.deb
# This is the same build as xenial hlint
hlint_deb_url="https://launchpad.net/ubuntu/+source/hlint/1.9.26-1/+build/8831318/+files/${hlint_deb_filename}"
hlint_deb=~/.apt-cache/$hlint_deb_filename
wget -O $hlint_deb $hlint_deb_url
fi
sudo dpkg -i $hlint_deb
fi

# cabal update to 1.22.9.0 and install ghc-mod 5.6.0
if [[ -z "$(which ghc-mod)" ]]; then
cabal update && cabal install cabal-install-1.22.9.0
cabal install ghc-mod
fi

# NPM commands
sudo rm -rf $(which alex) # Delete ghc-alex as it clashes with npm deps
ALEX=$(which alex || true)
# Delete 'alex' if it is not in a node_modules directory,
# which means it is ghc-alex.
if [[ -n "$ALEX" && "${ALEX/node_modules/}" == "${ALEX}" ]]; then
echo "Removing $ALEX"
sudo rm -rf $ALEX
fi
npm install

# R commands
Expand Down
26 changes: 0 additions & 26 deletions .ci/deps.shellcheck.sh

This file was deleted.

13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ addons:
- avsm # OPAM stable
- hvr-ghc # Haskell
packages:
- cabal-install
- cabal-install-1.24
- chktex
- clang-3.4
- cppcheck
- flawfinder
- gfortran
- ghc
- haskell-platform
- happy
- indent
- libblas-dev
- liblapack-dev
Expand All @@ -43,6 +43,8 @@ cache:
directories:
# Installed language package caches
- ~/.cabal
- ~/.ghc
- ~/.ghc-mod
- ~/R/Library
- ~/.julia
- $TRAVIS_BUILD_DIR/node_modules
Expand All @@ -51,8 +53,6 @@ cache:
# coala managed data
- ~/nltk_data
- ~/.local/share/coala-bears
# .deb cache
- ~/.apt-cache
# Installed linters
- ~/infer-linux64-v0.7.0
- ~/pmd-bin-5.4.1
Expand All @@ -66,7 +66,7 @@ env:
- USE_PPAS="marutter/rdev staticfloat/juliareleases ondrej/golang"
- R_LIB_USER=~/R/Library
- LINTR_COMMENT_BOT=false
- PATH="$PATH:$TRAVIS_BUILD_DIR/node_modules/.bin:$TRAVIS_BUILD_DIR/vendor/bin:$HOME/dart-sdk/bin:$HOME/.cabal/bin:$HOME/infer-linux64-v0.7.0/infer/bin:$HOME/pmd-bin-5.4.1/bin:$HOME/bakalint-0.4.0:$HOME/.local/tailor/tailor-latest/bin"
- PATH="/opt/cabal/1.24/bin:$PATH:$TRAVIS_BUILD_DIR/node_modules/.bin:$TRAVIS_BUILD_DIR/vendor/bin:$HOME/dart-sdk/bin:$HOME/.cabal/bin:$HOME/infer-linux64-v0.7.0/infer/bin:$HOME/pmd-bin-5.4.1/bin:$HOME/bakalint-0.4.0:$HOME/.local/tailor/tailor-latest/bin"

before_install:
- export TRAVIS_PYTHON_VERSION_MAJOR=${TRAVIS_PYTHON_VERSION%.[0-9]}
Expand All @@ -80,9 +80,8 @@ before_install:
- nvm use 4
# Remove Ruby directive from Gemfile as this image has 2.2.5
- sed -i '/^ruby/d' Gemfile
- mkdir -p ~/.apt-cache
- if [[ "$UNSUPPORTED" != true ]]; then bash .ci/deps.sh; fi
- if [[ "$UNSUPPORTED" != true ]]; then bash .ci/deps.shellcheck.sh; fi
- if [[ "$UNSUPPORTED" != true ]]; then bash .ci/deps.cabal.sh; fi
# https://github.com/coala/coala/issues/3183
- cp requirements.txt requirements.orig
- cat test-requirements.txt docs-requirements.txt bear-requirements.txt >> requirements.txt
Expand Down
5 changes: 3 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
dependencies:
cache_directories:
- ~/.apt-cache
- ~/.pyenv/versions/3.4.3
- ~/.pyenv/versions/3.5.1
- ~/coala-bears/node_modules
Expand All @@ -9,6 +8,8 @@ dependencies:
- ~/.RLibrary
- ~/dart-sdk/bin
- ~/.cabal
- ~/.ghc
- ~/.ghc-mod
- ~/infer-linux64-v0.7.0
- ~/nltk_data
- ~/pmd-bin-5.4.1
Expand All @@ -32,7 +33,7 @@ dependencies:
- mkdir -p ~/.RLibrary
- nvm alias default node
override:
- bash .ci/deps.shellcheck.sh
- bash .ci/deps.cabal.sh
- bash .ci/deps.sh:
timeout: 900 # Allow 15 mins before timing out due to "no output"

Expand Down
13 changes: 13 additions & 0 deletions coala-bears.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Name: coala-bears
Version: 0.10
cabal-version: >= 1.2
build-type: Simple

-- safe 0.3.9 is needed to coexist with Cabal 1.16
-- safe 0.3.10 requires Cabal 1.18

-- Note trusty apt package "haskell-platform" includes mtl-2.1.2
-- which is incompatible with ShellCheck 0.4.1 which needs mtl-2.2.1

library
build-depends: base, Cabal>=1.16, safe==0.3.9, ghc-mod==5.6.0.0, hlint==1.9.27, ShellCheck==0.4.1

0 comments on commit 06329a5

Please sign in to comment.