Skip to content

Commit

Permalink
Switch to stack for CI, resolves #1974 (#2099)
Browse files Browse the repository at this point in the history
* Switch to stack for CI, resolves #1974

* Remove the stack-nightly.yaml, since it always needs updating.
  Instead, we pass --resolver=nightly in one of the build jobs to ensure
  we always have the latest nightly. As an added bonus we no longer have
  to set the STACK_YAML environment variable on Windows, because
  stack.yaml is no longer a symlink.
* Remove use of cabal-install, which drastically simplifies the CI
  scripts :)
* Use the 'compiler' key in the build matrix as a hack to ensure each
  build job gets a separate cache.
* Add OSX tests.
* Add haddock tests, on a separate build job (for speed).
* Use separate build jobs for sdist tests (for speed).
* Fix binary bundle uploading on Travis
* Add binary bundle uploading for OSX.

* Update appveyor CI

* No longer need to set STACK_YAML on AppVeyor
* We should not attempt to run 'strip' on Windows executables
* Fix path to bundle creation script
  • Loading branch information
hdgarrood authored and paf31 committed May 8, 2016
1 parent 73746d9 commit 10f76a7
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 130 deletions.
125 changes: 66 additions & 59 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,80 @@
language: c
dist: trusty
dist: trusty # because of perf issues
sudo: required
matrix:
include:
- env: GHCVER=7.10.3 CABALVER=1.22 STACKAGE=lts-5.4 RUNSDISTTESTS=YES
compiler: ": #GHC 7.10.3 lts-5.4"
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
- env: GHCVER=7.10.3 CABALVER=1.22 STACKAGE=nightly-2016-02-25
compiler: ": #GHC 7.10.3 nightly-2016-02-25"
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
- env: GHCVER=7.10.3 CABALVER=1.22 DEPLOY=yes
compiler: ": #GHC 7.10.3"
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
before_install:
- unset CC
- export PATH="/opt/ghc/$GHCVER/bin:$PATH"
- export PATH="/opt/cabal/$CABALVER/bin:$PATH"
- export PATH="$HOME/.cabal/bin:$PATH"
- export PATH="/opt/happy/1.19.5/bin:/$PATH"
- export PATH="/opt/alex/3.1.4/bin:/$PATH"
- export PATH="$HOME/build/purescript/purescript/dist/build/psc:/$PATH"
- export PATH="$HOME/build/purescript/purescript/dist/build/psc-ide-server:/$PATH"
- export PATH="$HOME/build/purescript/purescript/dist/build/psc-ide-client:/$PATH"
# The 'compiler' key is a hack to get Travis to use different caches for
# each job in a build, in order to avoid the separate jobs stomping on each
# other's caches. See https://github.com/travis-ci/travis-ci/issues/4393
#
# We use trusty boxes because they seem to be a bit faster.
- compiler: cc-linux-lts-normal
os: linux
dist: trusty
sudo: required
env: BUILD_TYPE=normal COVERAGE=true DEPLOY=true

- compiler: cc-linux-nightly-normal
os: linux
dist: trusty
sudo: required
env: BUILD_TYPE=normal STACKAGE_NIGHTLY=true
allow_failures: true

- compiler: cc-linux-lts-sdist
os: linux
dist: trusty
sudo: required
env: BUILD_TYPE=sdist

- compiler: cc-linux-lts-haddock
os: linux
dist: trusty
sudo: required
env: BUILD_TYPE=haddock

- compiler: cc-osx-lts-normal
os: osx
env: BUILD_TYPE=normal DEPLOY=true

