Skip to content

Commit 435db78

Browse files
committed
Update CI from japaric/rust-everywhere
1 parent 155971b commit 435db78

File tree

4 files changed

+133
-85
lines changed

4 files changed

+133
-85
lines changed

.travis.yml

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,97 @@
11
sudo: false
22

3-
language: rust
4-
5-
rust:
6-
- stable
7-
- beta
8-
- nightly
9-
10-
os:
11-
- linux
12-
- osx
3+
language: generic
134

145
env:
156
global:
167
# This will be part of the release tarball
178
- PROJECT_NAME=ilc
189

1910
matrix:
20-
allow_failures:
21-
- rust: beta
22-
- rust: nightly
23-
- os: osx
24-
25-
# Clear the whole matrix
26-
exclude:
27-
- os: linux
28-
- os: osx
29-
- rust: stable
30-
- rust: beta
31-
- rust: nightly
32-
33-
# Add each target manually
34-
# pattern shown below
3511
include:
36-
# WARNING Experimental target. Tests are executed using qemu user emulation, but this approach
37-
# may have problems when too many threads are spawned. Also, by the next Rust stable release,
38-
# this target will be replaced by `armv7-unknown-linux-gnueabihf`.
12+
# Stable channel
3913
- os: linux
40-
rust: nightly
41-
env: TARGET=arm-unknown-linux-gnueabihf
42-
# Extra packages only for this build job
14+
env: TARGET=arm-unknown-linux-gnueabihf CHANNEL=stable
15+
# Extra packages only for this job
4316
addons:
4417
apt:
45-
packages:
18+
packages: &arm_unknown_linux_gnueabihf
4619
# Cross compiler and cross compiled C libraries
4720
- gcc-arm-linux-gnueabihf
4821
- libc6-armhf-cross
4922
- libc6-dev-armhf-cross
5023
# Emulator
5124
- qemu-user
25+
- os: osx
26+
env: TARGET=i686-apple-darwin CHANNEL=stable
5227
- os: linux
53-
rust: stable
54-
env: TARGET=i686-unknown-linux-gnu
28+
env: TARGET=i686-unknown-linux-gnu CHANNEL=stable
5529
addons:
5630
apt:
57-
packages:
31+
packages: &i686_unknown_linux_gnu
5832
# Cross compiler and cross compiled C libraries
5933
- gcc-multilib
34+
- os: osx
35+
env: TARGET=x86_64-apple-darwin CHANNEL=stable
36+
- os: linux
37+
env: TARGET=x86_64-unknown-linux-gnu CHANNEL=stable
38+
- os: linux
39+
env: TARGET=x86_64-unknown-linux-musl CHANNEL=stable
40+
# Beta channel
41+
- os: linux
42+
env: TARGET=arm-unknown-linux-gnueabihf CHANNEL=beta
43+
addons:
44+
apt:
45+
# Use the same packages the stable version uses
46+
packages: *arm_unknown_linux_gnueabihf
47+
- os: osx
48+
env: TARGET=i686-apple-darwin CHANNEL=beta
49+
- os: linux
50+
env: TARGET=i686-unknown-linux-gnu CHANNEL=beta
51+
addons:
52+
apt:
53+
packages: *i686_unknown_linux_gnu
54+
- os: osx
55+
env: TARGET=x86_64-apple-darwin CHANNEL=beta
56+
- os: linux
57+
env: TARGET=x86_64-unknown-linux-gnu CHANNEL=beta
6058
- os: linux
61-
rust: stable
62-
env: TARGET=x86_64-unknown-linux-gnu
59+
env: TARGET=x86_64-unknown-linux-musl CHANNEL=beta
60+
# Nightly channel
6361
- os: linux
64-
rust: nightly
65-
env: TARGET=x86_64-unknown-linux-musl
62+
env: TARGET=arm-unknown-linux-gnueabihf CHANNEL=nightly
6663
addons:
6764
apt:
68-
packages:
69-
- musl-tools
65+
# Use the same packages the stable version uses
66+
packages: *arm_unknown_linux_gnueabihf
7067
- os: osx
71-
rust: stable
72-
env: TARGET=i686-apple-darwin
68+
env: TARGET=i686-apple-darwin CHANNEL=nightly
69+
- os: linux
70+
env: TARGET=i686-unknown-linux-gnu CHANNEL=nightly
71+
addons:
72+
apt:
73+
packages: *i686_unknown_linux_gnu
7374
- os: osx
74-
rust: stable
75-
env: TARGET=x86_64-apple-darwin
75+
env: TARGET=x86_64-apple-darwin CHANNEL=nightly
76+
- os: linux
77+
env: TARGET=x86_64-unknown-linux-gnu CHANNEL=nightly
78+
- os: linux
79+
env: TARGET=x86_64-unknown-linux-musl CHANNEL=nightly
80+
allow_failures:
81+
# NOTE This target appears to be broken on Rust 1.7.0
82+
# TODO You may want to remove this entry by the time Rust 1.8.0 is out
83+
- os: linux
84+
env: TARGET=arm-unknown-linux-gnueabihf CHANNEL=stable
7685

7786
install:
78-
- sh ci/install.sh
87+
- export PATH="$PATH:~/multirust/bin"
88+
- bash ci/install.sh
7989

8090
script:
81-
- sh ci/script.sh
91+
- bash ci/script.sh
8292

8393
before_deploy:
84-
- sh ci/before_deploy.sh
94+
- bash ci/before_deploy.sh
8595

8696
deploy:
8797
provider: releases
@@ -97,6 +107,7 @@ deploy:
97107
skip_cleanup: true
98108
# deploy when a new tag is pushed
99109
on:
110+
condition: $TRAVIS_RUST_VERSION = stable
100111
tags: true
101112

