Skip to content

Commit c721ba8

Browse files
Update travis CI (#516)
* Use japaric/trust for travis configuration * Moved the github pages logic (not running the script breaks the build) * Removed the x86 linux musl build
1 parent bd134fb commit c721ba8

File tree

5 files changed

+172
-53
lines changed

5 files changed

+172
-53
lines changed

.travis.yml

Lines changed: 68 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,87 @@
1+
# Based on the "trust" template v0.1.1
2+
# https://github.com/japaric/trust/tree/v0.1.1
3+
4+
dist: trusty
15
language: rust
2-
sudo: false
6+
services: docker
7+
sudo: required
38

49
cache: cargo
10+
before_cache:
11+
- chmod -R a+r $HOME/.cargo
12+
13+
env:
14+
global:
15+
- CRATE_NAME=mdbook
16+
- secure: DPzSRXyfRIVTibv1wOKFeGekXlL8sumGEZxpeq911MpLlrndOKmOo5Ibi3JD8fbUOsE9A/5spj4B2KQNjhbplH+Cp26oEikjuNAA6cA/b2+/TMoC3i0klAYpVopBBV3FFna0gLP+q6t6fzG2v9TJrvmmVav6KVX6ylPNvD/LoReCjrkpgLIQuAQ6dSQNor9uV+EVt4plKhhkiS28DlYdgmTvNb5g4dzOhs8hoWty72J765VYWEDDC8qXn6N9GyrhsC3dhjASGn+1QDSCADYdbG9nrRlb4CZhrfcgOnHhAFva363kshg9HtCphigMgQy2oZXk4nLWK90/HuaPPkVj+N/lpIYjtiHOunToZJfIb0MWzyVI+7+I7WR6n6XbhLCPMe/sPXHHQ3HhQhZZ9xv7CDx9IkYJQBcF3LC+9kzJRi4QT0UTqrxcO3ncgXwvholP8Vg2KKPqFcbuyLPzbvr/o8zIilvLUFAEoDPfTEwSAC4BCzaGkFQVWzhWkgw8Pe1ckOEYFkZ0VLBuCpEiz+x45sbBL1SnnO5xhpjmdc572ZyW7ZmAABw1VfiWhhBWg4WGSf8lLnDHhNA36Qon34pnME/xpJQtWoo7ZZkkzvzYP/oW88/0UIMWDSOYKz7MijXlbNUggwAwUhrLzXDuB71HUKfPreFubfUxbOpu+OtTcOQ=
17+
18+
matrix:
19+
include:
20+
# Android
21+
- env: TARGET=arm-linux-androideabi DISABLE_TESTS=1
22+
23+
# Linux
24+
- env: TARGET=aarch64-unknown-linux-gnu
25+
- env: TARGET=arm-unknown-linux-gnueabi
26+
- env: TARGET=i686-unknown-linux-gnu
27+
- env: TARGET=x86_64-unknown-linux-gnu
28+
- env: TARGET=x86_64-unknown-linux-musl
29+
30+
# Mac
31+
- env: TARGET=i686-apple-darwin
32+
os: osx
33+
- env: TARGET=x86_64-apple-darwin
34+
os: osx
35+
36+
# BSD
37+
- env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1
38+
- env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
39+
- env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1
540

6-
rust:
7-
- stable
8-
- nightly
41+
# Other channels
42+
- env: TARGET=x86_64-unknown-linux-gnu
43+
rust: beta
44+
- env: TARGET=x86_64-apple-darwin
45+
os: osx
46+
rust: beta
47+
- env: TARGET=x86_64-unknown-linux-gnu
48+
rust: nightly
49+
- env: TARGET=x86_64-apple-darwin
50+
os: osx
51+
rust: nightly
952

10-
os:
11-
- linux
12-
- osx
53+
before_install:
54+
- set -e
55+
- rustup self update
56+
57+
install:
58+
- sh ci/install.sh
59+
- source ~/.cargo/env || true
1360

1461
script:
15-
- cargo build --verbose
16-
- cargo test --verbose
62+
- bash ci/script.sh
1763

1864
after_success:
19-
# Deploy the docs if the commit is on master
20-
- test "$TRAVIS_PULL_REQUEST" == "false" &&
21-
test "$TRAVIS_BRANCH" == "master" &&
22-
test "$TRAVIS_RUST_VERSION" == "stable" &&
23-
npm install stylus nib &&
24-
bash ci/deploy.sh
65+
- bash ci/github_pages.sh
2566

2667
before_deploy:
27-
# Script to create packages from the build artefacts to upload to GitHub
28-
- bash ci/before_deploy.sh
68+
- sh ci/before_deploy.sh
2969

3070
deploy:
31-
provider: releases
3271
api_key:
33-
secure: Z1k7WqX7z+tT4+SzTh4tBBzf11VaADB4AWuEczHtylaEb/0hRs8gaiHCNSVHm/QTp0QPWQR2Vw7uKMhVuxG7I8X7h31j3A7ulYBh/iVk0DVIrtrn2Q4WOED9CpoXLuLtk2nxo9MBViFW7mw4nJe9H2Tn9o/9oEYBuwzekvW5mh4muqUuCVTr8eQVYbs3jbC9pQy5oYjOLeUnlL9Cey5VN/nAhzAtyFP+6lIMri0PKit4JtkFou/O1MEpFYlP3VGC2lFiWuByocPKBT/L45FecS9qoHq+i6+ZCPDH2eu46nuYsDbLKAkPdGvf1MdPBPwoj0vSnZbgaTisQ4hIoBngQQQPZlPaGtcdd6g6asxSfnbA9cQhClI5oZJmg+ksxQE+peE8pnbmZ10Ix0PpIkkfWdQeMdUUCQarOTkTK54Munw+X+kp1lH19j6+krQPLBYr95fPRd4b5tWsJD2+pb/UOYFEEJxMNoUHyLCrtdCO7imOwrSUcv51+Z8UudqfPpKQeszrJcntL4owip35r3sF5TsE9YfW5qssLC164IylvP32y1AcfL1jqg8b+zrqLZKanjvDOJ1dtHHuwKqxcwf7PhAf0YjAtVSH9OIYcDzmDa0EMLrq7EK0fs6NAeb5qt6CML7pZrRS3fmOxN53Fbmj81qm6TmjQjDe4dmZlELgNow=
34-
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TRAVIS_OS_NAME}.tar.gz
35-
# don't delete the artifacts from previous phases
36-
skip_cleanup: true
72+
- secure: cURRWBr034iqBz/ifD7uOunBfNR30YxIXfgLX0osWz+iafkVbhDGYYz9sBmRraqO2P7L2koEXMADVb/md1kI2+ykiq/ml+l9zuEAZPVmvSGUN7ZD+7s+lu3l5OBPG5z175T+b2q2q2m8XVR7TW20ra4QbE0bq06KAoOyjSgQVBTSCYsL9uTsGwiVRMEqqJT/BmKhKJNkpGsTKyBSKkOXvfeAAbE260vXUDEN9TYdJ3fvteRrpwLX56ee64gIZUq0RjDc4SKIEqilM6iUtNMvurqaewYNGkiXKRruV6BPCHxEHo6NNT46kOJLBJTf7gZw//dWhSoWpg9P0gdAnPWm407kSa3F7aJ1eRShAFQ4BLyfz9efTqm+jP3fOp7Mm7igSh9w6caSRuOnSsUf5+raRQ8E5Y9HsWGzzpZQk24Fx9EGZ04EeDSdpZAFz+jcbMpHf8t2p4CEx0CCNwYvKx6EydMKbMF5QteQ8SQkXNLhv7Rz2OgtXWYZPRVCMfQfOplsi2InsLCrQxTgwh+6u654SqVSgaHG+IncEAxBrdWy4rHcg7qereUcKfcY3k96vaDxdn/T2c00Ig0aNFR91YnixGMd6J6tQgDcRK9jh6fUm1CCBE9hT+pNUmtgYKuWBoLZexUZFFnfuBed0WciBot1bGDDamndqKq0jJiAzg+GMHk=
73+
file_glob: true
74+
file: "$CRATE_NAME-$TRAVIS_TAG-$TARGET.*"
3775
on:
38-
condition: $TRAVIS_RUST_VERSION = stable
76+
condition: "$TRAVIS_RUST_VERSION = stable"
3977
tags: true
78+
provider: releases
79+
skip_cleanup: true
80+
81+
branches:
82+
only:
83+
- "/^v\\d+\\.\\d+\\.\\d+.*$/"
84+
- master
4085

