Skip to content

Commit

Permalink
Add rust-everywhere travis scripts and config
Browse files Browse the repository at this point in the history
  • Loading branch information
eliihen committed May 30, 2016
1 parent 4057e3a commit b2025d1
Show file tree
Hide file tree
Showing 6 changed files with 478 additions and 0 deletions.
216 changes: 216 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
language: rust
cache: cargo

env:
global:
# This will be part of the release tarball
- PROJECT_NAME=wsta
# - MAKE_DEB=yes
# - DEB_MAINTAINER="Jorge Aparicio <[email protected]>"
# - DEB_DESCRIPTION="Hello, world! written in Rust"

# AFAICT There are a few ways to set up the build jobs. This one is not the DRYest but I feel is the
# easiest to reason about.
# NOTE Make *sure* you don't remove a reference (&foo) if you are going to dereference it (*foo)
matrix:
include:
# Stable channel
# TODO Uncomment stable channel when cargo 0.10 is stable
# - os: linux
# rust: stable
# env: TARGET=aarch64-unknown-linux-gnu
# # need Trusty because the glibc in Precise is too old and doesn't support 64-bit arm
# dist: trusty
# sudo: required
# # Extra packages only for this job
# addons:
# apt:
# packages: &aarch64_unknown_linux_gnu
# # Transparent emulation
# - qemu-user-static
# - binfmt-support
# - os: linux
# rust: stable
# env: TARGET=armv7-unknown-linux-gnueabihf
# # sudo is needed for binfmt_misc, which is needed for transparent user qemu emulation
# sudo: required
# addons:
# apt:
# packages: &armv7_unknown_linux_gnueabihf
# # Cross compiler and cross compiled C libraries
# - gcc-arm-linux-gnueabihf
# - libc6-armhf-cross
# - libc6-dev-armhf-cross
# # Transparent emulation
# - qemu-user-static
# - binfmt-support
# - os: osx
# rust: stable
# env: TARGET=i686-apple-darwin
# - os: linux
# rust: stable
# env: TARGET=i686-unknown-linux-gnu
# sudo: required
# addons:
# apt:
# packages: &i686_unknown_linux_gnu
# # Cross compiler and cross compiled C libraries
# - gcc-multilib
# - os: linux
# rust: stable
# env: TARGET=i686-unknown-linux-musl
# sudo: required
# - os: osx
# rust: stable
# env: TARGET=x86_64-apple-darwin
# - os: linux
# rust: stable
# env: TARGET=x86_64-unknown-linux-gnu
# sudo: required
# - os: linux
# rust: stable
# env: TARGET=x86_64-unknown-linux-musl
# sudo: required
# Beta channel
- os: linux
rust: beta
env: TARGET=aarch64-unknown-linux-gnu
dist: trusty
sudo: required
addons:
apt:
packages: &aarch64_unknown_linux_gnu
# Transparent emulation
- qemu-user-static
- binfmt-support
- os: linux
rust: beta
env: TARGET=armv7-unknown-linux-gnueabihf
dist: trusty
sudo: required
addons:
apt:
# Use the same packages the stable version uses
packages: &armv7_unknown_linux_gnueabihf
# Transparent emulation
- qemu-user-static
- binfmt-support
- os: osx
rust: beta
env: TARGET=i686-apple-darwin
- os: linux
rust: beta
env: TARGET=i686-unknown-linux-gnu
sudo: required
addons:
apt:
packages: &i686_unknown_linux_gnu
# Cross compiler and cross compiled C libraries
- gcc-multilib
- os: linux
rust: beta
env: TARGET=i686-unknown-linux-musl
sudo: required
- os: osx
rust: beta
env: TARGET=x86_64-apple-darwin
- os: linux
rust: beta
env: TARGET=x86_64-unknown-linux-gnu
sudo: required
- os: linux
rust: beta
env: TARGET=x86_64-unknown-linux-musl
sudo: required
# Nightly channel
- os: linux
rust: nightly
env: TARGET=aarch64-unknown-linux-gnu
dist: trusty
sudo: required
addons:
apt:
packages: *aarch64_unknown_linux_gnu
- os: linux
rust: nightly
env: TARGET=armv7-unknown-linux-gnueabihf
dist: trusty
sudo: required
addons:
apt:
# Use the same packages the stable version uses
packages: *armv7_unknown_linux_gnueabihf
- os: osx
rust: nightly
env: TARGET=i686-apple-darwin
- os: linux
rust: nightly
env: TARGET=i686-unknown-linux-gnu
sudo: required
addons:
apt:
packages: *i686_unknown_linux_gnu
- os: linux
rust: nightly
env: TARGET=i686-unknown-linux-musl
sudo: required
- os: osx
rust: nightly
env: TARGET=x86_64-apple-darwin
- os: linux
rust: nightly
env: TARGET=x86_64-unknown-linux-gnu
sudo: required
- os: linux
rust: nightly
env: TARGET=x86_64-unknown-linux-musl
sudo: required
allow_failures:
# Target `i686-unknown-linux-musl` is currently only available on the nightly channel
# - os: linux
# rust: stable
# env: TARGET=i686-unknown-linux-musl
- os: linux
rust: beta
env: TARGET=i686-unknown-linux-musl

