From 338003b8571b790018713e2b2976f696ea905f91 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Thu, 25 Jan 2018 18:31:48 -0800 Subject: [PATCH] Experiment with 'trust' for CI/build config --- .travis.yml | 111 +++++++++++++++++++++++++++++++++++++++++--- ci/before_deploy.sh | 31 +++++++++++++ ci/install.sh | 47 +++++++++++++++++++ ci/script.sh | 20 ++++++++ 4 files changed, 203 insertions(+), 6 deletions(-) create mode 100755 ci/before_deploy.sh create mode 100755 ci/install.sh create mode 100755 ci/script.sh diff --git a/.travis.yml b/.travis.yml index 8c91a74..3bf4a5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,107 @@ +# Based on the "trust" template v0.1.2 +# https://github.com/japaric/trust/tree/v0.1.2 + +dist: trusty language: rust -rust: - - stable - - beta - - nightly +services: docker +sudo: required + +env: + global: + - CRATE_NAME=rff + matrix: - allow_failures: - - rust: nightly + include: + # ARM + - env: TARGET=aarch64-unknown-linux-gnu + - env: TARGET=arm-unknown-linux-gnueabi + - env: TARGET=armv7-unknown-linux-gnueabihf + + # 686 + - env: TARGET=i686-unknown-linux-gnu + - env: TARGET=i686-unknown-linux-musl + + # PowerPC + - env: TARGET=powerpc-unknown-linux-gnu + - env: TARGET=powerpc64-unknown-linux-gnu + - env: TARGET=powerpc64le-unknown-linux-gnu + + # Good ol' x86_64 + - env: TARGET=x86_64-unknown-linux-gnu + - env: TARGET=x86_64-unknown-linux-musl + + # macOS + - env: TARGET=i686-apple-darwin + os: osx + - env: TARGET=x86_64-apple-darwin + os: osx + + # Nightly + - os: linux + rust: nightly + env: TARGET=i686-unknown-linux-musl + - os: linux + rust: nightly + env: TARGET=x86_64-unknown-linux-musl + - os: linux + rust: nightly + env: TARGET=x86_64-unknown-linux-gnu + - os: osx + rust: nightly + env: TARGET=x86_64-apple-darwin + + # Beta + - os: linux + rust: beta + env: TARGET=i686-unknown-linux-musl + - os: linux + rust: beta + env: TARGET=x86_64-unknown-linux-musl + - os: linux + rust: beta + env: TARGET=x86_64-unknown-linux-gnu + - os: osx + rust: beta + env: TARGET=x86_64-apple-darwin + +before_install: + - set -e + - rustup self update + +install: + - sh ci/install.sh + - source ~/.cargo/env || true + +script: + - bash ci/script.sh + +after_script: set +e + +before_deploy: + - sh ci/before_deploy.sh + +deploy: + api_key: + secure: "uGQ8uifYOSOZqJtV4ydQ9tH+NMVWnCzRvX2Ngicc6jl/QzpGQfLyeaZP2QWssBQXsGmw5iPusvEPOVKmnkGffxfltsGd1zPaDFA83FcPAfC5zBDC5fjaCI8oQL9UqGxI3SGXnFKIQAjMW7HRDfhl/9jlk3KnTKYHjHwExJCzA6WwmMtrELbDiavGcfMkGkC69Jz3SDCbh/yILp/vpu6HJ/ol+7EckQXS44DBPoGyNZ2nGcDn1dXw98rHXOO7Y/G3codKK7+IO+4QzF9cOFIDiDvzyJIqMwGZo4tnQGUQs5WepJK8fQQTuJ1MCcL3SD0d7d/KykOaZoopC8f3oW1KQ+lEqZP6cQxGXStCgrqRRllf7eHahN70TBIbcQSDTwj40TidRE8ozQPNZBbOZAywsOUmrGk1ss3N8CKjP+5UELb09EyvGrlJIolS1K47MTnP4v6fOqPgJyw7DYh7HdI6fN7e2kHN8pDfIB1jAFb5YVRVsS6hdApnIEX/naxp2WLpFWohw01tp7uOJWXmJbsHE1lydvqyUKiWmCO5pDLDWLrZ8Q0kQMaJsW+oF4XnNXgOrPBNPXc7UxHbHdF9NuSdp6EswS5VcbcXbAG3NbH2zR472L+0BV5f4kQ9W6k33I5hvHT2IPKDwtakVbrCcRpUc0naUnd+if9mc/7nJE2jMwE=" + file_glob: true + file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* + on: + condition: $TRAVIS_RUST_VERSION = stable + tags: true + provider: releases + skip_cleanup: true + +cache: cargo +before_cache: + # Travis can't cache files that are not readable by "others" + - chmod -R a+r $HOME/.cargo + +branches: + only: + # release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + email: + on_success: never diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh new file mode 100755 index 0000000..a018250 --- /dev/null +++ b/ci/before_deploy.sh @@ -0,0 +1,31 @@ +# This script takes care of building your crate and packaging it for release + +set -ex + +main() { + local src=$(pwd) \ + stage= + + case $TRAVIS_OS_NAME in + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; + esac + + test -f Cargo.lock || cargo generate-lockfile + + cross build --target $TARGET --release + + cp target/$TARGET/release/rff $stage/ + + cd $stage + tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * + cd $src + + rm -rf $stage +} + +main diff --git a/ci/install.sh b/ci/install.sh new file mode 100755 index 0000000..80e18e4 --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,47 @@ +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # Builds for iOS are done on OSX, but require the specific target to be + # installed. + case $TARGET in + aarch64-apple-ios) + rustup target install aarch64-apple-ios + ;; + armv7-apple-ios) + rustup target install armv7-apple-ios + ;; + armv7s-apple-ios) + rustup target install armv7s-apple-ios + ;; + i386-apple-ios) + rustup target install i386-apple-ios + ;; + x86_64-apple-ios) + rustup target install x86_64-apple-ios + ;; + esac + + # This fetches latest stable release + local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ + | cut -d/ -f3 \ + | grep -E '^v[0.1.0-9.]+$' \ + | $sort --version-sort \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target +} + +main diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 0000000..3ccf556 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,20 @@ +# This script takes care of testing your crate + +set -ex + +main() { + cross build --target $TARGET + cross build --target $TARGET --release + + if [ ! -z $DISABLE_TESTS ]; then + return + fi + + cross test --target $TARGET + cross test --target $TARGET --release +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi