Skip to content

Commit b2025d1

Browse files
committed
Add rust-everywhere travis scripts and config
1 parent 4057e3a commit b2025d1

File tree

6 files changed

+478
-0
lines changed

6 files changed

+478
-0
lines changed

.travis.yml

+216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
language: rust
2+
cache: cargo
3+
4+
env:
5+
global:
6+
# This will be part of the release tarball
7+
- PROJECT_NAME=wsta
8+
# - MAKE_DEB=yes
9+
# - DEB_MAINTAINER="Jorge Aparicio <[email protected]>"
10+
# - DEB_DESCRIPTION="Hello, world! written in Rust"
11+
12+
# AFAICT There are a few ways to set up the build jobs. This one is not the DRYest but I feel is the
13+
# easiest to reason about.
14+
# NOTE Make *sure* you don't remove a reference (&foo) if you are going to dereference it (*foo)
15+
matrix:
16+
include:
17+
# Stable channel
18+
# TODO Uncomment stable channel when cargo 0.10 is stable
19+
# - os: linux
20+
# rust: stable
21+
# env: TARGET=aarch64-unknown-linux-gnu
22+
# # need Trusty because the glibc in Precise is too old and doesn't support 64-bit arm
23+
# dist: trusty
24+
# sudo: required
25+
# # Extra packages only for this job
26+
# addons:
27+
# apt:
28+
# packages: &aarch64_unknown_linux_gnu
29+
# # Transparent emulation
30+
# - qemu-user-static
31+
# - binfmt-support
32+
# - os: linux
33+
# rust: stable
34+
# env: TARGET=armv7-unknown-linux-gnueabihf
35+
# # sudo is needed for binfmt_misc, which is needed for transparent user qemu emulation
36+
# sudo: required
37+
# addons:
38+
# apt:
39+
# packages: &armv7_unknown_linux_gnueabihf
40+
# # Cross compiler and cross compiled C libraries
41+
# - gcc-arm-linux-gnueabihf
42+
# - libc6-armhf-cross
43+
# - libc6-dev-armhf-cross
44+
# # Transparent emulation
45+
# - qemu-user-static
46+
# - binfmt-support
47+
# - os: osx
48+
# rust: stable
49+
# env: TARGET=i686-apple-darwin
50+
# - os: linux
51+
# rust: stable
52+
# env: TARGET=i686-unknown-linux-gnu
53+
# sudo: required
54+
# addons:
55+
# apt:
56+
# packages: &i686_unknown_linux_gnu
57+
# # Cross compiler and cross compiled C libraries
58+
# - gcc-multilib
59+
# - os: linux
60+
# rust: stable
61+
# env: TARGET=i686-unknown-linux-musl
62+
# sudo: required
63+
# - os: osx
64+
# rust: stable
65+
# env: TARGET=x86_64-apple-darwin
66+
# - os: linux
67+
# rust: stable
68+
# env: TARGET=x86_64-unknown-linux-gnu
69+
# sudo: required
70+
# - os: linux
71+
# rust: stable
72+
# env: TARGET=x86_64-unknown-linux-musl
73+
# sudo: required
74+
# Beta channel
75+
- os: linux
76+
rust: beta
77+
env: TARGET=aarch64-unknown-linux-gnu
78+
dist: trusty
79+
sudo: required
80+
addons:
81+
apt:
82+
packages: &aarch64_unknown_linux_gnu
83+
# Transparent emulation
84+
- qemu-user-static
85+
- binfmt-support
86+
- os: linux
87+
rust: beta
88+
env: TARGET=armv7-unknown-linux-gnueabihf
89+
dist: trusty
90+
sudo: required
91+
addons:
92+
apt:
93+
# Use the same packages the stable version uses
94+
packages: &armv7_unknown_linux_gnueabihf
95+
# Transparent emulation
96+
- qemu-user-static
97+
- binfmt-support
98+
- os: osx
99+
rust: beta
100+
env: TARGET=i686-apple-darwin
101+
- os: linux
102+
rust: beta
103+
env: TARGET=i686-unknown-linux-gnu
104+
sudo: required
105+
addons:
106+
apt:
107+
packages: &i686_unknown_linux_gnu
108+
# Cross compiler and cross compiled C libraries
109+
- gcc-multilib
110+
- os: linux
111+
rust: beta
112+
env: TARGET=i686-unknown-linux-musl
113+
sudo: required
114+
- os: osx
115+
rust: beta
116+
env: TARGET=x86_64-apple-darwin
117+
- os: linux
118+
rust: beta
119+
env: TARGET=x86_64-unknown-linux-gnu
120+
sudo: required
121+
- os: linux
122+
rust: beta
123+
env: TARGET=x86_64-unknown-linux-musl
124+
sudo: required
125+
# Nightly channel
126+
- os: linux
127+
rust: nightly
128+
env: TARGET=aarch64-unknown-linux-gnu
129+
dist: trusty
130+
sudo: required
131+
addons:
132+
apt:
133+
packages: *aarch64_unknown_linux_gnu
134+
- os: linux
135+
rust: nightly
136+
env: TARGET=armv7-unknown-linux-gnueabihf
137+
dist: trusty
138+
sudo: required
139+
addons:
140+
apt:
141+
# Use the same packages the stable version uses
142+
packages: *armv7_unknown_linux_gnueabihf
143+
- os: osx
144+
rust: nightly
145+
env: TARGET=i686-apple-darwin
146+
- os: linux
147+
rust: nightly
148+
env: TARGET=i686-unknown-linux-gnu
149+
sudo: required
150+
addons:
151+
apt:
152+
packages: *i686_unknown_linux_gnu
153+
- os: linux
154+
rust: nightly
155+
env: TARGET=i686-unknown-linux-musl
156+
sudo: required
157+
- os: osx
158+
rust: nightly
159+
env: TARGET=x86_64-apple-darwin
160+
- os: linux
161+
rust: nightly
162+
env: TARGET=x86_64-unknown-linux-gnu
163+
sudo: required
164+
- os: linux
165+
rust: nightly
166+
env: TARGET=x86_64-unknown-linux-musl
167+
sudo: required
168+
allow_failures:
169+
# Target `i686-unknown-linux-musl` is currently only available on the nightly channel
170+
# - os: linux
171+
# rust: stable
172+
# env: TARGET=i686-unknown-linux-musl
173+
- os: linux
174+
rust: beta
175+
env: TARGET=i686-unknown-linux-musl
176+
177+
before_install:
178+
- export PATH="$PATH:$HOME/.cargo/bin"
179+
180+
install:
181+
- bash ci/install.sh
182+
183+
script:
184+
- bash ci/script.sh
185+
186+
before_deploy:
187+
- bash ci/before_deploy.sh
188+
189+
deploy:
190+
provider: releases
191+
# Encrypted API key using travis cli's encrypt
192+
api_key:
193+
secure: "HGVJap2744AiiqYP9A4bSwKU0UmB9yfOE6i77Fj4Y7f9HMYDBsC8P63AXt0ixXo1mEsWTjVtEZPNjAt1daxURc06xT3RkUw+BldJ/XhG4O1Tei9i0aVIB6t82HLnuvi89FFRJSdWkNMeKWoTh/Q/6c6aBuCmQzb8QGyne6MGXiDLV8z9hTIefTTfyAxjFY/25aPy/isvidVvdxU1SY+IBOnYAxYRmXFQLjDIn0pEu7j2cYw8ub0CGqRLfdoXfwCs0cgVx9Ikjy8x4CoUrxnKps+RSMt/uCZPrb1lMxgR0Bzv82K9TEY7nItn0pr5IilLj6aFZ+0k79VKse77S9st/vEmdxB8CCFOjL/GRnq+6BqFgZqZJVe25lgUwvzNfuidCo0uF4qlKNAi9bX9I0w6KTDkmRlWGb8nKcX2fxBfdb4ePt3RANdK7ZOMT3Brmxn+TjgFKOktkRNDVsIDO2cKUpXOlGyygjnZC5MyvoXov8mBvq5mywpFCozTYEZIciSLfyFC7TNgciWbEzEy9IOeQ73X0OGSvMNsxH05J8r7pZTzDnunhwPTEHG4wUcnQpqOf16lv5LQn8z/wIZ8nszLP0JlE0zz6Rq8Gn/8193v0ykqlHAAqV8isbvNHad1yksgMueHReEgqz8dDpaCsG0VkPq6FIi5sTDKjkruAkH1NyA="
194+
file_glob: true
195+
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.*
196+
# don't delete the artifacts from previous phases
197+
skip_cleanup: true
198+
# deploy when a new tag is pushed
199+
on:
200+
# channel to use to produce the release artifacts
201+
# NOTE make sure you only release *once* per target
202+
condition: $TRAVIS_RUST_VERSION = beta
203+
tags: true
204+
205+
branches:
206+
only:
207+
# Pushes and PR to the master branch
208+
- master
209+
- rust-everywhere
210+
# IMPORTANT Ruby regex to match tags. Required, or travis won't trigger deploys when a new tag
211+
# is pushed. This regex matches semantic versions like v1.2.3-rc4+2016.02.22
212+
- /^\d+\.\d+\.\d+.*$/
213+
214+
notifications:
215+
email:
216+
on_success: never

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
The WebSocket Transfer Agent
44

