From fb5ae6f7b8cd08c6f8b437972efef1a1c552e170 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Fri, 9 Jun 2017 15:34:47 +0200 Subject: [PATCH] Experiment with Travis's build stages. See #4556. --- .travis.yml | 24 ++++++++++++++++++------ travis-precache.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) create mode 100755 travis-precache.sh diff --git a/.travis.yml b/.travis.yml index 1b77cec836e..110123896eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -114,13 +114,25 @@ install: # We intentionally do not install anything before trying to build Cabal because # it should build with each supported GHC version out-of-the-box. -# Here starts the actual work to be performed for the package under test; any -# command which exits with a non-zero exit code causes the build to fail. Using -# ./dist/setup/setup here instead of cabal-install to avoid breakage when the -# build config format changed. +# All jobs except 'meta' have two stages; the first stage is used to +# warm up the cache. This is mostly useful when a new compiler gets +# added to the build matrix: work done installing dependencies is not +# wasted when we exceed the time limit for jobs. +jobs: + include: + - stage: prepare cache + script: if [ "x$SCRIPT" != "xmeta" ]; then ./travis-precache.sh; fi + after_success: skip + - stage: test + +# Here starts the actual work to be performed for the package under +# test; any command which exits with a non-zero exit code causes the +# build to fail. Using ./dist/setup/setup here instead of +# cabal-install to avoid breakage when the build config format +# changed. script: - - rm -rf dist-newstyle - - ./travis-${SCRIPT}.sh -j2 + - rm -rf dist-newstyle + - ./travis-${SCRIPT}.sh -j2 cache: directories: diff --git a/travis-precache.sh b/travis-precache.sh new file mode 100755 index 00000000000..6272d99d448 --- /dev/null +++ b/travis-precache.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +. ./travis-common.sh + +# --------------------------------------------------------------------- +# Update the Cabal index +# --------------------------------------------------------------------- + +timed cabal update + +# --------------------------------------------------------------------- +# Setup our local project +# --------------------------------------------------------------------- + +cp cabal.project.travis cabal.project.local + +# --------------------------------------------------------------------- +# Install executables if necessary +# --------------------------------------------------------------------- + +if ! command -v happy; then + timed cabal install $jobs happy +fi + +# --------------------------------------------------------------------- +# Warm up the cache +# --------------------------------------------------------------------- + +# TODO: Don't build Cabal and hackage-security here, they'll be +# rebuilt anyway. +timed cabal new-build --only-dependencies cabal-install cabal-tests