Skip to content

Commit 7f34512

Browse files
committed
Merge branch 'master' of https://github.com/azerupi/mdBook
2 parents 876ea78 + bea80f6 commit 7f34512

File tree

4 files changed

+125
-82
lines changed

4 files changed

+125
-82
lines changed

.travis.yml

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sudo: false
22

3-
language: rust
3+
language: generic
44

55
env:
66
global:
@@ -10,73 +10,59 @@ matrix:
1010
include:
1111
# Stable channel
1212
- os: osx
13-
env: TARGET=i686-apple-darwin
14-
rust: stable
13+
env: TARGET=i686-apple-darwin CHANNEL=stable
1514
- os: linux
16-
env: TARGET=i686-unknown-linux-gnu
17-
rust: stable
15+
env: TARGET=i686-unknown-linux-gnu CHANNEL=stable
1816
addons:
1917
apt:
2018
packages: &i686_unknown_linux_gnu
2119
- gcc-multilib
2220
- os: osx
23-
env: TARGET=x86_64-apple-darwin
24-
rust: stable
21+
env: TARGET=x86_64-apple-darwin CHANNEL=stable
2522
- os: linux
26-
env: TARGET=x86_64-unknown-linux-gnu
27-
rust: stable
23+
env: TARGET=x86_64-unknown-linux-gnu CHANNEL=stable
2824
addons:
2925
apt:
3026
packages:
3127
- nodejs
3228
- npm
3329
- os: linux
34-
env: TARGET=x86_64-unknown-linux-musl
35-
rust: stable
30+
env: TARGET=x86_64-unknown-linux-musl CHANNEL=stable
3631
# Beta channel
3732
- os: osx
38-
env: TARGET=i686-apple-darwin
39-
rust: beta
33+
env: TARGET=i686-apple-darwin CHANNEL=beta
4034
- os: linux
41-
env: TARGET=i686-unknown-linux-gnu
42-
rust: beta
35+
env: TARGET=i686-unknown-linux-gnu CHANNEL=beta
4336
addons:
4437
apt:
4538
packages: *i686_unknown_linux_gnu
4639
- os: osx
47-
env: TARGET=x86_64-apple-darwin
48-
rust: beta
40+
env: TARGET=x86_64-apple-darwin CHANNEL=beta
4941
- os: linux
50-
env: TARGET=x86_64-unknown-linux-gnu
51-
rust: beta
42+
env: TARGET=x86_64-unknown-linux-gnu CHANNEL=beta
5243
- os: linux
53-
env: TARGET=x86_64-unknown-linux-musl
54-
rust: beta
44+
env: TARGET=x86_64-unknown-linux-musl CHANNEL=beta
5545
# Nightly channel
5646
- os: osx
57-
env: TARGET=i686-apple-darwin
58-
rust: nightly
47+
env: TARGET=i686-apple-darwin CHANNEL=nightly
5948
- os: linux
60-
env: TARGET=i686-unknown-linux-gnu
61-
rust: nightly
49+
env: TARGET=i686-unknown-linux-gnu CHANNEL=nightly
6250
addons:
6351
apt:
6452
packages: *i686_unknown_linux_gnu
6553
- os: osx
66-
env: TARGET=x86_64-apple-darwin
67-
rust: nightly
54+
env: TARGET=x86_64-apple-darwin CHANNEL=nightly
6855
- os: linux
69-
env: TARGET=x86_64-unknown-linux-gnu
70-
rust: nightly
56+
env: TARGET=x86_64-unknown-linux-gnu CHANNEL=nightly
7157
- os: linux
72-
env: TARGET=x86_64-unknown-linux-musl
73-
rust: nightly
58+
env: TARGET=x86_64-unknown-linux-musl CHANNEL=nightly
7459

7560
install:
76-
- sh ci/install.sh
61+
- export PATH="$PATH:$HOME/.cargo/bin"
62+
- bash ci/install.sh
7763

7864
script:
79-
- sh ci/script.sh
65+
- bash ci/script.sh
8066

8167
after_success:
8268
- test $TRAVIS_PULL_REQUEST == "false" &&
@@ -87,7 +73,7 @@ after_success:
8773
bash deploy.sh
8874