5+
[![Build Status](https://travis-ci.org/esphen/wsta.svg?branch=rust-everywhere)](https://travis-ci.org/esphen/wsta)
6+
57
`wsta` is a cli tool written in rust for interfacing with WebSockets. `wsta` has
68
the philosophy of being an easy tool to learn and thus gets out of your way to
79
let you work your UNIX magic directly on the WebSocket traffic.

ci/before_deploy.sh

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# `before_deploy` phase: here we package the build artifacts
2+
3+
set -ex
4+
5+
. $(dirname $0)/utils.sh
6+
7+
# Generate artifacts for release
8+
mk_artifacts() {
9+
cargo build --target $TARGET --release
10+
}
11+
12+
mk_tarball() {
13+
# create a "staging" directory
14+
local td=$(mktempd)
15+
local out_dir=$(pwd)
16+
17+
# NOTE All Cargo build artifacts will be under the 'target/$TARGET/{debug,release}'
18+
cp target/$TARGET/release/wsta $td
19+
20+
pushd $td
21+
22+
# release tarball will look like 'rust-everywhere-v1.2.3-x86_64-unknown-linux-gnu.tar.gz'
23+
tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz *
24+
25+
popd
26+
rm -r $td
27+
}
28+
29+
# Package your artifacts in a .deb file
30+
# NOTE right now you can only package binaries using the `dobin` command. Simply call
31+
# `dobin [file..]` to include one or more binaries in your .deb package. I'll add more commands to
32+
# install other things like manpages (`doman`) as the needs arise.
33+
# XXX This .deb packaging is minimal -- just to make your app installable via `dpkg` -- and doesn't
34+
# fully conform to Debian packaging guideliens (`lintian` raises a few warnings/errors)
35+
mk_deb() {
36+
dobin target/$TARGET/release/wsta
37+
}
38+
39+
main() {
40+
mk_artifacts
41+
mk_tarball
42+
43+
if [ $TRAVIS_OS_NAME = linux ]; then
44+
if [ ! -z $MAKE_DEB ]; then
45+
dtd=$(mktempd)
46+
mkdir -p $dtd/debian/usr/bin
47+
48+
mk_deb
49+
50+
mkdir -p $dtd/debian/DEBIAN
51+
cat >$dtd/debian/DEBIAN/control <<EOF
52+
Package: $PROJECT_NAME
53+
Version: ${TRAVIS_TAG#v}
54+
Architecture: $(architecture $TARGET)
55+
Maintainer: $DEB_MAINTAINER
56+
Description: $DEB_DESCRIPTION
57+
EOF
58+
59+
fakeroot dpkg-deb --build $dtd/debian
60+
mv $dtd/debian.deb $PROJECT_NAME-$TRAVIS_TAG-$TARGET.deb
61+
rm -r $dtd
62+
fi
63+
fi
64+
}
65+
66+
main

ci/install.sh

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# `install` phase: install stuff needed for the `script` phase
2+
3+
set -ex
4+
5+
. $(dirname $0)/utils.sh
6+
7+
install_c_toolchain() {
8+
case $TARGET in
9+
aarch64-unknown-linux-gnu)
10+
sudo apt-get install -y --no-install-recommends \
11+
gcc-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross
12+
;;
13+
armv7-unknown-linux-gnueabihf)
14+
sudo apt-get install -y --no-install-recommends \
15+
gcc-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross
16+
;;
17+
*)
18+
# For other targets, this is handled by addons.apt.packages in .travis.yml
19+
;;
20+
esac
21+
}
22+
23+
install_rustup() {
24+
# uninstall the rust toolchain installed by travis, we are going to use rustup
25+
sh ~/rust/lib/rustlib/uninstall.sh
26+
27+
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TRAVIS_RUST_VERSION
28+
29+
rustc -V
30+
cargo -V
31+
}
32+
33+
install_standard_crates() {
34+
if [ $(host) != "$TARGET" ]; then
35+
rustup target add $TARGET
36+
fi
37+
}
38+
39+
configure_cargo() {
40+
local prefix=$(gcc_prefix)
41+
42+
if [ ! -z $prefix ]; then
43+
# information about the cross compiler
44+
${prefix}gcc -v
45+
46+
# tell cargo which linker to use for cross compilation
47+
mkdir -p .cargo
48+
cat >>.cargo/config <<EOF
49+
[target.$TARGET]
50+
linker = "${prefix}gcc"
51+
EOF
52+
fi
53+
}
54+
55+
main() {
56+
install_c_toolchain
57+
install_rustup
58+
install_standard_crates
59+
configure_cargo
60+
61+
case "$TRAVIS_OS_NAME" in
62+
linux)
63+
# libssl-dev is in backports for ARM
64+
if [[ "$(architecture $TARGET)" == arm* ]]; then
65+
66+
sudo sh -c 'echo "deb [arch=arm64,armhf] http://ports.ubuntu.com trusty main universe" >> /etc/apt/sources.list'
67+
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551
68+
fi
69+
70+
sudo apt-get update -qq
71+
sudo apt-get install -y --no-install-recommends \
72+
"libssl-dev:$(architecture $TARGET)" gcc-multilib
73+
;;
74+
osx)
75+
brew update
76+
brew install openssl
77+
;;
78+
esac
79+
}
80+
81+
main

0 commit comments

Comments
 (0)