102113
branches:

ci/before_deploy.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
set -ex
44

5+
# Generate artifacts for release
6+
cargo build --target $TARGET --release
7+
58
# create a "staging" directory
69
mkdir staging
710

@@ -10,5 +13,5 @@ cp target/$TARGET/release/ilc* staging
1013

1114
cd staging
1215

13-
# release tarball will look like 'rust-everywhere-v1.2.3-x86_64-unknown-linux-gnu.tar.gz'
16+
# release tarball will look like 'ilc-unknown-linux-gnu.tar.gz'
1417
tar czf ../${PROJECT_NAME}-${TARGET}.tar.gz *

ci/install.sh

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

33
set -ex
44

5-
case $TARGET in
6-
# Install standard libraries needed for cross compilation
7-
arm-unknown-linux-gnueabihf | \
8-
i686-apple-darwin | \
9-
i686-unknown-linux-gnu | \
10-
x86_64-unknown-linux-musl)
11-
if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then
12-
# information about the cross compiler
13-
arm-linux-gnueabihf-gcc -v
14-
15-
# tell cargo which linker to use for cross compilation
16-
mkdir -p .cargo
17-
cat >.cargo/config <<EOF
5+
# Install multirust
6+
git clone https://github.com/brson/multirust
7+
pushd multirust
8+
./build.sh
9+
./install.sh --prefix=~/multirust
10+
multirust default $CHANNEL
11+
rustc -V
12+
cargo -V
13+
popd
14+
15+
case "$TRAVIS_OS_NAME" in
16+
linux)
17+
host=x86_64-unknown-linux-gnu
18+
;;
19+
osx)
20+
host=x86_64-apple-darwin
21+
;;
22+
esac
23+
24+
# Install standard libraries needed for cross compilation
25+
if [ "$host" != "$TARGET" ]; then
26+
if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then
27+
# information about the cross compiler
28+
arm-linux-gnueabihf-gcc -v
29+
30+
# tell cargo which linker to use for cross compilation
31+
mkdir -p .cargo
32+
cat >>.cargo/config <<EOF
1833
[target.$TARGET]
1934
linker = "arm-linux-gnueabihf-gcc"
2035
EOF
36+
fi
37+
38+
if [ "$CHANNEL" = "nightly" ]; then
39+
multirust add-target nightly $TARGET
40+
else
41+
if [ "$CHANNEL" = "stable" ]; then
42+
# e.g. 1.6.0
43+
version=$(rustc -V | cut -d' ' -f2)
44+
else
45+
version=beta
2146
fi
2247

23-
# e.g. 1.6.0
24-
# doesn't work for nightly
25-
# version=$(rustc -V | cut -d' ' -f2)
26-
version=$(rustc -V | cut -d' ' -f2 | cut -d'-' -f2)
27-
28-
if [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then
29-
version="nightly"
30-
fi
3148
tarball=rust-std-${version}-${TARGET}
3249

3350
curl -Os http://static.rust-lang.org/dist/${tarball}.tar.gz
@@ -38,10 +55,7 @@ EOF
3855

3956
rm -r ${tarball}
4057
rm ${tarball}.tar.gz
41-
;;
42-
# Nothing to do for native builds
43-
*)
44-
;;
45-
esac
58+
fi
59+
fi
4660

4761
# TODO if you need to install extra stuff add it here

ci/script.sh

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,55 @@
22

33
set -ex
44

5-
# TODO modify this phase as you see fit
65
# PROTIP Always pass `--target $TARGET` to cargo commands, this makes cargo output build artifacts
76
# to target/$TARGET/{debug,release} which can reduce the number of needed conditionals in the
87
# `before_deploy`/packaging phase
98

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
17+
18+
# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling
19+
# This has been fixed in the nightly channel but it would take a while to reach the other channels
20+
if [ "$host" != "$TARGET" ] && [ "$CHANNEL" != "nightly" ]; then
21+
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
22+
brew install gnu-sed --default-names
23+
fi
24+
25+
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g'
26+
fi
27+
1028
case $TARGET in
1129
# use an emulator to run the cross compiled binaries
1230
arm-unknown-linux-gnueabihf)
1331
# build tests but don't run them
14-
cargo test --target $TARGET --no-run
32+
# cargo test --target $TARGET --no-run
1533

1634
# run tests in emulator
17-
find target/$TARGET/debug -maxdepth 1 -executable -type f | \
18-
xargs qemu-arm -L /usr/arm-linux-gnueabihf
35+
# find target/$TARGET/debug -maxdepth 1 -executable -type f \
36+
# -exec qemu-arm -L /usr/arm-linux-gnueabihf '{}' ';'
1937

2038
# build the main executable
21-
cargo build --target $TARGET
39+
cargo build --target $TARGET --verbose
2240

23-
# run the main executable using the emulator
41+
# sanity check the file type
42+
file target/$TARGET/debug/ilc
2443
qemu-arm -L /usr/arm-linux-gnueabihf target/$TARGET/debug/ilc -V
2544
;;
2645
*)
2746
cargo build --target $TARGET --verbose
47+
48+
# sanity check the file type
49+
file target/$TARGET/debug/ilc
50+
target/$TARGET/debug/ilc -V
51+
2852
# this isn't even a temporary solution. :(
2953
# cargo test --target $TARGET --verbose
3054
;;
3155
esac
3256

33-
cargo build --target $TARGET --release
34-
35-
# sanity check the file type
36-
file target/$TARGET/release/ilc

0 commit comments

Comments
 (0)