Skip to content

Commit 30286b5

Browse files
committed
Add travisci build support
Signed-off-by: Paul Osborne <[email protected]>
1 parent 18f0254 commit 30286b5

File tree

5 files changed

+219
-0
lines changed

5 files changed

+219
-0
lines changed

.travis.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Based on the "trust" template v0.1.2
2+
# https://github.com/japaric/trust/tree/v0.1.2
3+
4+
dist: trusty
5+
language: rust
6+
services: docker
7+
sudo: required
8+
9+
env:
10+
global:
11+
- CRATE_NAME=gpio-cdev
12+
13+
matrix:
14+
# TODO These are all the build jobs. Adjust as necessary. Comment out what you
15+
# don't need
16+
include:
17+
# Android (disabled for now due to nix issues)
18+
# - env: TARGET=aarch64-linux-android DISABLE_TESTS=1
19+
# - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1
20+
# - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1
21+
# - env: TARGET=i686-linux-android DISABLE_TESTS=1
22+
# - env: TARGET=x86_64-linux-android DISABLE_TESTS=1
23+
24+
# TODO: Add back when we have a MacOS stub implementaiton
25+
# - env: TARGET=i686-apple-darwin
26+
# os: osx
27+
# - env: TARGET=x86_64-apple-darwin
28+
# os: osx
29+
30+
# Linux
31+
- env: TARGET=aarch64-unknown-linux-gnu
32+
- env: TARGET=arm-unknown-linux-gnueabi
33+
- env: TARGET=armv7-unknown-linux-gnueabihf
34+
- env: TARGET=i686-unknown-linux-gnu
35+
- env: TARGET=i686-unknown-linux-musl
36+
- env: TARGET=mips-unknown-linux-gnu
37+
- env: TARGET=mips64-unknown-linux-gnuabi64
38+
- env: TARGET=mips64el-unknown-linux-gnuabi64
39+
- env: TARGET=mipsel-unknown-linux-gnu
40+
- env: TARGET=powerpc-unknown-linux-gnu
41+
- env: TARGET=powerpc64-unknown-linux-gnu
42+
- env: TARGET=powerpc64le-unknown-linux-gnu
43+
- env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1
44+
- env: TARGET=x86_64-unknown-linux-gnu
45+
- env: TARGET=x86_64-unknown-linux-musl
46+
47+
# Testing other channels
48+
- env: TARGET=x86_64-unknown-linux-gnu
49+
rust: nightly
50+
51+
before_install:
52+
- set -e
53+
- rustup self update
54+
55+
install:
56+
- sh ci/install.sh
57+
- source ~/.cargo/env || true
58+
59+
script:
60+
- bash ci/script.sh
61+
62+
after_script: set +e
63+
64+
before_deploy:
65+
- sh ci/before_deploy.sh
66+
67+
deploy:
68+
api_key:
69+
secure: "ZZdMvl1P0aryrEKReoR4wApMHw48+9Z843+4G/vmEDvqj0ogZ7ryDZ49gHiEc0cV7QHXE/OIBLIYtS9WVIDZ4h7HTLke5IdhB1pvOJX1dovQfxIZaR66Z9pVvcIJ/KOVgkxAzqd8WrcI/uvLnSH4VWflu0D1X10Ry7j6xZjVByhwh9ObNktklCkQWDbt19fABpRJZ0aZjj2djzlSpLWiYeg0Dj6GnrDp4fBki8LCQmJtE1QcEb83fegfyLPCT4/eI1f4vwayJ/6RhMtMbYcNWs8B0tuaPvYuzBZWwRsN2cMz6BrIiMO0CjOa8tjl6kCnrlOqd84wdE8l9/TTx6Scjwrii/xN2heOhbeOOXe8DElmL3JmUvRzMtK8idwGSYAyqWWiTojwPsVF3IylCANQJhcSyymtANl4OqD1kxtdUY3kvWH675fbi2iJt1uaAv8ZnjesMjzhnCcUYF7NIfuif0VWOqaBbG9T+39rBav8quqWwWJUqytk3kI/rqdlVGsNWWeeM6ZqstQuZHtTIuzOmgI8VNyKlKIWLJJzlD+t2rvr0FD+iOstwxEKiY1Hhh8naOR1+cJg8jekLDJl6wLKR/7oIXlPJ5csm0086MNQ68K1NLqmA6qPzb2B3V8HCwW/vhw6M2pXSqKqziwd2iLn7TdOezX8nY56NA/ty0EtHYA="
70+
file_glob: true
71+
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
72+
on:
73+
condition: $TRAVIS_RUST_VERSION = stable
74+
tags: true
75+
provider: releases
76+
skip_cleanup: true
77+
78+
cache: cargo
79+
before_cache:
80+
# Travis can't cache files that are not readable by "others"
81+
- chmod -R a+r $HOME/.cargo
82+
83+
branches:
84+
only:
85+
# release tags
86+
- /^v\d+\.\d+\.\d+.*$/
87+
- master
88+
89+
notifications:
90+
email:
91+
on_success: never

