Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #58 - indiv0:chore-fix-travis-ci, r=indiv0
Update Travis CI Configuration # Status * [x] Enable Travis CI builds on rustc nightly, beta, and stable * [x] Add `travis-cargo` support * [ ] Ensure Travis CI performs the following operations: * [x] build * [x] test * [x] bench * [ ] doc-upload * [ ] coveralls code checking * [ ] automated build artifact deployment (#11) * [x] Update `README.md` * [x] Update building instructions * [x] Add information on pre-compiled binaries * [x] Update the badges * [x] API Docs * [x] Travis CI * [x] crates.io * [x] coveralls.io * [ ] ..? # Related Issues * #3 * #7 * #10 * #11 * #16 * #49
- Loading branch information
Showing
6 changed files
with
413 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,134 @@ | ||
sudo: false | ||
language: rust | ||
os: | ||
- linux | ||
- osx | ||
cache: cargo | ||
|
||
env: | ||
global: | ||
# this will be part of the release tarball | ||
- PROJECT_NAME=colonize | ||
- RUST_BACKTRACE=1 | ||
# override the default '--features unstable' used for the nightly branch | ||
- TRAVIS_CARGO_NIGHTLY_FEATURE="nightly-testing" | ||
# encrypted Github token for doc upload | ||
- secure: "OtcCEFBniy4i89KaFKEOct+JsTQF3W3+6SYWlcB4FEvljRwwpAMWzpqoHQhfNLPQiX07Da+IlKrhM5wt2PPF80dEzyIxiK6Y/fJFgd0peAkbKYwqrgoS80WoqSHYBR8STb+X6JlhxxX+/pma+ILBBFQ6UH01KEHGISlHq4ARw58=" | ||
# the following are necessary for `travis-cargo coveralls --no-sudo` | ||
addons: | ||
apt: | ||
packages: | ||
- libcurl4-openssl-dev | ||
- libelf-dev | ||
- libdw-dev | ||
- binutils-dev # optional: only required for the --verify flag of coveralls | ||
|
||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
- rust: nightly | ||
include: | ||
# stable channel | ||
- os: osx | ||
rust: stable | ||
env: TARGET=i686-apple-darwin | ||
- os: linux | ||
rust: stable | ||
env: TARGET=i686-unknown-linux-gnu | ||
addons: | ||
apt: | ||
packages: &i686_unknown_linux_gnu | ||
# Cross compiler and cross compiled C libraries | ||
- gcc-multilib | ||
# freetype library | ||
- libfreetype6-dev:i386 | ||
- os: linux | ||
rust: stable | ||
env: TARGET=x86_64-unknown-linux-gnu | ||
# beta channel | ||
- os: osx | ||
rust: beta | ||
env: TARGET=i686-apple-darwin | ||
- os: linux | ||
rust: beta | ||
env: TARGET=i686-unknown-linux-gnu | ||
addons: | ||
apt: | ||
packages: *i686_unknown_linux_gnu | ||
- os: linux | ||
rust: beta | ||
env: TARGET=x86_64-unknown-linux-gnu | ||
# nightly channel | ||
- os: osx | ||
rust: nightly | ||
env: TARGET=i686-apple-darwin | ||
- os: linux | ||
rust: nightly | ||
env: TARGET=i686-unknown-linux-gnu | ||
addons: | ||
apt: | ||
packages: *i686_unknown_linux_gnu | ||
- os: linux | ||
rust: nightly | ||
env: TARGET=x86_64-unknown-linux-gnu | ||
|
||
before_install: | ||
- | | ||
export PATH="$PATH:$HOME/.cargo/bin" | ||
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then | ||
brew update && | ||
brew install freetype | ||
fi | ||
install: | ||
- sudo apt-get update | ||
- sudo apt-get install gcc g++ make upx electric-fence libsdl1.2-dev mercurial | ||
- bash ci/install.sh | ||
|
||
before_script: | ||
# load travis-cargo | ||
- | | ||
pip install 'travis-cargo<0.2' --user && | ||
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then | ||
export PATH=$HOME/.local/bin/:$PATH | ||
else | ||
export PATH=$HOME/Library/Python/2.7/bin:$PATH | ||
fi | ||
# the main build | ||
script: | ||
- cargo build -v | ||
- bash ci/script.sh | ||
|
||
after_success: | ||
# upload the documentation from the build with stable (automatically only | ||
# actually runs from the master branch, not individual PRs) | ||
- travis-cargo --only stable doc-upload | ||
# measure code coverage and upload to coveralls.io (the verify argument | ||
# mitigates kcov crashes due to malformed debuginfo, at the cost of some | ||
# speed. <https://github.com/huonw/travis-cargo/issues/12>) | ||
- travis-cargo coveralls --no-sudo --verify | ||
|
||
before_deploy: | ||
- bash ci/before_deploy.sh | ||
|
||
deploy: | ||
provider: releases | ||
api_key: | ||
# secure Github token for release upload | ||
secure: "OtcCEFBniy4i89KaFKEOct+JsTQF3W3+6SYWlcB4FEvljRwwpAMWzpqoHQhfNLPQiX07Da+IlKrhM5wt2PPF80dEzyIxiK6Y/fJFgd0peAkbKYwqrgoS80WoqSHYBR8STb+X6JlhxxX+/pma+ILBBFQ6UH01KEHGISlHq4ARw58=" | ||
file_glob: true | ||
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.* | ||
# don't delete the artifacts from previous phases | ||
skip_cleanup: true | ||
on: | ||
# channel to use to produce the release artifacts | ||
condition: $TRAVIS_RUST_VERSION = stable | ||
tags: true | ||
|
||
branches: | ||
only: | ||
- master | ||
- auto | ||
# Ruby regex to match tags. Required to Travis won't trigger deploys when a | ||
# new tag is pushed. This regex matches semantic versions like | ||
# v1.2.3-rc4+2016.02.22 | ||
- /^v\d+\.\d+\.\d+.*$/ | ||
|
||
notifications: | ||
email: | ||
on_success: never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# `before_deploy` phase: here we package the build artifacts | ||
|
||
set -ex | ||
|
||
. $(dirname $0)/utils.sh | ||
|
||
# Generate artifacts for release | ||
mk_artifacts() { | ||
cargo rustc --target $TARGET --release -- -C link_args="-s" -C opt-level=3 | ||
} | ||
|
||
mk_tarball() { | ||
# create a "staging" directory | ||
local td=$(mktempd) | ||
local out_dir=$(pwd) | ||
|
||
# NOTE All Cargo build artifacts will be under the 'target/$TARGET/{debug,release}' | ||
cp target/$TARGET/release/colonize $td | ||
|
||
pushd $td | ||
|
||
# release tarball will look like 'rust-everywhere-v1.2.3-x86_64-unknown-linux-gnu.tar.gz' | ||
tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz * | ||
|
||
popd | ||
rm -r $td | ||
} | ||
|
||
# Package your artifacts in a .deb file | ||
# NOTE right now you can only package binaries using the `dobin` command. Simply call | ||
# `dobin [file..]` to include one or more binaries in your .deb package. I'll add more commands to | ||
# install other things like manpages (`doman`) as the needs arise. | ||
# XXX This .deb packaging is minimal -- just to make your app installable via `dpkg` -- and doesn't | ||
# fully conform to Debian packaging guideliens (`lintian` raises a few warnings/errors) | ||
mk_deb() { | ||
# TODO update this part to package the artifacts that make sense for your project | ||
dobin target/$TARGET/release/colonize | ||
} | ||
|
||
main() { | ||
mk_artifacts | ||
mk_tarball | ||
|
||
if [ $TRAVIS_OS_NAME = linux ]; then | ||
if [ ! -z $MAKE_DEB ]; then | ||
dtd=$(mktempd) | ||
mkdir -p $dtd/debian/usr/bin | ||
|
||
mk_deb | ||
|
||
mkdir -p $dtd/debian/DEBIAN | ||
cat >$dtd/debian/DEBIAN/control <<EOF | ||
Package: $PROJECT_NAME | ||
Version: ${TRAVIS_TAG#v} | ||
Architecture: $(architecture $TARGET) | ||
Maintainer: $DEB_MAINTAINER | ||
Description: $DEB_DESCRIPTION | ||
EOF | ||
|
||
fakeroot dpkg-deb --build $dtd/debian | ||
mv $dtd/debian.deb $PROJECT_NAME-$TRAVIS_TAG-$TARGET.deb | ||
rm -r $dtd | ||
fi | ||
fi | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# `install` phase: install stuff needed for the `script` phase | ||
|
||
set -ex | ||
|
||
. $(dirname $0)/utils.sh | ||
|
||
install_c_toolchain() { | ||
case $TARGET in | ||
aarch64-unknown-linux-gnu) | ||
sudo apt-get install -y --no-install-recommends \ | ||
gcc-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross | ||
;; | ||
*) | ||
# For other targets, this is handled by addons.apt.packages in .travis.yml | ||
;; | ||
esac | ||
} | ||
|
||
install_rustup() { | ||
# uninstall the rust toolchain installed by travis, we are going to use rustup | ||
sh ~/rust/lib/rustlib/uninstall.sh | ||
|
||
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TRAVIS_RUST_VERSION | ||
|
||
rustc -V | ||
cargo -V | ||
} | ||
|
||
install_standard_crates() { | ||
if [ $(host) != "$TARGET" ]; then | ||
rustup target add $TARGET | ||
fi | ||
} | ||
|
||
configure_cargo() { | ||
local prefix=$(gcc_prefix) | ||
|
||
if [ ! -z $prefix ]; then | ||
# information about the cross compiler | ||
${prefix}gcc -v | ||
|
||
# tell cargo which linker to use for cross compilation | ||
mkdir -p .cargo | ||
cat >>.cargo/config <<EOF | ||
[target.$TARGET] | ||
linker = "${prefix}gcc" | ||
EOF | ||
fi | ||
} | ||
|
||
main() { | ||
install_c_toolchain | ||
install_rustup | ||
install_standard_crates | ||
configure_cargo | ||
|
||
# TODO if you need to install extra stuff add it here | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# `script` phase: you usually build, test and generate docs in this phase | ||
|
||
set -ex | ||
|
||
. $(dirname $0)/utils.sh | ||
|
||
# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling | ||
# This has been fixed in the nightly channel but it would take a while to reach the other channels | ||
disable_cross_doctests() { | ||
if [ $(host) != "$TARGET" ] && [ "$TRAVIS_RUST_VERSION" = "stable" ]; then | ||
if [ "$TRAVIS_OS_NAME" = "osx" ]; then | ||
brew install gnu-sed --default-names | ||
fi | ||
|
||
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g' | ||
fi | ||
} | ||
|
||
# PROTIP Always pass `--target $TARGET` to cargo commands, this makes cargo output build artifacts | ||
# to target/$TARGET/{debug,release} which can reduce the number of needed conditionals in the | ||
# `before_deploy`/packaging phase | ||
run_test_suite() { | ||
case $TARGET in | ||
# configure emulation for transparent execution of foreign binaries | ||
aarch64-unknown-linux-gnu) | ||
export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu | ||
;; | ||
arm*-unknown-linux-gnueabihf) | ||
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf | ||
;; | ||
*) | ||
;; | ||
esac | ||
|
||
if [ ! -z "$QEMU_LD_PREFIX" ]; then | ||
# Run tests on a single thread when using QEMU user emulation | ||
export RUST_TEST_THREADS=1 | ||
fi | ||
|
||
if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then | ||
travis-cargo build -- --target $TARGET --no-default-features | ||
else | ||
travis-cargo build -- --target $TARGET | ||
fi && | ||
if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then | ||
travis-cargo test -- --target $TARGET --no-default-features | ||
else | ||
travis-cargo test -- --target $TARGET | ||
fi && | ||
if [[ "$TRAVIS_RUST_VERSION" == nightly* ]]; then | ||
travis-cargo bench -- --target $TARGET --no-default-features | ||
else | ||
travis-cargo bench -- --target $TARGET | ||
fi && | ||
travis-cargo --only stable doc -- --target $TARGET | ||
|
||
# sanity check the file type | ||
file target/$TARGET/debug/colonize | ||
} | ||
|
||
main() { | ||
disable_cross_doctests | ||
run_test_suite | ||
} | ||
|
||
main |
Oops, something went wrong.