before_install:
- export PATH="$PATH:$HOME/.cargo/bin"

install:
- bash ci/install.sh

script:
- bash ci/script.sh

before_deploy:
- bash ci/before_deploy.sh

deploy:
provider: releases
# Encrypted API key using travis cli's encrypt
api_key:
secure: "HGVJap2744AiiqYP9A4bSwKU0UmB9yfOE6i77Fj4Y7f9HMYDBsC8P63AXt0ixXo1mEsWTjVtEZPNjAt1daxURc06xT3RkUw+BldJ/XhG4O1Tei9i0aVIB6t82HLnuvi89FFRJSdWkNMeKWoTh/Q/6c6aBuCmQzb8QGyne6MGXiDLV8z9hTIefTTfyAxjFY/25aPy/isvidVvdxU1SY+IBOnYAxYRmXFQLjDIn0pEu7j2cYw8ub0CGqRLfdoXfwCs0cgVx9Ikjy8x4CoUrxnKps+RSMt/uCZPrb1lMxgR0Bzv82K9TEY7nItn0pr5IilLj6aFZ+0k79VKse77S9st/vEmdxB8CCFOjL/GRnq+6BqFgZqZJVe25lgUwvzNfuidCo0uF4qlKNAi9bX9I0w6KTDkmRlWGb8nKcX2fxBfdb4ePt3RANdK7ZOMT3Brmxn+TjgFKOktkRNDVsIDO2cKUpXOlGyygjnZC5MyvoXov8mBvq5mywpFCozTYEZIciSLfyFC7TNgciWbEzEy9IOeQ73X0OGSvMNsxH05J8r7pZTzDnunhwPTEHG4wUcnQpqOf16lv5LQn8z/wIZ8nszLP0JlE0zz6Rq8Gn/8193v0ykqlHAAqV8isbvNHad1yksgMueHReEgqz8dDpaCsG0VkPq6FIi5sTDKjkruAkH1NyA="
file_glob: true
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.*
# don't delete the artifacts from previous phases
skip_cleanup: true
# deploy when a new tag is pushed
on:
# channel to use to produce the release artifacts
# NOTE make sure you only release *once* per target
condition: $TRAVIS_RUST_VERSION = beta
tags: true

branches:
only:
# Pushes and PR to the master branch
- master
- rust-everywhere
# IMPORTANT Ruby regex to match tags. Required, or travis won't trigger deploys when a new tag
# is pushed. This regex matches semantic versions like v1.2.3-rc4+2016.02.22
- /^\d+\.\d+\.\d+.*$/

notifications:
email:
on_success: never
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

The WebSocket Transfer Agent

[![Build Status](https://travis-ci.org/esphen/wsta.svg?branch=rust-everywhere)](https://travis-ci.org/esphen/wsta)

`wsta` is a cli tool written in rust for interfacing with WebSockets. `wsta` has
the philosophy of being an easy tool to learn and thus gets out of your way to
let you work your UNIX magic directly on the WebSocket traffic.
Expand Down
66 changes: 66 additions & 0 deletions ci/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# `before_deploy` phase: here we package the build artifacts

set -ex

. $(dirname $0)/utils.sh

# Generate artifacts for release
mk_artifacts() {
cargo build --target $TARGET --release
}

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/wsta $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() {
dobin target/$TARGET/release/wsta
}

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
81 changes: 81 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# `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
;;
armv7-unknown-linux-gnueabihf)
sudo apt-get install -y --no-install-recommends \
gcc-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-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

case "$TRAVIS_OS_NAME" in
linux)
# libssl-dev is in backports for ARM
if [[ "$(architecture $TARGET)" == arm* ]]; then

sudo sh -c 'echo "deb [arch=arm64,armhf] http://ports.ubuntu.com trusty main universe" >> /etc/apt/sources.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551
fi

sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
"libssl-dev:$(architecture $TARGET)" gcc-multilib
;;
osx)
brew update
brew install openssl
;;
esac
}

main
Loading

0 comments on commit b2025d1

Please sign in to comment.