From 359f6afb1d347a0a4769c820bcac9e642059c6fe Mon Sep 17 00:00:00 2001 From: Harry Garrood Date: Sat, 7 May 2016 19:32:43 +0100 Subject: [PATCH 1/2] 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. --- .travis.yml | 125 +++++++++++++++------------- bundle/{build-stack.sh => build.sh} | 0 purescript.cabal | 2 - stack-lts-5.yaml | 7 -- stack-nightly.yaml | 6 -- stack.yaml | 8 +- travis/after.sh | 13 --- travis/build.sh | 59 +++++++++++++ travis/configure.sh | 17 ---- travis/convert-os-name.sh | 14 ++++ travis/test-install.sh | 18 ---- 11 files changed, 146 insertions(+), 123 deletions(-) rename bundle/{build-stack.sh => build.sh} (100%) delete mode 100644 stack-lts-5.yaml delete mode 100644 stack-nightly.yaml mode change 120000 => 100644 stack.yaml delete mode 100755 travis/after.sh create mode 100755 travis/build.sh delete mode 100755 travis/configure.sh create mode 100755 travis/convert-os-name.sh delete mode 100755 travis/test-install.sh diff --git a/.travis.yml b/.travis.yml index 2e6b496922..ac5f023a42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/bundle/build-stack.sh b/bundle/build.sh similarity index 100% rename from bundle/build-stack.sh rename to bundle/build.sh diff --git a/purescript.cabal b/purescript.cabal index 592f30dff4..f9ba55e378 100644 --- a/purescript.cabal +++ b/purescript.cabal @@ -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 diff --git a/stack-lts-5.yaml b/stack-lts-5.yaml deleted file mode 100644 index 9f87d0ed7c..0000000000 --- a/stack-lts-5.yaml +++ /dev/null @@ -1,7 +0,0 @@ -resolver: lts-5.4 -packages: -- '.' -extra-deps: -- bower-json-0.8.0 -- language-javascript-0.6.0.4 -flags: {} diff --git a/stack-nightly.yaml b/stack-nightly.yaml deleted file mode 100644 index 22c2f0d0e0..0000000000 --- a/stack-nightly.yaml +++ /dev/null @@ -1,6 +0,0 @@ -flags: {} -packages: -- '.' -extra-deps: -- language-javascript-0.6.0.4 -resolver: nightly-2016-03-17 diff --git a/stack.yaml b/stack.yaml deleted file mode 120000 index 0db6065aea..0000000000 --- a/stack.yaml +++ /dev/null @@ -1 +0,0 @@ -stack-lts-5.yaml \ No newline at end of file diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000000..9f87d0ed7c --- /dev/null +++ b/stack.yaml @@ -0,0 +1,7 @@ +resolver: lts-5.4 +packages: +- '.' +extra-deps: +- bower-json-0.8.0 +- language-javascript-0.6.0.4 +flags: {} diff --git a/travis/after.sh b/travis/after.sh deleted file mode 100755 index 58511bd67f..0000000000 --- a/travis/after.sh +++ /dev/null @@ -1,13 +0,0 @@ -set -e - -pushd core-tests/ -./test-everything.sh -popd - -if ! git describe --tags --exact-match >/dev/null 2>/dev/null && [ "$COVERAGE" = "true" ] -then - ./.cabal-sandbox/bin/hpc-coveralls \ - --exclude-dir=dist/build/autogen \ - --exclude-dir=tests \ - tests -fi diff --git a/travis/build.sh b/travis/build.sh new file mode 100755 index 0000000000..ea54ba3fcd --- /dev/null +++ b/travis/build.sh @@ -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 diff --git a/travis/configure.sh b/travis/configure.sh deleted file mode 100755 index d5ce1f751b..0000000000 --- a/travis/configure.sh +++ /dev/null @@ -1,17 +0,0 @@ -set -e - -configure_flags="--enable-tests -v2" - -if ! git describe --tags --exact-match >/dev/null 2>/dev/null -then - # Not a release build - configure_flags="--disable-optimization $configure_flags" -fi - -if [ "$COVERAGE" = "true" ] -then - configure_flags="--enable-coverage $configure_flags" -fi - -echo "> cabal configure $configure_flags" -cabal configure $configure_flags diff --git a/travis/convert-os-name.sh b/travis/convert-os-name.sh new file mode 100755 index 0000000000..c3abbf2970 --- /dev/null +++ b/travis/convert-os-name.sh @@ -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 diff --git a/travis/test-install.sh b/travis/test-install.sh deleted file mode 100755 index 2206e248f9..0000000000 --- a/travis/test-install.sh +++ /dev/null @@ -1,18 +0,0 @@ -set -e - -# Check that a source distribution can be successfully generated, and that -# the generated source distribution can be installed and tested -cabal sdist -if SRC_TGZ="$PWD/dist/$(cabal info . | awk '{print $2;exit}').tar.gz" -then - if [ "$RUNSDISTTESTS" = "YES" ]; then - mkdir test-install - cd test-install - tar --strip-components=1 -xzf $SRC_TGZ - cabal sandbox init --sandbox ../.cabal-sandbox - cabal install --enable-tests --force-reinstalls - cabal test - else - cabal install "$SRC_TGZ" - fi -fi From 4e30241e399547d693e4a66f86eda05f5d250508 Mon Sep 17 00:00:00 2001 From: Harry Garrood Date: Sun, 8 May 2016 18:59:20 +0100 Subject: [PATCH 2/2] 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 --- appveyor.yml | 6 +----- bundle/build.sh | 6 ++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index efbc4d3ce7..706a8d7b24 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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: @@ -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 { @@ -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 diff --git a/bundle/build.sh b/bundle/build.sh index ee13b9542f..2acfdf417a 100755 --- a/bundle/build.sh +++ b/bundle/build.sh @@ -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