From f9a24d61af4313f5003def3661da8798f02f1666 Mon Sep 17 00:00:00 2001 From: Elliott Linder Date: Tue, 13 Jun 2017 16:52:06 +0200 Subject: [PATCH] chore: add continous integration --- .travis.yml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 4 ++-- appveyor.yml | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ ci/install.sh | 27 ++++++++++++++++++++++++ ci/script.sh | 20 ++++++++++++++++++ 5 files changed, 161 insertions(+), 2 deletions(-) create mode 100755 .travis.yml create mode 100755 appveyor.yml create mode 100755 ci/install.sh create mode 100755 ci/script.sh diff --git a/.travis.yml b/.travis.yml new file mode 100755 index 00000000..bf4bba04 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,55 @@ +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 + +dist: trusty +language: rust +services: docker +sudo: required + +env: + global: + - CRATE_NAME=detour + +matrix: + include: + # Linux + - env: TARGET=i686-unknown-linux-gnu + rust: nightly + - env: TARGET=x86_64-unknown-linux-gnu + rust: nightly + + # OSX + - env: TARGET=i686-apple-darwin + os: osx + rust: nightly + - env: TARGET=x86_64-apple-darwin + os: osx + rust: nightly + +before_install: set -e + +install: + - sh ci/install.sh + - source ~/.cargo/env || true + +script: + - bash ci/script.sh + +after_script: set +e + +deploy: off + +cache: cargo +before_cache: + # Travis can't cache files that are not readable by "others" + - chmod -R a+r $HOME/.cargo + +branches: + only: + # release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + email: + on_success: never diff --git a/README.md b/README.md index 25712787..af2c05e1 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ fn basics() { // nop // ... ``` - *Functions such as this one (lacking a hot-patching area), and too small to + *Functions such as this one, lacking a hot-patching area, and too small to be hooked with a 5-byte `jmp`, are supported thanks to the detection of code padding (`NOP/INT3` instructions). Therefore the required amount of - `NOP` instructions will be replaced, to make room for the detour.* + trailing `NOP` instructions will be replaced, to make room for the detour.* diff --git a/appveyor.yml b/appveyor.yml new file mode 100755 index 00000000..69e98ed1 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,57 @@ +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 + +environment: + global: + RUST_VERSION: nightly + CRATE_NAME: region + matrix: + # MinGW + - TARGET: i686-pc-windows-gnu + - TARGET: x86_64-pc-windows-gnu + + # MSVC + - TARGET: i686-pc-windows-msvc + - TARGET: x86_64-pc-windows-msvc + +install: + - ps: >- + If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { + $Env:PATH += ';C:\msys64\mingw64\bin' + } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { + $Env:PATH += ';C:\msys64\mingw32\bin' + } + - curl -sSf -o rustup-init.exe https://win.rustup.rs/ + - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - rustc -Vv + - cargo -V + +# This is the "test phase" +test_script: + # Don't run the "test phase" when doing deploys + - if [%APPVEYOR_REPO_TAG%]==[false] ( + cargo build --target %TARGET% && + cargo build --target %TARGET% --release && + cargo test --target %TARGET% && + cargo test --target %TARGET% --release + ) + +deploy: off + +cache: + - C:\Users\appveyor\.cargo\registry + - target + +branches: + only: + # Release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + - provider: Email + on_build_success: false + +# Building is done in the test phase, so we disable Appveyor's build phase. +build: false diff --git a/ci/install.sh b/ci/install.sh new file mode 100755 index 00000000..748ad9a9 --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,27 @@ +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # This fetches latest stable release + local 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 \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target +} + +main diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 00000000..c351a7eb --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,20 @@ +# This script takes care of testing your crate + +set -ex + +main() { + cross build --target $TARGET + cross build --target $TARGET --release + + if [ ! -z $DISABLE_TESTS ]; then + return + fi + + cross test --target $TARGET + cross test --target $TARGET --release +} + +# Don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi