[commit: ghc] master: Factor out builds into steps. Address ghc/ghc#83 comments. (ed18f47)

git at git.haskell.org git at git.haskell.org
Wed Nov 8 06:19:48 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/ed18f47f931361a9adbb109085c6feb432ec41aa/ghc

>---------------------------------------------------------------

commit ed18f47f931361a9adbb109085c6feb432ec41aa
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date:   Tue Nov 7 10:52:38 2017 +0000

    Factor out builds into steps. Address ghc/ghc#83 comments.
    
    This should greatly improve log output.


>---------------------------------------------------------------

ed18f47f931361a9adbb109085c6feb432ec41aa
 .circleci/build.sh          | 59 -----------------------------
 .circleci/config.yml        | 91 +++++++++++++++++++++++++++++++++------------
 .circleci/prepare-system.sh | 24 ++++++++++--
 3 files changed, 88 insertions(+), 86 deletions(-)

diff --git a/.circleci/build.sh b/.circleci/build.sh
deleted file mode 100755
index 74d98fa..0000000
--- a/.circleci/build.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env bash
-# vim: sw=2 et
-
-set -euo pipefail
-
-fail() {
-  echo "ERROR: $*" >&2
-  exit 1
-}
-
-echo 'BUILD_SPHINX_HTML = NO' > mk/validate.mk
-echo 'BUILD_SPHINX_PDF = NO' >> mk/validate.mk
-
-cat > mk/build.mk <<EOF
-V=1
-HADDOCK_DOCS=YES
-LATEX_DOCS=YES
-HSCOLOUR_SRCS=YES
-BUILD_DOCBOOK_HTML=YES
-BeConservative=YES
-EOF
-
-export THREADS=8
-export SKIP_PERF_TESTS=YES
-export VERBOSE=2
-
-function run_build() {
-    ./boot
-    ./configure "$@"
-    make -j$THREADS
-    make fasttest
-    make binary-dist
-}
-
-case "$(uname)" in
-  Linux)
-    if [[ -n ${TARGET:-} ]]; then
-      if [[ $TARGET = FreeBSD ]]; then
-        # cross-compiling to FreeBSD
-        echo 'HADDOCK_DOCS = NO' >> mk/build.mk
-        echo 'WERROR=' >> mk/build.mk
-        export PATH=/opt/ghc/bin:$PATH
-        run_build --target=x86_64-unknown-freebsd10
-      else
-        fail "TARGET=$target not supported"
-      fi
-    else
-      run_build
-    fi
-    ;;
-  Darwin)
-    if [[ -n ${TARGET:-} ]]; then
-      fail "uname=$(uname) not supported for cross-compilation"
-    fi
-    run_build
-    ;;
-  *)
-    fail "uname=$(uname) not supported"
-esac
diff --git a/.circleci/config.yml b/.circleci/config.yml
index e38d265..c35ac21 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -3,6 +3,16 @@ version: 2
 aliases:
   - &defaults
     working_directory: ~/ghc
+
+  # Make sure we have proper openssh before checkout: CircleCI git
+  # does not check the repository out properly without it and also
+  # takes 20 times longer than it should be.
+  - &precheckout
+    run:
+      name: Install OpenSSH client
+      command: |
+        apt-get update -qq
+        apt-get install -qy openssh-client
   - &prepare
     run:
       name: prepare-system
@@ -11,16 +21,40 @@ aliases:
     run:
       name: submodules
       command: .circleci/fetch-submodules.sh
-  - &build
+  - &buildenv
+    THREADS: 8
+    SKIP_PERF_TESTS: YES
+    VERBOSE: 2
+  - &boot
+    run:
+      name: Boot
+      command: ./boot
+  - &configure_unix
+    run:
+      name: Configure
+      command: ./configure
+  - &configure_bsd
+    run:
+      name: Configure
+      command: ./configure --target=x86_64-unknown-freebsd10
+  - &make
     run:
-      name: build
-      command: .circleci/build.sh
+      name: Build
+      command: "make -j$THREADS"
+  - &test
+    run:
+      name: Test
+      command: make test
+  - &bindist
+    run:
+      name: Create bindist
+      command: make binary-dist
       # Building bindist takes ~15 minutes without output, account for
       # that.
       no_output_timeout: "30m"
   - &collectartifacts
     run:
