forked from nirum-lang/nirum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
234 lines (212 loc) · 7.4 KB
/
.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
dist: trusty
sudo: false
language: c
matrix:
include:
- os: osx
osx_image: xcode8.3
- addons:
apt:
sources: [hvr-ghc, deadsnakes]
packages:
- ghc-8.0.2
- python2.7
- python3.4
- python3.5
- python3.6
- libgmp10
- upx-ucl
- shellcheck
env:
- PIP_MINVER=9.0.1 SETUPTOOLS_MINVER=36.6.0
cache:
directories:
- "$HOME/.cabal"
- "$HOME/.stack"
- "$HOME/.ghc"
- "$HOME/Library/Caches/Homebrew"
before_install:
- grep 2016–`date +%Y` package.yaml # Check copyright year
# Check version
- |
if [[ "$TRAVIS_TAG" != "" ]]; then
[[ "$(stack query locals nirum version)" == "'$TRAVIS_TAG'" ]]
grep "$TRAVIS_TAG" README.md # Check output example of -h/--help
fi
# Check changelog
- |
if git show --format=%B --quiet "${TRAVIS_PULL_REQUEST_SHA:-${TRAVIS_TAG:-${TRAVIS_COMMIT}}}" \
| grep '\[changelog skip\]' > /dev/null; then
echo "Skip changelog checker..."
elif [[ "$TRAVIS_TAG" != "" ]]; then
! grep -i "to be released" CHANGES.md
else
[[ "$TRAVIS_COMMIT_RANGE" = "" ]] || \
[[ "$(git diff --name-only "$TRAVIS_COMMIT_RANGE" | grep CHANGES\.md)" != "" ]]
fi
# Install things
- mkdir -p "$HOME/.local/bin"
- export PATH="$HOME/.local/bin:$PATH"
- |
if [[ "$TRAVIS_OS_NAME" = "linux" ]]
then
curl -o "$HOME/.local/bin/checkmate" \
-L https://github.com/spoqa/checkmate/releases/download/0.3.2/checkmate-linux-x86_64
chmod +x "$HOME/.local/bin/checkmate"
checkmate --help
token_encoded='gJvdss03HpHm1tCqhziBezjVi8Y='
token="$(echo $token_encoded | python -m base64 -d | xxd -pu)"
checkmate github-travis --token "$token"
fi
- |
if [[ "$TRAVIS_OS_NAME" = "osx" ]]
then
travis_retry curl -L https://www.stackage.org/stack/$TRAVIS_OS_NAME-x86_64 | tar xz --strip-components=1 --include '*/stack' -C "$HOME/.local/bin"
else
travis_retry curl -L https://www.stackage.org/stack/$TRAVIS_OS_NAME-x86_64 | tar xz --wildcards --strip-components=1 -C "$HOME/.local/bin" '*/stack'
fi
- |
if [[ "$TRAVIS_OS_NAME" = "osx" ]]
then
brew update || true
brew upgrade || true
brew update || true
brew install --with-default-names gnu-sed
brew tap dahlia/homebrew-deadsnakes
brew install python34 python35 python3 || \
brew upgrade python34 python35 python3 || \
true
pip3 install --upgrade pip setuptools
fi
- curl -o "$HOME/.local/bin/travis_long" -L https://raw.githubusercontent.com/futurice/fum2github/master/travis_long
- chmod +x "$HOME/.local/bin/travis_long"
install:
- |
if python3 -c "import pip"; then
python3 -m pip install --user -U setuptools
python3 -m pip install --user -U "pip>=$PIP_MINVER"
else
if ! python3 -c "import setuptools"; then
pushd /tmp
curl -L "https://github.com/pypa/setuptools/archive/v$SETUPTOOLS_MINVER.tar.gz" | tar xvfz -
cd setuptools-*/
python3 bootstrap.py
python3 setup.py install --user
popd
fi
python3 -m easy_install --user -U "setuptools>=$SETUPTOOLS_MINVER"
python3 -m easy_install --user -U "pip>=$PIP_MINVER"
fi
- python3 -m pip install --user --upgrade tox
- travis_long stack --no-terminal setup
- travis_long stack --no-terminal install scan -j4
- travis_long stack --no-terminal install -j4 --only-dependencies
- |
if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then
curl -L -o "$HOME/.local/bin/hadolint" \
https://github.com/hadolint/hadolint/releases/download/v1.4.0/hadolint-Linux-x86_64
chmod +x "$HOME/.local/bin/hadolint"
fi
script:
- ls -al "$(python3 -m site --user-base)/bin/tox"
- 'TOX="$(python3 -m site --user-base)/bin/tox" stack --no-terminal test -j4 --coverage'
- ./lint.sh
after_script:
- |
# Since codecov-haskell doesn't work on Windows,
# it should be added to extra-deps during only Travis CI build.
sed -i 's|^## *INSERT CODECOV HERE.*$|- {"git": "https://github.com/spoqa/codecov-haskell.git", "commit": "8448801f8d01624e4cd60420beb3fdc85c099576"}|' stack.yaml
- stack build --install-ghc --no-terminal --copy-bins codecov-haskell
- find . -name '*.tix'
- find . -name '*.mix'
- |
token_encoded='NTBjYmQ4ZTgtN2Y4Ni00Mzg4LWIyN2EtMzMzMzhiNjUwZjc3'
stack exec -- codecov-haskell \
--tix-dir ./.stack-work/install/x86_64-*/lts-*/*/hpc/nirum/ \
--mix-dir ./.stack-work/dist/x86_64-*/Cabal-*/hpc/ \
--token="$(echo $token_encoded | python -m base64 -d)" \
spec
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/29cc2477daa438db4e9d
- 'http://travis-auto-rebuilder.herokuapp.com/76caecf7-abe1-4122-9fcc-aa5226dc10f8/?jobs=1&subject-to=2&retries=5'
on_success: change
on_failure: always
on_start: never
before_deploy:
- mkdir -p /tmp/nirum-build
- export NIGHTLY_BINARY_PATH="/tmp/nirum-build/nirum-$(uname -s | tr '[A-Z]' '[a-z]')-$(uname -m)"
- |
if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then
docker build -t nirum .
docker run --entrypoint /bin/cat nirum /bin/nirum > "$NIGHTLY_BINARY_PATH"
chmod +x "$NIGHTLY_BINARY_PATH"
upx-ucl -9 "$NIGHTLY_BINARY_PATH"
elif [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
stack clean --no-terminal
stack build --no-terminal --copy-bins --flag nirum:static
ls -al "$(stack path --local-bin)/nirum"
cp "$(stack path --local-bin)/nirum" "$NIGHTLY_BINARY_PATH"
ls -al /tmp/nirum-build
fi
ls -al "$NIGHTLY_BINARY_PATH"
deploy:
# Nightly builds
- provider: s3
on: { branch: master }
skip_cleanup: yes
local_dir: /tmp/nirum-build
upload-dir: travis-builds
acl: public_read
bucket: nightly-builds.nirum.org
access_key_id: "$AWS_ACCESS_KEY_ID"
secret_access_key: "$AWS_SECRET_ACCESS_KEY"
# GitHub Releases
- provider: releases
on: { tags: yes }
skip_cleanup: yes
api_key: "$GITHUB_TOKEN"
file_glob: yes
file: /tmp/nirum-build/*
name: "$TRAVIS_TAG"
prerelease: yes
after_deploy: |
[[ "$TRAVIS_TAG" != "" && "$TRAVIS_OS_NAME" = "linux" ]] || exit 0
# Give the GitHub release a proper description
export GITHUB_USER="${TRAVIS_REPO_SLUG%%/[^/]*}" \
GITHUB_REPO="${TRAVIS_REPO_SLUG#[^/]*/}"
curl -L -o "$HOME/.local/bin/submark" \
https://github.com/dahlia/submark/releases/download/0.2.0/submark-linux-x86_64
chmod +x "$HOME/.local/bin/submark"
submark -o /tmp/release-note -i --h2 "Version $TRAVIS_TAG" -O CHANGES.md
pushd /tmp
curl -LO \
https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2
tar xvfj linux-amd64-github-release.tar.bz2
mv bin/linux/amd64/github-release "$HOME/.local/bin"
if [[ "$TRAVIS_TAG" = 0.* ]]; then
pre_release="--pre-release"
fi
github-release edit \
--tag "$TRAVIS_TAG" \
--name "Nirum $TRAVIS_TAG" \
--description "$(cat /tmp/release-note)" \
$pre_release
popd
# sdist
sed -i 's/^- -Werror$//g' package.yaml # Hackage disallows -Werror
stack --no-terminal sdist --ignore-check
# Upload sdist as well to GitHub Releases
for sdist_file in "$(stack path --dist-dir)"/*.tar.gz; do
github-release upload \
--tag "$TRAVIS_TAG" \
--name "$(basename $sdist_file)" \
--file "$sdist_file"
done
# Upload sdist to Hackage
if [[ "$HACKAGE_USERNAME" != "" && "$HACKAGE_PASSWORD" != "" ]]; then
mkdir -p "$HOME/.stack/upload"
python -c 'import json, os; print(json.dumps({"username": os.environ["HACKAGE_USERNAME"], "password": os.environ["HACKAGE_PASSWORD"]}))' > ~/.stack/upload/credentials.json
stack --no-terminal upload --ignore-check --no-signature .
fi