Skip to content

Commit 6bac41c

Browse files
committed
Merge pull request #118 from japaric/travis
Travis CI: expand to test and deploy for Linux and Mac
2 parents 9e34ecc + b094268 commit 6bac41c

File tree

5 files changed

+175
-18
lines changed

5 files changed

+175
-18
lines changed

.travis.yml

Lines changed: 102 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,107 @@
1+
sudo: false
2+
13
language: rust
2-
rust:
3-
- stable
4-
- beta
5-
- nightly
6-
matrix:
7-
allow_failure:
8-
- rust: nightly
4+
95
env:
106
global:
11-
secure: l3/qEC4krRerllLQzni8j5AjngFi6pluWvBWj//1mJLoIEYwxlQ9mYxEdd9BqccWWFn3K0bVYCVC/64+tP6sRfLkZCe2gPUtwe7ITwCDbapUxmkiRObVJCs5yMQZt6idyhHUDKAXKgNCrusfI2BM3tKGBfRK7Cnn/R/7p/U9+q7D1sgJtUKp6ypVzK6A3jLNp3dFLFI19a5KmbZMVsaa7tOhtdDJjjr7ebsc9z7HMW5/OItiWU3FSauVQQlUMaCiEgFuIG7H7OnBAYWB/gNEtLuwfLqU9UjtWk/njNNRnmJ7m3y5HbQhv5H5F5mJUOq9XFlPLwPwyTeVztSGdQm6k8Pp2pgKBUjY27afBl9BWU+msmN6k0oXfhvIebiBPe/x2udiKeFik1xqOOEU1q9dF0sZiuPxCSM1n7tgWklJ8epgaRQaMPPQw9pO/2H5/ynHCJqBlw6WcdiqWtwAyyr/GEx62u/cg5IVkqb7KLmYsWzjS8wYG4CYs1eIxCw2xPZxP0FGuUXvxTBUPipFze6Z7FqxVauXtVe2D7c1P4738HZP660rmR0GYtHtKLny1QxCCK9sxd9JmcezFCSz4YeQ1od9xc0OzGJ2ullKNGizmGfYmgL6X8faNylLIEdaiHAcY16xV3L0g3fXL1Qg360UHQyj7GIv+0nqQnf+H9xRTTU=
12-
addons:
13-
apt:
14-
packages:
15-
- nodejs
16-
- npm
7+
- PROJECT_NAME=mdBook
8+
9+
matrix:
10+
include:
11+
# Stable channel
12+
# TODO re-enable the i686-apple-darwin target when passcod/rsnotify#53 is fixed
13+
#- os: osx
14+
#env: TARGET=i686-apple-darwin
15+
#rust: stable
16+
- os: linux
17+
env: TARGET=i686-unknown-linux-gnu
18+
rust: stable
19+
addons:
20+
apt:
21+
packages: &i686_unknown_linux_gnu
22+
- gcc-multilib
23+
- os: osx
24+
env: TARGET=x86_64-apple-darwin
25+
rust: stable
26+
- os: linux
27+
env: TARGET=x86_64-unknown-linux-gnu
28+
rust: stable
29+
addons:
30+
apt:
31+
packages:
32+
- nodejs
33+
- npm
34+
- os: linux
35+
env: TARGET=x86_64-unknown-linux-musl
36+
rust: stable
37+
# Beta channel
38+
#- os: osx
39+
#env: TARGET=i686-apple-darwin
40+
#rust: beta
41+
- os: linux
42+
env: TARGET=i686-unknown-linux-gnu
43+
rust: beta
44+
addons:
45+
apt:
46+
packages: *i686_unknown_linux_gnu
47+
- os: osx
48+
env: TARGET=x86_64-apple-darwin
49+
rust: beta
50+
- os: linux
51+
env: TARGET=x86_64-unknown-linux-gnu
52+
rust: beta
53+
- os: linux
54+
env: TARGET=x86_64-unknown-linux-musl
55+
rust: beta
56+
# Nightly channel
57+
#- os: osx
58+
#env: TARGET=i686-apple-darwin
59+
#rust: nightly
60+
- os: linux
61+
env: TARGET=i686-unknown-linux-gnu
62+
rust: nightly
63+
addons:
64+
apt:
65+
packages: *i686_unknown_linux_gnu
66+
- os: osx
67+
env: TARGET=x86_64-apple-darwin
68+
rust: nightly
69+
- os: linux
70+
env: TARGET=x86_64-unknown-linux-gnu
71+
rust: nightly
72+
- os: linux
73+
env: TARGET=x86_64-unknown-linux-musl
74+
rust: nightly
75+
1776
install:
18-
- npm install stylus nib
77+
- sh ci/install.sh
78+
79+
script:
80+
- sh ci/script.sh
81+
1982
after_success:
20-
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && bash deploy.sh
83+
- test $TRAVIS_PULL_REQUEST == "false" &&
84+
test $TRAVIS_BRANCH == "master" &&
85+
test $TARGET == "x86_64-unknown-linux-gnu" &&
86+
test $TRAVIS_RUST_VERSION = "stable" &&
87+
npm install stylus nib &&
88+
bash deploy.sh
89+
90+
before_deploy:
91+
- sh ci/before_deploy.sh
92+
93+
deploy:
94+
provider: releases
95+
api_key:
96+
secure: Z1k7WqX7z+tT4+SzTh4tBBzf11VaADB4AWuEczHtylaEb/0hRs8gaiHCNSVHm/QTp0QPWQR2Vw7uKMhVuxG7I8X7h31j3A7ulYBh/iVk0DVIrtrn2Q4WOED9CpoXLuLtk2nxo9MBViFW7mw4nJe9H2Tn9o/9oEYBuwzekvW5mh4muqUuCVTr8eQVYbs3jbC9pQy5oYjOLeUnlL9Cey5VN/nAhzAtyFP+6lIMri0PKit4JtkFou/O1MEpFYlP3VGC2lFiWuByocPKBT/L45FecS9qoHq+i6+ZCPDH2eu46nuYsDbLKAkPdGvf1MdPBPwoj0vSnZbgaTisQ4hIoBngQQQPZlPaGtcdd6g6asxSfnbA9cQhClI5oZJmg+ksxQE+peE8pnbmZ10Ix0PpIkkfWdQeMdUUCQarOTkTK54Munw+X+kp1lH19j6+krQPLBYr95fPRd4b5tWsJD2+pb/UOYFEEJxMNoUHyLCrtdCO7imOwrSUcv51+Z8UudqfPpKQeszrJcntL4owip35r3sF5TsE9YfW5qssLC164IylvP32y1AcfL1jqg8b+zrqLZKanjvDOJ1dtHHuwKqxcwf7PhAf0YjAtVSH9OIYcDzmDa0EMLrq7EK0fs6NAeb5qt6CML7pZrRS3fmOxN53Fbmj81qm6TmjQjDe4dmZlELgNow=
97+
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz
98+
# don't delete the artifacts from previous phases
99+
skip_cleanup: true
100+
# deploy when a new tag is pushed
101+
on:
102+
condition: $TRAVIS_RUST_VERSION = stable
103+
tags: true
104+
105+
notifications:
106+
email:
107+
on_success: never