8975
before_deploy:
90-
- sh ci/before_deploy.sh
76+
- bash ci/before_deploy.sh
9177

9278
deploy:
9379
provider: releases
@@ -98,7 +84,7 @@ deploy:
9884
skip_cleanup: true
9985
# deploy when a new tag is pushed
10086
on:
101-
condition: $TRAVIS_RUST_VERSION = stable
87+
condition: $CHANNEL = stable
10288
tags: true
10389

10490
notifications:

ci/before_deploy.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,31 @@
22

33
set -ex
44

5-
cargo build --target $TARGET --release
5+
mktempd() {
6+
echo $(mktemp -d 2>/dev/null || mktemp -d -t tmp)
7+
}
68

7-
mkdir staging
9+
mk_artifacts() {
10+
cargo build --target $TARGET --release
11+
}
812

9-
cp target/$TARGET/release/mdbook staging
13+
mk_tarball() {
14+
local td=$(mktempd)
15+
local out_dir=$(pwd)
1016

11-
cd staging
17+
cp target/$TARGET/release/mdbook $td
1218

13-
tar czf ../${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz *
19+
pushd $td
20+
21+
tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz *
22+
23+
popd $td
24+
rm -r $td
25+
}
26+
27+
main() {
28+
mk_artifacts
29+
mk_tarball
30+
}
31+
32+
main

ci/install.sh

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,57 @@
22

33
set -ex
44

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
5+
case "$TRAVIS_OS_NAME" in
6+
linux)
7+
host=x86_64-unknown-linux-gnu
298
;;
30-
# Nothing to do for native builds
31-
*)
9+
osx)
10+
host=x86_64-apple-darwin
3211
;;
3312
esac
13+
14+
mktempd() {
15+
echo $(mktemp -d 2>/dev/null || mktemp -d -t tmp)
16+
}
17+
18+
install_rustup() {
19+
local td=$(mktempd)
20+
21+
pushd $td
22+
curl -O https://static.rust-lang.org/rustup/dist/$host/rustup-setup
23+
chmod +x rustup-setup
24+
./rustup-setup -y
25+
popd
26+
27+
rm -r $td
28+
29+
rustup default $CHANNEL
30+
rustc -V
31+
cargo -V
32+
}
33+
34+
install_standard_crates() {
35+
if [ "$host" != "$TARGET" ]; then
36+
if [ ! "$CHANNEL" = "stable" ]; then
37+
rustup target add $TARGET
38+
else
39+
local version=$(rustc -V | cut -d' ' -f2)
40+
local tarball=rust-std-${version}-${TARGET}
41+
42+
local td=$(mktempd)
43+
curl -s https://static.rust-lang.org/dist/${tarball}.tar.gz | \
44+
tar --strip-components 1 -C $td -xz
45+
46+
$td/install.sh --prefix=$(rustc --print sysroot)
47+
48+
rm -r $td
49+
fi
50+
fi
51+
}
52+
53+
main() {
54+
install_rustup
55+
install_standard_crates
56+
}
57+
58+
main

ci/script.sh

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,36 @@
22

33
set -ex
44

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
5+
# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling
6+
# This has been fixed in the nightly channel but it would take a while to reach the other channels
7+
disable_cross_doctests() {
8+
local host
9+
case "$TRAVIS_OS_NAME" in
10+
linux)
11+
host=x86_64-unknown-linux-gnu
12+
;;
13+
osx)
14+
host=x86_64-apple-darwin
15+
;;
16+
esac
1317

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+
if [ "$host" != "$TARGET" ] && [ "$CHANNEL" != "nightly" ]; then
19+
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
20+
brew install gnu-sed --default-names
21+
fi
22+
23+
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g'
1824
fi
25+
}
26+
27+
run_test_suite() {
28+
cargo build --target $TARGET --verbose
29+
cargo test --target $TARGET --verbose
30+
}
1931

20-
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g'
21-
fi
32+
main() {
33+
disable_cross_doctests
34+
run_test_suite
35+
}
2236

23-
cargo build --target $TARGET --verbose
24-
cargo test --target $TARGET --verbose
37+
main

0 commit comments

Comments
 (0)