Skip to content

Commit

Permalink
Refactor ci scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
io12 committed Jan 12, 2019
1 parent ea14cce commit 34fc153
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ before_install:
- rustup self update

install:
- sh ci/install.sh
- ./ci/install.sh
- source ~/.cargo/env || true

script:
- bash ci/script.sh
- ./ci/script.sh

after_script: set +e

before_deploy:
- sh ci/before_deploy.sh
- ./ci/before_deploy.sh

deploy:
api_key:
Expand Down
10 changes: 6 additions & 4 deletions ci/before_deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/bin/sh

# This script takes care of building your crate and packaging it for release

set -ex

main() {
test -f Cargo.lock || cargo generate-lockfile

cross rustc --bin $CRATE_NAME --target $TARGET --release -- -C lto
cross rustc --bin "$CRATE_NAME" --target "$TARGET" --release -- -C lto

case $TARGET in
x86_64-apple-darwin)
cp target/$TARGET/release/$CRATE_NAME $CRATE_NAME-macos
cp "target/$TARGET/release/$CRATE_NAME" "$CRATE_NAME-macos"
;;
x86_64-unknown-linux-gnu)
cp target/$TARGET/release/$CRATE_NAME $CRATE_NAME-linux
cp "target/$TARGET/release/$CRATE_NAME" "$CRATE_NAME-linux"
;;
x86_64-pc-windows-gnu)
cp target/$TARGET/release/$CRATE_NAME.exe $CRATE_NAME-windows.exe
cp "target/$TARGET/release/$CRATE_NAME.exe" "$CRATE_NAME-windows.exe"
;;
*)
echo "error: Unknown target $TARGET"
Expand Down
15 changes: 7 additions & 8 deletions ci/install.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/bin/sh

set -ex

main() {
local target=
if [ $TRAVIS_OS_NAME = linux ]; then
target=x86_64-unknown-linux-musl
sort=sort
if [ "$TRAVIS_OS_NAME" = linux ]; then
sort="sort"
else
target=x86_64-apple-darwin
sort=gsort # for `sort --sort-version`, from brew's coreutils.
fi

Expand All @@ -31,7 +30,7 @@ main() {
esac

# This fetches latest stable release
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
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 \
Expand All @@ -40,8 +39,8 @@ main() {
sh -s -- \
--force \
--git japaric/cross \
--tag $tag \
--target $target
--tag "$tag" \
--target "$TARGET"
}

main
14 changes: 8 additions & 6 deletions ci/script.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/bin/sh

# This script takes care of testing your crate

set -ex

main() {
cross build --target $TARGET
cross build --target $TARGET --release
cross build --target "$TARGET"
cross build --target "$TARGET" --release

if [ ! -z $DISABLE_TESTS ]; then
if [ -n "$DISABLE_TESTS" ]; then
return
fi

cross test --target $TARGET
cross test --target $TARGET --release
cross test --target "$TARGET"
cross test --target "$TARGET" --release
}

# we don't run the "test phase" when doing deploys
if [ -z $TRAVIS_TAG ]; then
if [ -z "$TRAVIS_TAG" ]; then
main
fi

0 comments on commit 34fc153

Please sign in to comment.