ci/before_deploy.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# `before_deploy` phase: here we package the build artifacts
2+
3+
set -ex
4+
5+
cargo build --target $TARGET --release
6+
7+
mkdir staging
8+
9+
cp target/$TARGET/release/mdbook staging
10+
11+
cd staging
12+
13+
tar czf ../${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz *

ci/install.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# `install` phase: install stuff needed for the `script` phase
2+
3+
set -ex
4+
5+
case $TARGET in
6+
# Install standard libraries needed for cross compilation
7+
i686-apple-darwin | \
8+
i686-unknown-linux-gnu | \
9+
x86_64-unknown-linux-musl)
10+
case $TRAVIS_RUST_VERSION in
11+
stable)
12+
# e.g. 1.6.0
13+
version=$(rustc -V | cut -d' ' -f2)
14+
;;
15+
*)
16+
version=$TRAVIS_RUST_VERSION
17+
;;
18+
esac
19+
tarball=rust-std-${version}-${TARGET}
20+
21+
curl -Os http://static.rust-lang.org/dist/${tarball}.tar.gz
22+
23+
tar xzf ${tarball}.tar.gz
24+
25+
${tarball}/install.sh --prefix=$(rustc --print sysroot)
26+
27+
rm -r ${tarball}
28+
rm ${tarball}.tar.gz
29+
;;
30+
# Nothing to do for native builds
31+
*)
32+
;;
33+
esac

ci/script.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# `script` phase: you usually build, test and generate docs in this phase
2+
3+
set -ex
4+
5+
case "$TRAVIS_OS_NAME" in
6+
linux)
7+
host=x86_64-unknown-linux-gnu
8+
;;
9+
osx)
10+
host=x86_64-apple-darwin
11+
;;
12+
esac
13+
14+
# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when crossing
15+
if [ "$host" != "$TARGET" ]; then
16+
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
17+
brew install gnu-sed --default-names
18+
fi
19+
20+
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g'
21+
fi
22+
23+
cargo build --target $TARGET --verbose
24+
cargo test --target $TARGET --verbose

deploy.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ cargo doc
1515

1616
echo -e "${CYAN}Running mdbook build${NC}"
1717
# Run mdbook to generate the book
18-
target/debug/mdbook build book-example/
18+
target/$TARGET/debug/mdbook build book-example/
1919

2020
echo -e "${CYAN}Copying book to target/doc${NC}"
2121
# Copy files from rendered book to doc root
22-
cp -R book-example/book/* target/doc/
22+
cp -R book-example/book/* target/$TARGET/doc/
2323

24-
cd target/doc
24+
cd target/$TARGET/doc
2525

2626
echo -e "${CYAN}Initializing Git${NC}"
2727
git init

0 commit comments

Comments
 (0)