From 24204e7b71d40fe88efd1574300c00c86e173b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Mon, 28 Oct 2019 13:01:55 +1300 Subject: [PATCH] Add windows travis builds --- .travis.yml | 45 ++++++++++++++++++------ ci/before.sh | 18 ++++++++++ ci/before_deploy.sh | 45 ------------------------ ci/before_script.sh | 4 --- ci/deploy.sh | 83 +++++++++++++++++++++++++++++++++++++++++++++ ci/script.sh | 10 ++++-- 6 files changed, 143 insertions(+), 62 deletions(-) create mode 100755 ci/before.sh delete mode 100755 ci/before_deploy.sh delete mode 100755 ci/before_script.sh create mode 100755 ci/deploy.sh diff --git a/.travis.yml b/.travis.yml index d194eb3..cb2a83d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,38 @@ +dist: xenial language: rust -cache: cargo -dist: trusty -sudo: false + +cache: + - directories: + - $HOME/.cargo + - target/debug/deps + - target/$TARGET/debug/deps +before_cache: + # Travis can't cache files that are not readable by "others" + - chmod -R a+r $HOME/.cargo addons: apt: packages: - fakeroot + - musl-dev + - musl-tools env: global: - PROJECT_NAME=watchexec matrix: + fast_finish: true + allow_failures: + - env: CARGO_CLIPPY=1 + - env: TARGET=i686-unknown-linux-musl + - env: TARGET=x86_64-unknown-linux-musl + - env: TARGET=x86_64-pc-windows-gnu include: - # Default test+release version + # Default test+release versions + - os: windows + rust: stable + env: TARGET=x86_64-pc-windows-msvc - os: osx rust: stable env: TARGET=x86_64-apple-darwin @@ -22,27 +40,32 @@ matrix: rust: stable env: TARGET=x86_64-unknown-linux-gnu - # Extra targets for linux only + # Extra targets, released on best-effort - os: linux rust: stable env: TARGET=i686-unknown-linux-musl - os: linux rust: stable env: TARGET=x86_64-unknown-linux-musl + - os: windows + rust: stable + env: TARGET=x86_64-pc-windows-gnu # Minimum version advertised in readme + - os: windows + rust: 1.38.0 + env: TARGET=x86_64-apple-darwin - os: linux rust: 1.38.0 env: TARGET=x86_64-unknown-linux-gnu - - os: osx - rust: 1.38.0 - env: TARGET=x86_64-apple-darwin - fast_finish: true -before_script: ci/before_script.sh + # Clippy only + - env: CARGO_CLIPPY=1 + +before_install: ci/before.sh script: ci/script.sh -before_deploy: ci/before_deploy.sh +before_deploy: ci/deploy.sh deploy: provider: releases api_key: diff --git a/ci/before.sh b/ci/before.sh new file mode 100755 index 0000000..ae64159 --- /dev/null +++ b/ci/before.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +rustup target add $TARGET +cargo clean --target $TARGET --verbose + +if [ $TRAVIS_OS_NAME = windows ]; then + choco install windows-sdk-10.1 +fi + +if [[ ! -z "$CARGO_AUDIT" ]]; then + which cargo-audit || cargo install --debug cargo-audit + # --debug for faster build at the minimal expense of runtime speed +elif [[ ! -z "$CARGO_CLIPPY" ]]; then + rustup component add clippy +fi + diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh deleted file mode 100755 index 777bbb8..0000000 --- a/ci/before_deploy.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash - -# Build script shamelessly stolen from ripgrep :) - -cargo build --target $TARGET --release --locked - -build_dir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) -out_dir=$(pwd) -name="${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}" -mkdir "$build_dir/$name" - -cp target/$TARGET/release/watchexec "$build_dir/$name/" -cp {doc/watchexec.1,LICENSE,completions/zsh} "$build_dir/$name/" - -pushd $build_dir -tar cvf "$out_dir/$name.tar" * -popd -gzip -f9 "$name.tar" - - -if [[ "$TARGET" == "x86_64-unknown-linux-gnu" ]]; then - mkdir -p "$build_dir/deb/$name" - pushd "$build_dir/deb/$name" - - mkdir -p DEBIAN usr/bin usr/share/man/man1 usr/share/zsh/site-functions - cp "../../$name/watchexec" usr/bin/ - cp "../../$name/watchexec.1" usr/share/man/man1/ - cp "../../$name/zsh" usr/share/zsh/site-functions/_watchexec - cat < DEBIAN/control -Package: watchexec -Version: ${TRAVIS_TAG} -Architecture: amd64 -Maintainer: Félix Saparelli -Installed-Size: $(du -d1 usr | tail -n1 | cut -d\t -f1) -Homepage: https://github.com/watchexec/watchexec -Description: Executes commands in response to file modifications. - Software development often involves running the same commands over and over. Boring! - Watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications. -CONTROL - cd .. - fakeroot dpkg -b "$name" - mv "$name.deb" "$out_dir/" - popd -fi - diff --git a/ci/before_script.sh b/ci/before_script.sh deleted file mode 100755 index 88f888a..0000000 --- a/ci/before_script.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -rustup target add $TARGET -cargo clean --target $TARGET --verbose diff --git a/ci/deploy.sh b/ci/deploy.sh new file mode 100755 index 0000000..91f1af6 --- /dev/null +++ b/ci/deploy.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +### Vars + +project="$PROJECT_NAME" +tag="$TRAVIS_TAG" +target="$TARGET" + +[[ -z "$project" ]] && exit 21 +[[ -z "$tag" ]] && exit 22 +[[ -z "$target" ]] && exit 23 + +ext="" +windows="" +if [[ "$target" == *"windows"* ]]; then + choco install 7zip + ext=".exe" + windows="1" +fi + +project="cargo-watch" +build_dir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) +out_dir=$(pwd) +name="$project-$tag-$target" + +### Build + +cargo build --target $target --release --locked + +### Decorate + +mkdir "$build_dir/$name" +cp -v "target/$target/release/$project$ext" "$build_dir/$name/" +cp -v LICENSE "$build_dir/$name/" +cp -v README.md "$build_dir/$name/" +cp -v completions/zsh "$build_dir/$name/" +cp -v doc/watchexec.1 "$build_dir/$name/" +ls -shal "$build_dir/$name/" + +### Strip + +cd "$build_dir" +strip "$name/$project$ext" +ls -shal "$name/" + +### Pack + +if [[ -z "$windows" ]]; then + tar cvf "$out_dir/$name.tar" "$name" + cd "$out_dir" + xz -f9 "$name.tar" +else + 7z a "$out_dir/$name.zip" "$name" +fi + +### Debify + +if [[ "$target" == "x86_64-unknown-linux-gnu" ]]; then + mkdir -p "$build_dir/deb/$name" + cd "$build_dir/deb/$name" + + mkdir -p DEBIAN usr/bin usr/share/man/man1 usr/share/zsh/site-functions + cp "../../$name/watchexec" usr/bin/ + cp "../../$name/watchexec.1" usr/share/man/man1/ + cp "../../$name/zsh" usr/share/zsh/site-functions/_watchexec + cat < DEBIAN/control +Package: watchexec +Version: ${TRAVIS_TAG} +Architecture: amd64 +Maintainer: Félix Saparelli +Installed-Size: $(du -d1 usr | tail -n1 | cut -d\t -f1) +Homepage: https://github.com/watchexec/watchexec +Description: Executes commands in response to file modifications. + Software development often involves running the same commands over and over. Boring! + Watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications. +CONTROL + cd .. + fakeroot dpkg -b "$name" + mv "$name.deb" "$out_dir/" + popd +fi + +ls -shal "$out_dir/" diff --git a/ci/script.sh b/ci/script.sh index 95dee5d..3e40488 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash -cargo build --target $TARGET --verbose -cargo test --target $TARGET --verbose +if [[ ! -z "$CARGO_AUDIT" ]]; then + cargo check --target $TARGET + cargo audit +elif [[ ! -z "$CARGO_CLIPPY" ]]; then + cargo clippy --target $TARGET +else + cargo test --target $TARGET +fi