Skip to content

Commit d6986ea

Browse files
committed
Build macOS binaries with Travis
1 parent e497101 commit d6986ea

File tree

1 file changed

+58
-83
lines changed

1 file changed

+58
-83
lines changed

.travis.yml

Lines changed: 58 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,75 @@
1-
# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
2-
language: c
3-
sudo: false
1+
sudo: required
2+
3+
language: generic
44

55
cache:
66
directories:
7-
- $HOME/.cabsnap
8-
- $HOME/.cabal/packages
9-
10-
before_cache:
11-
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
12-
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
7+
- $HOME/.ghc
8+
- $HOME/.cabal
9+
- $HOME/.stack
10+
- $TRAVIS_BUILD_DIR/.stack-work
1311

1412
matrix:
1513
include:
16-
- env: CABALVER=1.24 GHCVER=8.0.1 DEPLOY_GITHUB_RELEASE=true
17-
compiler: ": #GHC 8.0.1"
18-
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
19-
- env: CABALVER=1.24 GHCVER=8.0.1 DEPLOY_GITHUB_RELEASE=true
20-
compiler: ": #GHC 8.0.1"
21-
os: osx
14+
# Build only on macOS
15+
- env: BUILD=stack
16+
compiler: ": #stack default osx"
17+
os: osx
18+
19+
# Build only master and release tags
20+
branches:
21+
only:
22+
- master
23+
- /^\d+\.\d+\.\d+(\.\d+)?$/
24+
2225

2326
before_install:
24-
- unset CC
25-
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
26-
# Work around travis issue by updating Homebrew: https://github.com/travis-ci/travis-ci/issues/8552
27-
- if [ "$TRAVIS_OS_NAME" = osx ];
28-
then
29-
brew update;
30-
brew install cabal-install;
31-
brew install gnu-sed --with-default-names;
32-
fi
27+
# Using compiler above sets CC to an invalid value, so unset it
28+
- unset CC
29+
# We want to always allow newer versions of packages when building on GHC HEAD
30+
- CABALARGS=""
31+
- if [ "x$GHCVER" = "xhead" ]; then CABALARGS=--allow-newer; fi
32+
# Download and unpack the stack executable
33+
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:/opt/alex/$ALEXVER/bin:/opt/happy/$HAPPYVER/bin:$HOME/.cabal/bin:$PATH
34+
- mkdir -p ~/.local/bin
35+
- travis_retry curl --insecure -L https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
36+
# Use the more reliable S3 mirror of Hackage
37+
- mkdir -p $HOME/.cabal
38+
- echo 'remote-repo: hackage.haskell.org:http://hackage.fpcomplete.com/' > $HOME/.cabal/config
39+
- echo 'remote-repo-cache: $HOME/.cabal/packages' >> $HOME/.cabal/config
3340

34-
install:
35-
- cabal --version
36-
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
37-
- if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
38-
then
39-
zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
40-
$HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
41-
fi
42-
- travis_retry cabal update -v
43-
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
44-
- cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
45-
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
4641

47-
# check whether current requested install-plan matches cached package-db snapshot
48-
- if diff -u $HOME/.cabsnap/installplan.txt installplan.txt;
49-
then
50-
echo "cabal build-cache HIT";
51-
rm -rfv .ghc;
52-
cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
53-
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
54-
else
55-
echo "cabal build-cache MISS";
56-
rm -rf $HOME/.cabsnap;
57-
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
58-
cabal install --only-dependencies --enable-tests --enable-benchmarks;
59-
fi
42+
install:
43+
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
44+
- if [ -f configure.ac ]; then autoreconf -i; fi
45+
- set -ex
46+
- stack --no-terminal --install-ghc $ARGS test --bench --only-dependencies
47+
- set +ex
6048

61-
# snapshot package-db on cache miss
62-
- if [ ! -d $HOME/.cabsnap ];
63-
then
64-
echo "snapshotting package-db to build-cache";
65-
mkdir $HOME/.cabsnap;
66-
cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
67-
cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
68-
fi
6949

70-
# Here starts the actual work to be performed for the package under test;
71-
# any command which exits with a non-zero exit code causes the build to fail.
7250
script:
73-
- if [ -f configure.ac ]; then autoreconf -i; fi
74-
- cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
75-
- cabal build # this builds all libraries and executables (including tests/benchmarks)
76-
- cabal test
77-
- cabal check
78-
- cabal sdist # tests that a source-distribution can be generated
79-
80-
# Check that the resulting source distribution can be built & installed.
81-
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
82-
# `cabal install --force-reinstalls dist/*-*.tar.gz`
83-
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
84-
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
51+
- export PATH="${PATH}:$(pwd)/artifacts"
52+
- stack build --copy-bins --local-bin-path ./bin
53+
- get_cabal_version() { cat $1/$1.cabal | grep '^Version: ' | gsed -e 's/^Version: //g'; }
54+
- mk_release_name() { echo "$1-$(get_cabal_version $1)-x86_64-macos.tar.bz2"; }
55+
- tar -jcvf $(mk_release_name dhall) bin/dhall
56+
- tar -jcvf $(mk_release_name dhall-json) bin/dhall-to-json bin/dhall-to-yaml bin/json-to-dhall bin/yaml-to-dhall
57+
- tar -jcvf $(mk_release_name dhall-bash) bin/dhall-to-bash
58+
- tar -jcvf $(mk_release_name dhall-lsp-server) bin/dhall-lsp-server
8559

8660
before_deploy:
87-
- tar --create --file "$TRAVIS_OS_NAME.tar" --files-from /dev/null
88-
- tar --append --file "$TRAVIS_OS_NAME.tar" --directory dist/build/dhall dhall
89-
- gzip "$TRAVIS_OS_NAME.tar"
61+
- stack build --copy-bins --local-bin-path ./bin
62+
# TODO: move the tar operations here
63+
- mkdir -p uploads
64+
- mv *.tar.bz2 uploads/
9065

9166
deploy:
92-
provider: releases
93-
api_key: "$GITHUB_OAUTH_TOKEN"
94-
file: "$TRAVIS_OS_NAME.tar.gz"
95-
on:
96-
condition: $DEPLOY_GITHUB_RELEASE = true
97-
tags: true
98-
skip_cleanup: true
99-
100-
# EOF
67+
- provider: releases
68+
api_key: $GITHUB_OAUTH_TOKEN
69+
file_glob: true
70+
file: uploads/*
71+
skip_cleanup: true
72+
on:
73+
tags: true
74+
script:
75+
- echo 'done'

0 commit comments

Comments
 (0)