Skip to content

Commit

Permalink
Fix travis builds (#1)
Browse files Browse the repository at this point in the history
Mostly copied from fd
  • Loading branch information
lespea authored Oct 31, 2018
1 parent 43c7c38 commit 59f37d9
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 25 deletions.
118 changes: 94 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,118 @@
language: rust
sudo: false
cache: cargo

env:
global:
# Default target on travis-ci.
# Used as conditional check in the install stage
- HOST=x86_64-unknown-linux-gnu

# Used on the deployment script
- PROJECT_NAME=fse_dump

install:
# prevent target re-add error from rustup
- if [[ "z$TARGET" != "z" && $TRAVIS_OS_NAME = linux && $HOST != $TARGET ]]; then rustup target add $TARGET; fi
- if [[ "z$TARGET" != "z" && $TRAVIS_OS_NAME = windows && $TARGET != "x86_64-pc-windows-msvc" ]]; then rustup target add $TARGET; fi

matrix:
allow_failures:
- rust: nightly
- os: windows

fast_finish: true

include:
- rust: stable
- rust: nightly
- name: Clippy
rust: nightly
before_script: rustup component add clippy-preview
script: cargo clippy --all -- -D clippy

- name: rustfmt
rust: nightly
before_script: rustup component add rustfmt-preview
script: cargo fmt --all -- --check
- name: warnings

# - name: release
# rust: stable
# script:
# - cargo build --all --release
# - cargo test --all --release
# - cargo doc --all --release
# on:
# tags: true

- os: linux
rust: stable
script: cargo check --all
- name: release
env:
- TARGET=x86_64-unknown-linux-gnu
- EXE=linux-gnu-x64
- os: linux
rust: stable
env:
- TARGET=x86_64-unknown-linux-musl
- EXE=linux-musl-x64
addons:
apt:
packages: &musl_packages
- musl
- musl-dev
- musl-tools
- os: linux
rust: stable
script:
- cargo build --all --release
- cargo test --all --release
- cargo doc --all --release
env:
- TARGET=i686-unknown-linux-gnu
- EXE=linux-gnu-i686
addons:
apt:
packages: &i686_unknown_linux_gnu
# Cross compiler and cross compiled C libraries
- gcc-multilib
#- os: linux
# rust: stable
# env:
# - TARGET=i686-unknown-linux-musl
# - EXE=linux-musl-i686
# addons:
# apt:
# packages:
# - *musl_packages
# - *i686_unknown_linux_gnu
- os: osx
osx_image: xcode10
rust: stable
env:
- TARGET=x86_64-apple-darwin
- EXE=darwin
- os: windows
rust: stable
env:
- TARGET=x86_64-pc-windows-msvc
- EXE=windows-x64
- os: windows
rust: stable
env:
- TARGET=i686-pc-windows-msvc
- EXE=windows-i686

- os: linux
#before_deploy: ci/deploy.sh
#deploy:
# provider: releases
# file_glob: true
# file: "${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar"
# skip_cleanup: true
# on:
# condition: "$TRAVIS_RUST_VERSION = stable"
# branch: master
# tags: true
# api:
# secure: mTp1YRZi4eJ9htDXzl8l78nlIFdEOOTCs9YEN7ai5ZtbEFwrah2iX/2ofF6ZBGFXpENzXzeaR2xHvJ/9WcucQ0ByatEAO0hlijtxCpIOyuR/bJhIFugGUHn14hgg7Y82tpOC146fufCANMplrmcgL14eo7D2Sam/0xqF+QS2fpuNvKBiU8Wzl3EgUX3hOhrokaM+5KpwomVIw5Jht4zfmAkLe0NDoZWWybc9/ZATiMehxr4FD6pShVwWm4cnbZeuxP7cFbnez4NN1gh9WvRaglSrXtALZ6xgBnDVTK9bHYa1ZKWXLjf8bcqf7PsMPQuT+ak39zFc/SIumjSciU84uS9o2oL2U3ilBwAMQlNYTJ6QgNwhzq81Mn6Gq8Tfl6/ilIEAZ1SjtW8SQyxZUSYCjJK1b7Dgs3GxQ2LjRMShbFY1H1I0L9UatAekDjWcRc8QNwB8pJVt1Vwc2aBrWvUI6tcezs0XmBE1NPX3uHCHuY0LAJsvqyQyIVdvUc0fhXT8srhnwzzfGUKDUBcC9scat6DnqCGgUYpblLNlDPNpDAMBTuqy8/ivxdyIUKo6zzUG7QMNIJXYbs7WCSQ+LHUIrgDxiXtQk1WCi2bEVzU7QHZfpCh4/Ei2GrHcVaO7zcIKwBkmalNkVJxUCMjMxMCrkzU2IdftSKY7+wrO9fl2xNc=
rust: nightly
env: TARGET=x86_64-unknown-linux-gnu

before_deploy: ci/before_deploy.bash

deploy:
provider: releases
file_glob: true
file: pfiles/*
skip_cleanup: true
on:
condition: "$TRAVIS_RUST_VERSION = stable"
#branch: master
tags: true
api_key:
secure: PCRC1AYGYksGfRqUpNglgaOh2t+Jnmv/hd+K4ClScx2OQpjvFZyj1XTJsBN/Ze6VzyQR6dJH5b1g6LRSdF8qB364IOS5L4M6xFov9e1im14TrVDfGf7Dc5Qp4YvqKj+p6FcXwaLbq+AaDJeBfHVmgrI6TyjuYDmOMcaURMlzVCCeNpwkJobKji/Kua8HupYW+Tv/nviZtwhQJZ6EbjWjr65l5BdIEHpRiutjWDR14waa+Mx97ffInzoxCBtJJnU8RRz7uinxwXNF24vcJHy1eocZGJ/jt423beOGUE5NU42aSmXz3HpPquUf/WPp2Pc2SJOa0gK0ZVlu1BBxgO97lruQlQn285wFUDCX4EcrADtPHaTCCDp6YCKajBymEW6M60bKFMG/4YL4S9smYkLroy+dLUlUkBLLM+FdLRi0peYpfaJLHkga2z2/eA6xzHzqj3lrDkEfRgVa2aiJq5p3ZsBqBqKRNSVshZZr95GRmiVah5tsc5REKgOumyvhG8Fqt+MmG+ql502kT5aGhBxk3YswvzQZeUSB/8ACD2Lxc55vUE8Y9wbP4AGo59jPd6h/tC+9LDZRmKF2+20qtV5qfB4vl0JUyFtP7FComvN+I8dQSviH+PWOIvnPz2MCJs9f6xoBr4FAqqODpsMjqUTHMZYZzRufdBGp+aIBMQL2Qz0=

script:
- cargo build --all
- cargo test --all
- cargo doc --all
- ci/script.bash
138 changes: 138 additions & 0 deletions ci/before_deploy.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/usr/bin/env bash
# Building and packaging for release

set -ex

build() {
cargo build --target "$TARGET" --release --verbose
cargo test --all --release
cargo doc --all --release
}

pack() {
mkdir -p pfiles
if [[ "$TRAVIS_OS_NAME" == 'windows' ]]; then
cp "target/$TARGET/release/${PROJECT_NAME}.exe" "pfiles/${PROJECT_NAME}-${TRAVIS_TAG}-${EXE}.exe"
else
strip "target/$TARGET/release/${PROJECT_NAME}"
cp "target/$TARGET/release/${PROJECT_NAME}" "pfiles/${PROJECT_NAME}-${TRAVIS_TAG}-${EXE}"
fi
}

packOld() {
local tempdir
local out_dir
local package_name
local gcc_prefix

tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
out_dir=$(pwd)
package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"

if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then
gcc_prefix="arm-linux-gnueabihf-"
else
gcc_prefix=""
fi

# create a "staging" directory
mkdir "$tempdir/$package_name"
mkdir "$tempdir/$package_name/autocomplete"

# copying the main binary
cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"
"${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME"

# manpage, readme and license
cp "doc/$PROJECT_NAME.1" "$tempdir/$package_name"
cp README.md "$tempdir/$package_name"
cp LICENSE-MIT "$tempdir/$package_name"
cp LICENSE-APACHE "$tempdir/$package_name"

# various autocomplete
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".bash "$tempdir/$package_name/autocomplete/${PROJECT_NAME}.bash-completion"
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".fish "$tempdir/$package_name/autocomplete"
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/_"$PROJECT_NAME" "$tempdir/$package_name/autocomplete"

# archiving
pushd "$tempdir"
tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*
popd
rm -r "$tempdir"
}

make_deb() {
local tempdir
local architecture
local version
local dpkgname
local conflictname

case $TARGET in
x86_64*)
architecture=amd64
;;
i686*)
architecture=i386
;;
*)
echo "make_deb: skipping target '${TARGET}'" >&2
return 0
;;
esac
version=${TRAVIS_TAG#v}
if [[ $TARGET = *musl* ]]; then
dpkgname=$PROJECT_NAME-musl
conflictname=$PROJECT_NAME
else
dpkgname=$PROJECT_NAME
conflictname=$PROJECT_NAME-musl
fi

tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)

# copy the main binary
install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"
strip "$tempdir/usr/bin/$PROJECT_NAME"

# manpage
install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"

# readme and license
install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"
install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"
install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE"

# completions
install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.bash "$tempdir/usr/share/bash-completion/completions/${PROJECT_NAME}"
install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.fish "$tempdir/usr/share/fish/completions/$PROJECT_NAME.fish"
install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/_$PROJECT_NAME "$tempdir/usr/share/zsh/vendor-completions/_$PROJECT_NAME"

# Control file
mkdir "$tempdir/DEBIAN"
cat > "$tempdir/DEBIAN/control" <<EOF
Package: $dpkgname
Version: $version
Section: utils
Priority: optional
Maintainer: Adam Lesperance <[email protected]>
Architecture: $architecture
Provides: $PROJECT_NAME
Conflicts: $conflictname
Description: Dumps the fseventsd entries from a mac
EOF

fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb"
}


main() {
build
pack
#if [[ $TARGET = *linux* ]]; then
#make_deb
#fi
}

main
26 changes: 26 additions & 0 deletions ci/before_install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -ex

if [ "$TRAVIS_OS_NAME" != linux ]; then
exit 0
fi

sudo apt-get update

# needed to build deb packages
sudo apt-get install -y fakeroot

# needed for i686 linux gnu target
if [[ $TARGET == i686-unknown-linux-gnu ]]; then
sudo apt-get install -y gcc-multilib
fi

# needed for cross-compiling for arm
if [[ $TARGET == arm-unknown-linux-gnueabihf ]]; then
sudo apt-get install -y \
gcc-4.8-arm-linux-gnueabihf \
binutils-arm-linux-gnueabihf \
libc6-armhf-cross \
libc6-dev-armhf-cross
fi
7 changes: 6 additions & 1 deletion ci/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/usr/bin/env sh

tar cvf "${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar" "target/release/fse_dump"
mkdir -p pfiles
if [[ "$TRAVIS_OS_NAME" == 'windows' ]]; then
cp "target/release/${PROJECT_NAME}.exe" "pfiles/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.exe"
else
cp "target/release/${PROJECT_NAME}" "pfiles/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}"
fi
6 changes: 6 additions & 0 deletions ci/script.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -ex

# Incorporate TARGET env var to the build and test process
cargo build --target "$TARGET" --verbose

0 comments on commit 59f37d9

Please sign in to comment.