Skip to content

Commit

Permalink
during deploy, non-deploy branches should NOP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Aparicio committed Oct 16, 2016
1 parent 59adf98 commit 1045c7d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 49 deletions.
47 changes: 32 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sudo: required
env:
global:
- CRATE_NAME=trust
- DEPLOY_VERSION=nightly
- TARGET=x86_64-unknown-linux-gnu

matrix:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
environment:
global:
CRATE_NAME: trust
DEPLOY_VERSION: nightly
RUST_VERSION: nightly
matrix:
- TARGET: i586-pc-windows-msvc
Expand Down Expand Up @@ -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:
Expand All @@ -43,7 +46,7 @@ deploy:
secure: bQ29dEXeNG5VP2hQcWiZ1xsfmkGosteCDNeYu/cXTX4lOeghOp0qANpQXmGfal29
provider: GitHub
on:
RUST_VERSION: nightly
RUST_VERSION: %DEPLOY_VERSION%
appveyor_repo_tag: true

cache:
Expand Down
38 changes: 20 additions & 18 deletions ci/install.ps1
Original file line number Diff line number Diff line change
@@ -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
}
24 changes: 11 additions & 13 deletions ci/package.sh
Original file line number Diff line number Diff line change
@@ -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/

Expand All @@ -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
1 change: 1 addition & 0 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ run() {

if [ -z $TRAVIS_TAG ]; then
test_mode
else
elif [ $TRAVIS_RUST_VERSION = $DEPLOY_VERSION ]; then
deploy_mode
fi
}
Expand Down

0 comments on commit 1045c7d

Please sign in to comment.