From 1045c7d6ba6df78b3e2c9a64b909cc1e79aa0c7e Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 16 Oct 2016 11:12:49 -0500 Subject: [PATCH] during deploy, non-deploy branches should NOP --- .travis.yml | 47 ++++++++++++++++++++++++++++++++--------------- appveyor.yml | 7 +++++-- ci/install.ps1 | 38 ++++++++++++++++++++------------------ ci/package.sh | 24 +++++++++++------------- ci/run-docker.sh | 1 + ci/run.sh | 2 +- 6 files changed, 70 insertions(+), 49 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3139b25..27fbad8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ sudo: required env: global: - CRATE_NAME=trust + - DEPLOY_VERSION=nightly - TARGET=x86_64-unknown-linux-gnu matrix: @@ -39,24 +40,40 @@ matrix: - env: TARGET=s390x-unknown-linux-gnu - env: TARGET=x86_64-unknown-linux-musl + # just to check these build jobs are skipped during deploys + - env: TARGET=x86_64-apple-darwin + os: osx + rust: stable + - env: TARGET=x86_64-unknown-linux-gnu + rust: stable + - env: TARGET=x86_64-unknown-linux-musl + rust: stable + install: - # `std for cross-compilation - - curl https://static.rust-lang.org/rustup.sh | - sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot` - # For transparent QEMU user emulation - - test $TRAVIS_OS_NAME = osx || - docker run --privileged --rm -it ubuntu:16.04 sh -c - "apt-get update && apt-get install -qq binfmt-support qemu-user-static" + - if [ -z $TRAVIS_TAG ] || [ $TRAVIS_RUST_VERSION = $DEPLOY_VERSION ]; then + # `std for cross-compilation + curl https://static.rust-lang.org/rustup.sh | + sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot`; + + # For transparent QEMU user emulation + test $TRAVIS_OS_NAME = osx || + docker run --privileged --rm -it ubuntu:16.04 sh -c + "apt-get update && apt-get install -qq binfmt-support qemu-user-static"; + fi script: - - cargo generate-lockfile - - if [[ $TRAVIS_OS_NAME = linux ]]; then - sh ci/run-docker.sh $TARGET; - else - sh ci/run.sh; + - if [ -z $TRAVIS_TAG ] || [ $TRAVIS_RUST_VERSION = $DEPLOY_VERSION ]; then + cargo generate-lockfile; + + if [[ $TRAVIS_OS_NAME = linux ]]; then + sh ci/run-docker.sh $TARGET; + else + sh ci/run.sh; + fi; + + # Travis can't cache files that are not readable by "others" + chmod -R a+r $HOME/.cargo; fi - # Travis can't cache files that are not readable by "others" - - chmod -R a+r $HOME/.cargo before_deploy: - sh ci/package.sh $TARGET @@ -70,7 +87,7 @@ deploy: # don't delete the target directory skip_cleanup: true on: - condition: $TRAVIS_RUST_VERSION = nightly + condition: $TRAVIS_RUST_VERSION = $DEPLOY_VERSION tags: true branches: diff --git a/appveyor.yml b/appveyor.yml index f790138..fdc37ef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,7 @@ environment: global: CRATE_NAME: trust + DEPLOY_VERSION: nightly RUST_VERSION: nightly matrix: - TARGET: i586-pc-windows-msvc @@ -30,7 +31,9 @@ test_script: cargo test --target %TARGET% --release ) ) else ( - cargo rustc --target %TARGET% --release --bin hello -- -C lto + if [%RUST_VERSION%]==[%DEPLOY_VERSION%] ( + cargo rustc --target %TARGET% --release --bin hello -- -C lto + ) ) before_deploy: @@ -43,7 +46,7 @@ deploy: secure: bQ29dEXeNG5VP2hQcWiZ1xsfmkGosteCDNeYu/cXTX4lOeghOp0qANpQXmGfal29 provider: GitHub on: - RUST_VERSION: nightly + RUST_VERSION: %DEPLOY_VERSION% appveyor_repo_tag: true cache: diff --git a/ci/install.ps1 b/ci/install.ps1 index d889b45..ec7077d 100644 --- a/ci/install.ps1 +++ b/ci/install.ps1 @@ -1,26 +1,28 @@ -$Env:HOST = $Env:TARGET +If ($Env:APPVEYOR_REPO_TAG -eq 'false' -Or $Env:RUST_VERSION -eq $Env:DEPLOY_VERSION) { + $Env:HOST = $Env:TARGET -If ($Env:TARGET -Match 'gnu') { - if ($Env:TARGET -Match 'x86_64') { - $Env:PATH += ';C:\msys64\mingw64\bin' - } else { - $Env:PATH += ';C:\msys64\mingw32\bin' + If ($Env:TARGET -Match 'gnu') { + if ($Env:TARGET -Match 'x86_64') { + $Env:PATH += ';C:\msys64\mingw64\bin' + } else { + $Env:PATH += ';C:\msys64\mingw32\bin' + } + } ElseIf ($Env:TARGET -Match 'i586') { + $Env:HOST = 'i686-pc-windows-msvc' } -} ElseIf ($Env:TARGET -Match 'i586') { - $Env:HOST = 'i686-pc-windows-msvc' -} -[Net.ServicePointManager]::SecurityProtocol = 'Ssl3, Tls, Tls12' -Start-FileDownload 'https://win.rustup.rs' 'rustup-init.exe' + [Net.ServicePointManager]::SecurityProtocol = 'Ssl3, Tls, Tls12' + Start-FileDownload 'https://win.rustup.rs' 'rustup-init.exe' -.\rustup-init --default-host $Env:HOST --default-toolchain $Env:RUST_VERSION -y + .\rustup-init --default-host $Env:HOST --default-toolchain $Env:RUST_VERSION -y -$Env:PATH = 'C:\Users\appveyor\.cargo\bin;' + $Env:PATH + $Env:PATH = 'C:\Users\appveyor\.cargo\bin;' + $Env:PATH -If ($Env:TARGET -ne $Env:HOST) { - rustup target add $Env:TARGET -} + If ($Env:TARGET -ne $Env:HOST) { + rustup target add $Env:TARGET + } -rustc -Vv + rustc -Vv -cargo -V + cargo -V +} diff --git a/ci/package.sh b/ci/package.sh index 55fe40a..d6f14c0 100644 --- a/ci/package.sh +++ b/ci/package.sh @@ -1,8 +1,17 @@ set -ex run() { - local src_dir=$(pwd)\ - stage=$(mk_temp_dir) + local src_dir=$(pwd) \ + stage= + + case $TRAVIS_OS_NAME in + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; + esac cp target/$TARGET/release/hello $stage/ @@ -13,15 +22,4 @@ run() { rm -rf $stage } -mk_temp_dir() { - case $TRAVIS_OS_NAME in - linux) - mktemp -d - ;; - osx) - mktemp -d -t tmp - ;; - esac -} - run diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 2fe831b..df2373d 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -11,6 +11,7 @@ run() { --user $(id -u):$(id -g) \ -e CARGO_HOME=/cargo \ -e CARGO_TARGET_DIR=/target \ + -e DEPLOY_VERSION=$DEPLOY_VERSION \ -e TARGET=$1 \ -e TRAVIS_OS_NAME=linux \ -e TRAVIS_RUST_VERSION=$TRAVIS_RUST_VERSION \ diff --git a/ci/run.sh b/ci/run.sh index 21a8f68..a432ccc 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -34,7 +34,7 @@ run() { if [ -z $TRAVIS_TAG ]; then test_mode - else + elif [ $TRAVIS_RUST_VERSION = $DEPLOY_VERSION ]; then deploy_mode fi }