-
Notifications
You must be signed in to change notification settings - Fork 0
/
cabal.travis.yml
141 lines (121 loc) Β· 4.19 KB
/
cabal.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
language: c
sudo: false
git:
submodules: false # don't recursively clone submodules
# NOTE: build multiple executables by making $EXE a matrix var
env:
global:
- EXE=hello # name of the executable to build (as it appears in the cabal stanza)
matrix:
include:
- os: linux
# NOTE: purescript prefers trusty for performance reasons?
dist: trusty
addons:
apt:
packages:
- ghc-8.4.4
- cabal-install-2.4
sources:
# https://launchpad.net/~hvr/+archive/ubuntu/ghc
- hvr-ghc
- os: osx
# Install stuff with Homebrew (see before_install)
- os: windows
# Install stuff with Chocolatey (see before_install)
# Make sure ghc and cabal are installed and on $PATH
before_install:
- |
if [ "$TRAVIS_OS_NAME" = linux ]
then
export PATH=$PATH:"/opt/ghc/bin";
fi
- |
if [ "$TRAVIS_OS_NAME" = osx ]
then
brew update;
# TODO: pin versions here
brew install ghc;
brew install cabal-install;
fi
- |
if [ "$TRAVIS_OS_NAME" = windows ]
then
# NOTE: can't have secure (i.e. set in the Travis UI) env vars
# otherwise this will hang
# https://travis-ci.community/t/choco-install-hangs-forever/307
choco install ghc --version 8.4.4 -y;
choco install cabal --version 2.4.1.0 -y;
# NOTE: Chocolatey $PATH changes don't take effect.
# Need to modify the $PATH manually.
export PATH=$PATH:"C:\ProgramData\chocolatey\lib\ghc\tools\ghc-8.4.4\bin";
fi
# Update package list and install project dependencies (cached)
install:
# Print version numbers for debuggin'
- ghc --version
- cabal --version
- travis_retry cabal new-update --verbose
- cabal new-build --disable-tests --disable-benchmarks --dependencies-only -j2 all
# Build and test the thing
script:
- cabal new-build --enable-tests --disable-benchmarks all
# ^^^^^^^ enable if you want
- cabal new-test all
- cabal check
# Deploy github release (optional)
before_deploy:
- cabal new-clean
- travis_retry cabal new-update --verbose
- cabal new-build --disable-tests --disable-benchmarks --enable-optimization=2 $EXE
# Get path of the built executable
- |
if [ "$TRAVIS_OS_NAME" = windows ]
then
EXE_NAME=$EXE.exe;
else
EXE_NAME=$EXE;
fi
- EXE_PATH=$(find dist-newstyle/build/ -type f -name $EXE_NAME) # NOTE: assuming this finds only one file!
# Build the tarball
- tar --create --file $TRAVIS_OS_NAME.tar --files-from /dev/null
- tar --append --file $TRAVIS_OS_NAME.tar -C $(dirname $EXE_PATH) $EXE_NAME
- tar --append --file $TRAVIS_OS_NAME.tar LICENSE
# Gzip the tarball
- gzip --verbose $TRAVIS_OS_NAME.tar
# Create the checksum
- |
if [ "$TRAVIS_OS_NAME" = windows ];
then
openssl dgst -sha1 $TRAVIS_OS_NAME.tar.gz | tee $TRAVIS_OS_NAME.sha;
else
shasum $TRAVIS_OS_NAME.tar.gz | tee $TRAVIS_OS_NAME.sha;
fi
deploy:
provider: releases
api_key:
# $ travis encrypt <github oauth token>
secure: "TODO"
file:
- $TRAVIS_OS_NAME.tar.gz
- $TRAVIS_OS_NAME.sha
skip_cleanup: true
on:
tags: true
notifications:
email:
on_success: never
on_failure: always
cache:
directories:
- $HOME/.cabal/packages
- $HOME/.cabal/store
before_cache:
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
# remove files that are regenerated by `cabal update`
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
- rm -rfv $HOME/.cabal/packages/head.hackage