ci/before_deploy.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This script takes care of packaging the build artifacts that will go in the
2+
# release zipfile
3+
4+
$SRC_DIR = $PWD.Path
5+
$STAGE = [System.Guid]::NewGuid().ToString()
6+
7+
Set-Location $ENV:Temp
8+
New-Item -Type Directory -Name $STAGE
9+
Set-Location $STAGE
10+
11+
$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"
12+
13+
# TODO Update this to package the right artifacts
14+
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\hello.exe" '.\'
15+
16+
7z a "$ZIP" *
17+
18+
Push-AppveyorArtifact "$ZIP"
19+
20+
Remove-Item *.* -Force
21+
Set-Location ..
22+
Remove-Item $STAGE
23+
Set-Location $SRC_DIR

ci/before_deploy.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This script takes care of building your crate and packaging it for release
2+
3+
set -ex
4+
5+
main() {
6+
local src=$(pwd) \
7+
stage=
8+
9+
case $TRAVIS_OS_NAME in
10+
linux)
11+
stage=$(mktemp -d)
12+
;;
13+
osx)
14+
stage=$(mktemp -d -t tmp)
15+
;;
16+
esac
17+
18+
test -f Cargo.lock || cargo generate-lockfile
19+
20+
# Build the examples
21+
cross build --examples --target $TARGET --release
22+
for f in $(dir examples); do
23+
example=$(echo "${f}" | tr -d '.rs')
24+
cp target/$TARGET/release/examples/${example} $stage/
25+
done
26+
27+
cd $stage
28+
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
29+
cd $src
30+
31+
rm -rf $stage
32+
}
33+
34+
main

ci/install.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
set -ex
2+
3+
main() {
4+
local target=
5+
if [ $TRAVIS_OS_NAME = linux ]; then
6+
target=x86_64-unknown-linux-musl
7+
sort=sort
8+
else
9+
target=x86_64-apple-darwin
10+
sort=gsort # for `sort --sort-version`, from brew's coreutils.
11+
fi
12+
13+
# Builds for iOS are done on OSX, but require the specific target to be
14+
# installed.
15+
case $TARGET in
16+
aarch64-apple-ios)
17+
rustup target install aarch64-apple-ios
18+
;;
19+
armv7-apple-ios)
20+
rustup target install armv7-apple-ios
21+
;;
22+
armv7s-apple-ios)
23+
rustup target install armv7s-apple-ios
24+
;;
25+
i386-apple-ios)
26+
rustup target install i386-apple-ios
27+
;;
28+
x86_64-apple-ios)
29+
rustup target install x86_64-apple-ios
30+
;;
31+
esac
32+
33+
# This fetches latest stable release
34+
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
35+
| cut -d/ -f3 \
36+
| grep -E '^v[0.1.0-9.]+$' \
37+
| $sort --version-sort \
38+
| tail -n1)
39+
curl -LSfs https://japaric.github.io/trust/install.sh | \
40+
sh -s -- \
41+
--force \
42+
--git japaric/cross \
43+
--tag $tag \
44+
--target $target
45+
}
46+
47+
main

ci/script.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This script takes care of testing your crate
2+
3+
set -ex
4+
5+
main() {
6+
cross build --target $TARGET
7+
cross build --target $TARGET --release
8+
9+
if [ ! -z $DISABLE_TESTS ]; then
10+
return
11+
fi
12+
13+
cross test --target $TARGET
14+
cross test --target $TARGET --release
15+
16+
# No main binary, so skip the 'cross run' portion
17+
# cross run --target $TARGET
18+
# cross run --target $TARGET --release
19+
}
20+
21+
# we don't run the "test phase" when doing deploys
22+
if [ -z $TRAVIS_TAG ]; then
23+
main
24+
fi

0 commit comments

Comments
 (0)