4186
notifications:
4287
email:

ci/before_deploy.sh

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1-
# `before_deploy` phase: here we package the build artifacts
1+
# This script takes care of building your crate and packaging it for release
22

33
set -ex
44

5-
mktempd() {
6-
echo $(mktemp -d 2>/dev/null || mktemp -d -t tmp)
7-
}
8-
9-
mk_artifacts() {
10-
cargo build --target $TARGET --release
11-
}
5+
main() {
6+
local src=$(pwd) \
7+
stage=
128

13-
mk_tarball() {
14-
local td=$(mktempd)
15-
local out_dir=$(pwd)
9+
case $TRAVIS_OS_NAME in
10+
linux)
11+
stage=$(mktemp -d)
12+
;;
13+
osx)
14+
stage=$(mktemp -d -t tmp)
15+
;;
16+
esac
1617

17-
cp target/$TARGET/release/mdbook $td
18+
test -f Cargo.lock || cargo generate-lockfile
1819

19-
pushd $td
20+
cross rustc --bin mdbook --target $TARGET --release -- -C lto
2021

21-
tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TRAVIS_OS_NAME}.tar.gz *
22+
cp target/$TARGET/release/mdbook $stage/
2223

23-
popd $td
24-
rm -r $td
25-
}
24+
cd $stage
25+
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
26+
cd $src
2627