- compiler: cc-osx-lts-sdist
os: osx
env: BUILD_TYPE=sdist
addons:
apt:
packages:
- libgmp-dev
cache:
directories:
- $HOME/.local/bin
- $HOME/.stack
install:
- cabal --version
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
- travis_retry cabal update
# Run sequentially
# Travis container infrastructure seems to expose all host CPUs (16?), thus
# cabal and ghc tries to use them all. Which is bad idea on a shared box.
# See also: https://ghc.haskell.org/trac/ghc/ticket/9221
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
# Cache sandboxes in ~/cabal-sandboxes
# Move right sandbox to .cabal-sandbox if exists
- if [ -d ~/cabal-sandboxes/$GHCVER-${STACKAGE:-none} ]; then
mv ~/cabal-sandboxes/$GHCVER-${STACKAGE:-none} .cabal-sandbox;
fi
- mkdir -p .cabal-sandbox
- cabal sandbox init --sandbox .cabal-sandbox
# Download stackage cabal.config. Filter this package and 'extra deps'
- if [ -n "$STACKAGE" ]; then curl https://www.stackage.org/$STACKAGE/cabal.config | egrep -v 'purescript|language-javascript|bower-json' > cabal.config; fi
- cabal install --only-dependencies --enable-tests
- cabal install hpc-coveralls
# Snapshot state of the sandbox now, so we don't need to make new one for test install
- rm -rf ~/cabal-sandboxes/$GHCVER-${STACKAGE:-none}
- cp -r .cabal-sandbox ~/cabal-sandboxes/$GHCVER-${STACKAGE:-none}
# Install bower globally (for psc-docs/psc-publish tests)
- npm install -g bower
- | # Install stack.
if test ! -f "$HOME/.local/bin/stack"
then
URL="https://www.stackage.org/stack/$TRAVIS_OS_NAME-x86_64"
curl --location "$URL" > stack.tar.gz
gunzip stack.tar.gz
tar -x -f stack.tar --strip-components 1
mkdir -p "$HOME/.local/bin"
mv stack "$HOME/.local/bin/"
fi
- npm install -g bower # for psc-docs / psc-publish tests
# Fix the CC environment variable, because Travis changes it
- export CC=gcc
- export OS_NAME=$(./travis/convert-os-name.sh)
script:
- ./travis/configure.sh
- cabal build --ghc-options="-Werror"
- cabal test
- ./travis/test-install.sh
after_script:
- ./travis/after.sh
notifications:
email: true
before_deploy: "./bundle/build.sh linux64"
- travis/build.sh
before_deploy:
- ./bundle/build.sh $OS_NAME
deploy:
provider: releases
api_key: $RELEASE_KEY
file:
- bundle/linux64.tar.gz
- bundle/linux64.sha
- bundle/$OS_NAME.tar.gz
- bundle/$OS_NAME.sha
skip_cleanup: true
on:
all_branches: true
tags: true
condition: "$DEPLOY = yes"
cache:
directories:
- ~/cabal-sandboxes
condition: "$DEPLOY = true"
6 changes: 1 addition & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ environment:
STACK_ROOT: c:\s
# Appveyor does not seem to be able to cope with the symbolic link
# stack.yaml, so this is a workaround.
STACK_YAML: stack-lts-5.yaml
RELEASE_USER: purescript
RELEASE_REPO: purescript
cache:
Expand All @@ -31,9 +30,6 @@ build_script:
test_script:
- stack -j1 --no-terminal test --pedantic
on_success:
# this seems to be necessary; if omitted, the bash script fails to find the
# tool 'strip'.
- copy C:\MinGW\bin\strip.exe C:\tools\strip.exe
- ps: |
function UploadFile
{
Expand All @@ -42,7 +38,7 @@ on_success:
if ($env:APPVEYOR_REPO_TAG_NAME)
{
bash ./bundle/build-stack.sh win64
bash ./bundle/build.sh win64
(New-Object Net.WebClient).DownloadFile('https://github.com/aktau/github-release/releases/download/v0.6.2/windows-amd64-github-release.zip', 'c:\tools\github-release.zip')
pushd c:\tools
Expand Down
6 changes: 4 additions & 2 deletions bundle/build-stack.sh → bundle/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ mkdir -p bundle/build/purescript
for BIN in psc psci psc-docs psc-publish psc-bundle psc-ide-server psc-ide-client
do
FULL_BIN="$LOCAL_INSTALL_ROOT/bin/${BIN}${BIN_EXT}"
strip "$FULL_BIN" || true # not the end of the world if this fails, and
# AppVeyor can't seem to handle it for some reason
if [ "$OS" != "win64" ]
then
strip "$FULL_BIN"
fi
cp "$FULL_BIN" bundle/build/purescript
done

Expand Down
2 changes: 0 additions & 2 deletions purescript.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ extra-source-files: examples/passing/*.purs
, tests/support/pscide/src/*.js
, tests/support/pscide/src/*.fail
, stack.yaml
, stack-lts-5.yaml
, stack-nightly.yaml
, README.md
, INSTALL.md
, CONTRIBUTORS.md
Expand Down
7 changes: 0 additions & 7 deletions stack-lts-5.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions stack-nightly.yaml

This file was deleted.

1 change: 0 additions & 1 deletion stack.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resolver: lts-5.4
packages:
- '.'
extra-deps:
- bower-json-0.8.0
- language-javascript-0.6.0.4
flags: {}
13 changes: 0 additions & 13 deletions travis/after.sh

This file was deleted.

59 changes: 59 additions & 0 deletions travis/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
set -e

STACK="stack --no-terminal --jobs=1"
$STACK setup

# Set up configuration
STACK_EXTRA_FLAGS=""
if [ -z "$TRAVIS_TAG" ]
then
# On non-release builds, disable optimizations.
STACK_EXTRA_FLAGS="--fast"
fi

if [ "$STACKAGE_NIGHTLY" = "true" ]
then
STACK_EXTRA_FLAGS="$STACK_EXTRA_FLAGS --resolver=nightly"
fi

if [ "$COVERAGE" = "true" ]
then
STACK_EXTRA_FLAGS="$STACK_EXTRA_FLAGS --coverage"
fi

echo "STACK_EXTRA_FLAGS=\"$STACK_EXTRA_FLAGS\""
BUILD_COMMAND="$STACK build --pedantic --test $STACK_EXTRA_FLAGS"

if [ "$BUILD_TYPE" = "normal" ]
then
echo ">>> Building & testing..."
echo "> $BUILD_COMMAND"
$BUILD_COMMAND

elif [ "$BUILD_TYPE" = "sdist" ]
then
echo ">>> Testing the source distribution..."
$STACK sdist
mkdir sdist-test
tar -xzf $(stack path --dist-dir)/purescript-*.tar.gz -C sdist-test --strip-components=1
pushd sdist-test
echo "> $BUILD_COMMAND"
$BUILD_COMMAND
popd

elif [ "$BUILD_TYPE" = "haddock" ]
then
echo ">>> Checking haddock documentation..."
$STACK haddock
else
echo "Unrecognised BUILD_TYPE: $BUILD_TYPE"
exit 1
fi

if [ "$COVERAGE" = "true" ]
then
echo ">>> Uploading test coverage report..."
which shc || $STACK install stack-hpc-coveralls
shc purescript tests || echo "Failed to upload coverage"
fi
17 changes: 0 additions & 17 deletions travis/configure.sh

This file was deleted.

14 changes: 14 additions & 0 deletions travis/convert-os-name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# This script converts the Travis OS name into the format used for PureScript
# binary bundles.
set -e

case "$TRAVIS_OS_NAME" in
"linux")
echo linux64;;
"osx")
echo macos;;
*)
echo "Unknown TRAVIS_OS_NAME: $TRAVIS_OS_NAME";
exit 1;;
esac
18 changes: 0 additions & 18 deletions travis/test-install.sh

This file was deleted.

0 comments on commit 10f76a7

Please sign in to comment.