Skip to content

Commit dec4529

Browse files
jirutkakripken
authored andcommitted
Set up Travis to run build on various architectures using Alpine and deploy statically linked binaries to GH Releases (#1064)
* Travis: Refactor config to use Build Stages * Travis: Add jobs for building on various architectures using Alpine * Travis: Build static binaries and deploy them to GH Releases
1 parent e6ea668 commit dec4529

1 file changed

Lines changed: 111 additions & 36 deletions

File tree

.travis.yml

Lines changed: 111 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,131 @@
11
sudo: false
2+
dist: trusty
23
language: cpp
3-
python:
4-
- "2.7"
54

6-
matrix:
5+
jobs:
76
include:
8-
9-
- env: CC_COMPILER="./test/wasm-install/wasm-install/bin/clang" CXX_COMPILER="./test/wasm-install/wasm-install/bin/clang++"
10-
dist: trusty
7+
# Build with clang and run tests on the host system (Ubuntu).
8+
- &test-ubuntu
9+
stage: test
1110
compiler: clang
12-
addons: &gcc5
11+
python: 2.7
12+
addons:
1313
apt:
1414
sources: ['ubuntu-toolchain-r-test']
1515
packages: ['cmake', 'nodejs', 'g++-5']
16+
before_install:
17+
- export CC="${CC_COMPILER}"
18+
- export CXX="${CXX_COMPILER}"
19+
- export ASAN_OPTIONS="symbolize=1"
20+
install:
21+
- pip install --user flake8
22+
before_script:
23+
# Check the style of a subset of Python code until the other code is updated.
24+
- flake8 ./scripts/
25+
- ./check.py --only-prepare
26+
script:
27+
- cmake . -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS"
28+
- make -j2
29+
- ./check.py
30+
env: |
31+
CC_COMPILER="./test/wasm-install/wasm-install/bin/clang"
32+
CXX_COMPILER="./test/wasm-install/wasm-install/bin/clang++"
1633
17-
- env: CC_COMPILER="./test/wasm-install/wasm-install/bin/clang" CXX_COMPILER="./test/wasm-install/wasm-install/bin/clang++" COMPILER_FLAGS="-fsanitize=undefined -fno-sanitize-recover=all -fsanitize-blacklist=`pwd`/ubsan.blacklist"
18-
dist: trusty
19-
compiler: clang
20-
addons: *gcc5
34+
- <<: *test-ubuntu
35+
env: |
36+
CC_COMPILER="./test/wasm-install/wasm-install/bin/clang"
37+
CXX_COMPILER="./test/wasm-install/wasm-install/bin/clang++"
38+
COMPILER_FLAGS="-fsanitize=undefined -fno-sanitize-recover=all -fsanitize-blacklist=$(pwd)/ubsan.blacklist"
2139
22-
- env: CC_COMPILER="./test/wasm-install/wasm-install/bin/clang" CXX_COMPILER="./test/wasm-install/wasm-install/bin/clang++" COMPILER_FLAGS="-fsanitize=address"
23-
dist: trusty
24-
compiler: clang
25-
addons: *gcc5
40+
- <<: *test-ubuntu
41+
env: |
42+
CC_COMPILER="./test/wasm-install/wasm-install/bin/clang"
43+
CXX_COMPILER="./test/wasm-install/wasm-install/bin/clang++"
44+
COMPILER_FLAGS="-fsanitize=address"
2645
27-
- env: CC_COMPILER="./test/wasm-install/wasm-install/bin/clang" CXX_COMPILER="./test/wasm-install/wasm-install/bin/clang++" COMPILER_FLAGS="-fsanitize=thread"
28-
dist: trusty
29-
compiler: clang
30-
addons: *gcc5
46+
- <<: *test-ubuntu
47+
env: |
48+
CC_COMPILER="./test/wasm-install/wasm-install/bin/clang"
49+
CXX_COMPILER="./test/wasm-install/wasm-install/bin/clang++"
50+
COMPILER_FLAGS="-fsanitize=thread"
3151
32-
- env: CC_COMPILER="gcc-5" CXX_COMPILER="g++-5"
33-
dist: trusty
52+
# Build with gcc 5 and run tests on the host system (Ubuntu).
53+
- <<: *test-ubuntu
3454
compiler: gcc
35-
addons: *gcc5
55+
env: |
56+
CC_COMPILER="gcc-5"
57+
CXX_COMPILER="g++-5"
58+
59+
# Build with gcc 6.3 and run tests on Alpine Linux (inside chroot).
60+
# Note: Alpine uses musl libc.
61+
- &test-alpine
62+
stage: test
63+
sudo: true
64+
language: minimal
65+
compiler: gcc
66+
env: ARCH=x86_64
67+
before_install:
68+
- "wget 'https://raw.githubusercontent.com/alpinelinux/alpine-chroot-install/v0.6.0/alpine-chroot-install' \
69+
&& echo 'a827a4ba3d0817e7c88bae17fe34e50204983d1e alpine-chroot-install' | sha1sum -c || exit 1"
70+
- alpine() { /alpine/enter-chroot -u "$USER" "$@"; }
71+
install:
72+
- sudo sh alpine-chroot-install -a "$ARCH" -p 'build-base cmake git nodejs python2'
73+
before_script:
74+
- alpine ./check.py --only-prepare
75+
script:
76+
- alpine cmake .
77+
- alpine make -j2
78+
- alpine ./check.py
79+
80+
81+
# Build statically linked release binaries with gcc 6.3 on Alpine Linux
82+
# (inside chroot). If building a tagged commit, then deploy release tarball
83+
# to GitHub Releases.
84+
- &build-alpine
85+
<<: *test-alpine
86+
stage: build
87+
env: ARCH=x86_64
88+
script:
89+
- alpine cmake -DCMAKE_BUILD_TYPE=Release
90+
-DCMAKE_VERBOSE_MAKEFILE=ON
91+
-DCMAKE_CXX_FLAGS="-static -no-pie"
92+
-DCMAKE_C_FLAGS="-static -no-pie" .
93+
- alpine make -j2
94+
- alpine find bin/ -type f -perm -u=x -exec strip {} +
95+
- alpine ls -lh bin/
96+
# Check if the built executables are really statically linked.
97+
- if [ -n "$(find bin/ -type f -perm -u=x -exec file {} + | grep -Fvw 'statically linked')" ]; then
98+
file bin/*; exit 1;
99+
fi
100+
before_deploy:
101+
- PKGNAME="binaryen-$TRAVIS_TAG-$ARCH-linux"
102+
- mv bin binaryen-$TRAVIS_TAG
103+
- tar -czf $PKGNAME.tar.gz binaryen-$TRAVIS_TAG
104+
- sha256sum $PKGNAME.tar.gz > $PKGNAME.tar.gz.sha256
105+
deploy:
106+
provider: releases
107+
api_key:
108+
secret: TODO
109+
file: binaryen-$TRAVIS_TAG-*.tar.gz*
110+
file_glob: true
111+
skip_cleanup: true
112+
on:
113+
tags: true
36114

37-
before_install:
38-
- export CC="${CC_COMPILER}"
39-
- export CXX="${CXX_COMPILER}"
40-
- export ASAN_OPTIONS="symbolize=1"
115+
# Build binaries for other architectures using QEMU user-mode emulation.
116+
# Note: We don't run tests for these architectures, because some fail under
117+
# QEMU/binfmt and it takes too long time (hits time limit on Travis).
118+
- <<: *build-alpine
119+
env: ARCH=x86
41120

42-
install:
43-
- pip install --user flake8
121+
- <<: *build-alpine
122+
env: ARCH=aarch64
44123

45-
before_script:
46-
# Check the style of a subset of Python code until the other code is updated.
47-
- flake8 ./scripts/
124+
- <<: *build-alpine
125+
env: ARCH=armhf
48126

49-
script:
50-
- ./check.py --only-prepare
51-
- cmake . -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS"
52-
- make -j2
53-
- ./check.py
127+
- <<: *build-alpine
128+
env: ARCH=ppc64le
54129

55130
notifications:
56131
email: false

0 commit comments

Comments
 (0)