27-
main() {
28-
mk_artifacts
29-
mk_tarball
28+
rm -rf $stage
3029
}
3130

32-
main
31+
main
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
#!/bin/bash
2+
# Deploys the `book-example` to GitHub Pages
23

3-
# Exit on error or variable unset
4-
set -o errexit -o nounset
4+
set -ex
5+
6+
# Only run this on the master branch for stable
7+
if [ "$TRAVIS_PULL_REQUEST" != "false" ] ||
8+
[ "$TRAVIS_BRANCH" != "master" ] ||
9+
[ "$TRAVIS_RUST_VERSION" != "stable" ]; then
10+
exit 0
11+
fi
12+
13+
# Make sure we have the css dependencies
14+
npm install stylus nib
515

616
NC='\033[39m'
717
CYAN='\033[36m'
@@ -10,23 +20,20 @@ GREEN='\033[32m'
1020
rev=$(git rev-parse --short HEAD)
1121

1222
echo -e "${CYAN}Running cargo doc${NC}"
13-
# Run cargo doc
14-
cargo doc
23+
cargo doc --features regenerate-css
1524

1625
echo -e "${CYAN}Running mdbook build${NC}"
17-
# Run mdbook to generate the book
1826
target/"$TARGET"/debug/mdbook build book-example/
1927

2028
echo -e "${CYAN}Copying book to target/doc${NC}"
21-
# Copy files from rendered book to doc root
2229
cp -R book-example/book/* target/doc/
2330

2431
cd target/doc
2532

2633
echo -e "${CYAN}Initializing Git${NC}"
2734
git init
28-
git config user.name "Mathieu David"
29-
git config user.email "[email protected]"
35+
git config user.name "Michael Bryan"
36+
git config user.email "[email protected]"
3037

3138
git remote add upstream "https://$GH_TOKEN@github.com/rust-lang-nursery/mdBook.git"
3239
git fetch upstream
@@ -39,4 +46,4 @@ git add -A .
3946
git commit -m "rebuild pages at ${rev}"
4047
git push -q upstream HEAD:gh-pages
4148

42-
echo -e "${GREEN}Deployement done${NC}"
49+
echo -e "${GREEN}Deployed docs to GitHub Pages${NC}"

ci/install.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
set -ex
2+
3+
main() {
4+
local target=
5+
if [ $TRAVIS_OS_NAME = linux ]; then
6+
target=x86_64-unknown-linux-musl
7+
sort=sort
8+
else
9+
target=x86_64-apple-darwin
10+
sort=gsort # for `sort --sort-version`, from brew's coreutils.
11+
fi
12+
13+
# Builds for iOS are done on OSX, but require the specific target to be
14+
# installed.
15+
case $TARGET in
16+
aarch64-apple-ios)
17+
rustup target install aarch64-apple-ios
18+
;;
19+
armv7-apple-ios)
20+
rustup target install armv7-apple-ios
21+
;;
22+
armv7s-apple-ios)
23+
rustup target install armv7s-apple-ios
24+
;;
25+
i386-apple-ios)
26+
rustup target install i386-apple-ios
27+
;;
28+
x86_64-apple-ios)
29+
rustup target install x86_64-apple-ios
30+
;;
31+
esac
32+
33+
# This fetches latest stable release
34+
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
35+
| cut -d/ -f3 \
36+
| grep -E '^v[0.1.0-9.]+$' \
37+
| $sort --version-sort \
38+
| tail -n1)
39+
curl -LSfs https://japaric.github.io/trust/install.sh | \
40+
sh -s -- \
41+
--force \
42+
--git japaric/cross \
43+
--tag $tag \
44+
--target $target
45+
}
46+
47+
main

ci/script.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This script takes care of testing your crate
2+
3+
set -ex
4+
5+
# TODO This is the "test phase", tweak it as you see fit
6+
main() {
7+
cross build --target $TARGET
8+
cross build --target $TARGET --release
9+
10+
if [ ! -z $DISABLE_TESTS ]; then
11+
return
12+
fi
13+
14+
cross test --target $TARGET
15+
cross test --target $TARGET --release
16+
}
17+
18+
# we don't run the "test phase" when doing deploys
19+
if [ -z $TRAVIS_TAG ]; then
20+
main
21+
fi

0 commit comments

Comments
 (0)