-      name: collect artifacts
+      name: Collect artifacts
       # We need this because CircleCI expects a path without
       # wildcards but bindist archive name is not static
       command: |
@@ -28,28 +62,29 @@ aliases:
         pwd
         find .
         cp ghc*.tar.xz /tmp/artifacts
+  - &storeartifacts
+    store-artifacts:
+      path: /tmp/artifacts
 
 jobs:
   "validate-x86_64-linux":
     resource_class: xlarge
     docker:
       - image: haskell:8.2
+    environment:
+      <<: *buildenv
     steps:
-      # Make sure we have proper openssh before checkout: CircleCI git
-      # does not check the repository out properly without it and also
-      # takes 20 times longer than it should be.
-      - run:
-          name: install openssh
-          command: |
-            apt-get update -qq
-            apt-get install -y openssh-client
+      - *precheckout
       - checkout
       - *prepare
       - *submodules
-      - *build
+      - *boot
+      - *configure_unix
+      - *make
+      - *test
+      - *bindist
       - *collectartifacts
-      - store-artifacts:
-          path: /tmp/artifacts
+      - *storeartifacts
 
   "validate-x86_64-freebsd":
     resource_class: xlarge
@@ -57,28 +92,36 @@ jobs:
       - image: tweag/toolchain-x86_64-freebsd
     environment:
       TARGET: FreeBSD
+      <<: *buildenv
     steps:
-      - run:
-          name: install git
-          command: |
-            apt-get update -qq
-            apt-get install -qy openssh-client
+      - *precheckout
       - checkout
       - *prepare
       - *submodules
-      - *build
+      - *boot
+      - *configure_bsd
+      - *make
+      - *test
+      - *bindist
+      - *collectartifacts
+      - *storeartifacts
 
   "validate-x86_64-darwin":
     macos:
       xcode: "9.0"
+    environment:
+      <<: *buildenv
     steps:
       - checkout
       - *prepare
       - *submodules
-      - *build
+      - *boot
+      - *configure_unix
+      - *make
+      - *test
+      - *bindist
       - *collectartifacts
-      - store-artifacts:
-          path: /tmp/artifacts
+      - *storeartifacts
 
 workflows:
   version: 2
diff --git a/.circleci/prepare-system.sh b/.circleci/prepare-system.sh
index 5d4d630..063c70a 100755
--- a/.circleci/prepare-system.sh
+++ b/.circleci/prepare-system.sh
@@ -7,6 +7,18 @@ fail() {
   exit 1
 }
 
+echo 'BUILD_SPHINX_HTML = NO' > mk/validate.mk
+echo 'BUILD_SPHINX_PDF = NO' >> mk/validate.mk
+
+cat > mk/build.mk <<EOF
+V=1
+HADDOCK_DOCS=YES
+LATEX_DOCS=YES
+HSCOLOUR_SRCS=YES
+BUILD_DOCBOOK_HTML=YES
+BeConservative=YES
+EOF
+
 case "$(uname)" in
   Linux)
     if [[ -n ${TARGET:-} ]]; then
@@ -14,17 +26,23 @@ case "$(uname)" in
         # cross-compiling to FreeBSD
         add-apt-repository -y ppa:hvr/ghc
         apt-get update -qq
-        apt-get install -qy ghc-8.0.2 cabal-install  alex happy ncurses-dev git openssh-client make automake autoconf gcc perl python3 texinfo xz-utils
+        apt-get install -qy ghc-8.0.2 cabal-install-1.24 alex happy \
+                            ncurses-dev git make automake autoconf gcc perl \
+                            python3 texinfo xz-utils
         cabal update
         cabal install --reinstall hscolour
         ln -s $HOME/.cabal/bin/HsColour /usr/local/bin/HsColour
+
+        echo 'HADDOCK_DOCS = NO' >> mk/build.mk
+        echo 'WERROR=' >> mk/build.mk
+        # https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
+        echo 'export PATH=/opt/ghc/bin:$PATH' >> $BASH_ENV
       else
         fail "TARGET=$target not supported"
       fi
     else
       # assuming Ubuntu
-      apt-get update -qq
-      apt-get install -qy git openssh-client make automake autoconf gcc perl python3 texinfo xz-utils
+      apt-get install -qy git make automake autoconf gcc perl python3 texinfo xz-utils
       cabal update
       cabal install --reinstall hscolour
     fi



More information about the ghc-commits mailing list